安装环境
Linux服务器:redhat 企业版 32位
Oracle :Oracle11gR2 32位
系统环境检查
使用命令
rpm -qa | grep
rpm -qa | grep compat-libstdc++-33-3.2.3-61
rpm -qa | grep binutils-2.17.50.0.6-2.el5
rpm -qa | grep binutils-2.17.50.0.6-2.el5
rpm -qa | grep elfutils-libelf-0.125-3.el5
rpm -qa | grep elfutils-libelf-devel-0.125
rpm -qa | grep gcc-4.1.1-52
rpm -qa | grep gcc-c++-4.1.1-52
rpm -qa | grep glibc-2.5-12
rpm -qa | grep glibc-common-2.5-12
rpm -qa | grep glibc-devel-2.5-12
rpm -qa | grep glibc-headers-2.5-12
rpm -qa | grep libaio-0.3.106(一般没有安装)
rpm -qa | grep libaio-devel-0.3.106
rpm -qa | grep libgcc-4.1.1-52
rpm -qa | grep libstdc++-4.1.1
rpm -qa | grep libstdc++-devel-4.1.1-52.e15
rpm -qa | grep make-3.81-1.1
rpm -qa | grep numactl-devel-0.9.8.i386(一般没有安装)
rpm -qa | grep sysstat-7.0.0 (一般没有安装)
rpm -q unixODBC
rpm -q unixODBC-devel
建立用户和目录
[root@localhost /]# vi user.sh
groupadd dba
groupadd oinstall
useradd -g oinstall -g dba -m oracle
passwd oracle
[root@localhost /]#chmod 700 user.sh
[root@localhost /]# ./user.sh
Changing password for user oracle.
New UNIX password:
BAD PASSWORD: it is too simplistic/systematic
Retype new UNIX password:
passwd: all authentication tokens updated successfully.
[root@localhost /]#vi dir.sh
mkdir –p /u01/oracle
mkdir /u01/oracle/app
mkdir /u01/oracle/app/oracle
mkdir /u01/oracle/app/oradata
mkdir /u01/oracle/app/oracle/ product
chown -R oracle:oinstall u01
ls –l
检查nobody用户是否存在
#id nobody
uid=99(nobody) gid=99(nobody) groups=99(nobody)
修改操作系统核心参数
在Root用户下执行以下步骤:
修改用户的SHELL的限制,修改/etc/security/limits.c
onf文件vi /etc/security/limits.conf,按i键进入编辑模式,将下列内容加入该文件。
oracle soft nproc 2047
oracle hard nproc 16384
oracle soft nofile 1024
oracle hard nofile 65536
编辑完成后按Esc键,输入 “:wq” 存盘退出
vi /etc/pam.d/login, 按i键进入编辑模式,将下列内容加入该文件
session required /lib/security/pam_limits.so
session required pam_limits.so
vi /etc/sysctl.conf , 按i键进入编辑模式,将下列内容加入该文件
fs.file-max = 6815744
fs.aio-max-nr = 1048576
kernel.shmall = 2097152
kernel.shmmax = 2147483648
kernel.shmmni = 4096
kernel.sem = 250 32000 100 128
net.ipv4.ip_local_port_range = 9000 65500
net.core.rmem_default = 4194304
net.core.rmem_max = 4194304
net.core.wmem_default = 262144
net.core.wmem_max = 1048576
[root@localhost /]# sysctl -p
net.ipv4.ip_forward = 0
net.ipv4.conf.default.rp_filter = 1
net.ipv4.conf.default.accept_source_route = 0
kernel.sysrq = 0
kernel.core_uses_pid = 1
net.ipv4.tcp_syncookies = 1
kernel.msgmnb = 65536
kernel.msgmax = 65536
fs.file-max = 6815744
fs.aio-max-nr = 1048576
kernel.shmall = 2097152
kernel.shmmax = 2147483648
kernel.shmmni = 4096
kernel.sem = 250 32000 100 128
net.ipv4.ip_local_port_range = 9000 65500
net.core.rmem_default = 4194304
net.core.rmem_max = 4194304
net.core.wmem_default = 262144
net.core.wmem_max = 1048576
vi /etc/profile,按i键进入编辑模式,将下列内容加入该文件
if [ $USER = "oracle" ]; then
if [ $SHELL = "/bin/ksh" ]; then
ulimit -p 16384
ulimit -n 65536
else
ulimit -u 16384 -n 65536
fi
fi
配置oracle用户的环境变量,首先,切换到新创建的oracle用户下,
su – oracle
vi .bash_profile 按i编辑 .bash_profile,进入编辑模式,增加以下内容:
umask 022
export ORACLE_BASE=/home/oracle/app
export ORACLE_HOME=$ORACLE_BASE/oracle/product/11.2.0/dbhome_1
export ORACLE_SID=orcl
export PATH=$PATH:$HOME/bin:$ORACLE_HOME/bin
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/usr/lib
注意:root用户要执行一下xhost +(不然无法起图形界面)
解压oracle
unzip /u01/oracle/linux_11gR2_database_1of2.zip
unzip /u01/oracle/linux_11gR2_database_2of2.zip
su - oracle
cd /u01/oracle/database
[oracle@localhost database]$ ./runInstaller
正在启动 Oracle Universal Installer...
检查临时空间: 必须大于 80 MB。实际为 6469 MB 通过
检查交换空间: 必须大于 150 MB。实际为 2047 MB 通过
检查监视器: 监视器配置至少必须显示 256种颜色。 实际为 16777216通过
准备从以下地址启动 Oracle Universal Installer /tmp/OraInstall2012-06-25_11-23-44AM.请稍候...[oracle@localhost database]$
配置Listener
以oracle用户登录,打开终端,输入netca
netca
选择监听程序配置,然后按默认一直点下一步。
创建数据库
以oracl用户登录,打开终端,输入dbca
下面就是下一步点击安装,我这里就省略了。
手工启动和关闭数据库
[oracle@localhost ~]$sqlplus / as sysdba
SQL*Plus: Release 11.2.0.1.0 Production on Mon Jun 25 15:00:48 2012
Copyright (c) 1982, 2009, Oracle. All rights reserved.
Connected to an idle instance.
SQL> startup
ORACLE instance started.
Total System Global Area 422670336 bytes
Fixed Size 1336960 bytes
Variable Size 281020800 bytes
Database Buffers 134217728 bytes
Redo Buffers 6094848 bytes
????????
????????(这里字符集有点问题)这个可以按照盖总的笔记操作解决这个问题
http://blog.youkuaiyun.com/yujin2010good/article/details/7235895(下面也有解决方法)
SQL> select * from v$version;
BANNER
--------------------------------------------------------------------------------
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production
PL/SQL Release 11.2.0.1.0 - Production
CORE 11.2.0.1.0 Production
TNS for Linux: Version 11.2.0.1.0 - Production
NLSRTL Version 11.2.0.1.0 - Production
SQL>
监听查看
[root@localhost ~]# su - oracle
[oracle@localhost ~]$ lsnrctl status
LSNRCTL for Linux: Version 11.2.0.1.0 - Production on 25-JUN-2012 15:07:11
Copyright (c) 1991, 2009, Oracle. All rights reserved.
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=localhost.localdomain)(PORT=1521)))
TNS-12541: TNS:no listener
TNS-12560: TNS:protocol adapter error
TNS-00511: No listener
Linux Error: 111: Connection refused
[oracle@localhost ~]$ lsnrctl start
LSNRCTL for Linux: Version 11.2.0.1.0 - Production on 25-JUN-2012 15:07:19
Copyright (c) 1991, 2009, Oracle. All rights reserved.
Starting //u01/oracle/app/oracle/product/11.2/db/bin/tnslsnr: please wait...
TNSLSNR for Linux: Version 11.2.0.1.0 - Production
System parameter file is //u01/oracle/app/oracle/product/11.2/db/network/admin/listener.ora
Log messages written to /u01/oracle/app/diag/tnslsnr/localhost/listener/alert/log.xml
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=localhost.localdomain)(PORT=1521)))
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=localhost.localdomain)(PORT=1521)))
STATUS of the LISTENER
------------------------
Alias LISTENER
Version TNSLSNR for Linux: Version 11.2.0.1.0 - Production
Start Date 25-JUN-2012 15:07:19
Uptime 0 days 0 hr. 0 min. 20 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener Parameter File //u01/oracle/app/oracle/product/11.2/db/network/admin/listener.ora
Listener Log File /u01/oracle/app/diag/tnslsnr/localhost/listener/alert/log.xml
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=localhost.localdomain)(PORT=1521)))
The listener supports no services
The command completed successfully
[oracle@localhost ~]$ lsnrctl status
LSNRCTL for Linux: Version 11.2.0.1.0 - Production on 25-JUN-2012 15:07:57
Copyright (c) 1991, 2009, Oracle. All rights reserved.
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=localhost.localdomain)(PORT=1521)))
STATUS of the LISTENER
------------------------
Alias LISTENER
Version TNSLSNR for Linux: Version 11.2.0.1.0 - Production
Start Date 25-JUN-2012 15:07:19
Uptime 0 days 0 hr. 0 min. 38 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener Parameter File //u01/oracle/app/oracle/product/11.2/db/network/admin/listener.ora
Listener Log File /u01/oracle/app/diag/tnslsnr/localhost/listener/alert/log.xml
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=localhost.localdomain)(PORT=1521)))
The listener supports no services
The command completed successfully
[oracle@localhost ~]$
注意:上面字符集有问题,这里修正
查看oracle字符集
SQL> select userenv('language') from dual;
USERENV('LANGUAGE')
--------------------------------------------------------------------------------
SIMPLIFIED CHINESE_CHINA.UTF8
查看linux系统字符集
[root@ora ~]# env |grep LANG
LANG=zh_CN.UTF-8
GDM_LANG=zh_CN.UTF-8
定义linux系统字符集
[root@ora ~]# export NLS_LANG='SIMPLIFIED CHINESE_CHINA.UTF8'
定义oracle环境字符集
[root@ora ~]# su - oracle
[oracle@ora ~]$ export NLS_LANG='SIMPLIFIED CHINESE_CHINA.UTF8'
[oracle@ora ~]$ !sql
查看结果
SQL> select * from database_properties;