一、环境配置
1.配置Node1和Node2两个节点之间的网卡
Node1:
[root@rac1 network-scripts]# cat ifcfg-eth0 DEVICE=eth0 HWADDR=08:00:27:E6:6A:DF TYPE=Ethernet UUID=543aef46-94aa-442f-9259-8584588c5e66 ONBOOT=yes NM_CONTROLLED=yes BOOTPROTO=none IPADDR=192.168.8.221 NETMASK=255.255.255.0 GATEWAY=192.168.8.1 DNS1=221.228.255.1 [root@rac1 network-scripts]# cat ifcfg-eth1 DEVICE=eth1 HWADDR=08:00:27:72:5A:8F TYPE=Ethernet ONBOOT=yes NM_CONTROLLED=yes BOOTPROTO=none IPADDR=172.168.1.18Node2:
[root@rac2 network-scripts]# cat ifcfg-eth0 DEVICE=eth0 HWADDR=08:00:27:1B:D9:5A TYPE=Ethernet UUID=543aef46-94aa-442f-9259-8584588c5e66 ONBOOT=yes NM_CONTROLLED=yes BOOTPROTO=none IPADDR=192.168.8.223 NETMASK=255.255.255.0 GATEWAY=192.168.8.1 DNS1=221.228.255.1 [root@rac2 network-scripts]# cat ifcfg-eth1 DEVICE=eth1 HWADDR=08:00:27:39:5F:8C TYPE=Ethernet ONBOOT=yes NM_CONTROLLED=yes BOOTPROTO=none IPADDR=172.168.1.192.配置/etc/hosts主机文件
[root@rac1 network-scripts]# cat /etc/hosts 127.0.0.1 localhost ::1 localhost localhost.localdomain localhost6 localhost6.localdomain6 #node1 192.168.8.221 rac1 rac1.oracle.com 192.168.8.222 rac1-vip 172.168.1.18 rac1-priv #node2 192.168.8.223 rac2 rac2.oracle.com 192.168.8.224 rac2-vip 172.168.1.19 rac2-priv #scan-ip 192.168.8.225 rac-cluster rac-cluster-scan3.配置DNS(略,可以暂时不配置)
4.关闭防火墙
service iptables stop chkconfig iptables off5.关闭Selinux
vim /etc/selinux/config SELINUX=disabled
6.创建用户和组
--创建用户: groupadd -g 1000 oinstall groupadd -g 1200 asmadmin groupadd -g 1201 asmdba groupadd -g 1202 asmoper groupadd -g 1300 dba groupadd -g 1301 oper --创建组: useradd -u 1100 -g oinstall -G asmadmin,asmdba,asmoper grid useradd -u 1101 -g oinstall -G dba,oper,asmdba oracle --创建密码: passwd grid passwd oracle
7.配置用户的环境变量
Node1:
--grid用户: export PATH export TMP=/tmp export TMPDIR=$TMP export ORACLE_SID=+ASM1 export ORACLE_BASE=/u01/grid export ORACLE_HOME=/u01/app/grid/11.2.0 export NLS_DATE_FORMAT='yyyy/mm/dd hh24:mi:ss' export TNS_ADMIN=$ORACLE_HOME/network/admin export PATH=/usr/sbin:$PATH export PATH=$ORACLE_HOME/bin:$PATH export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib export CLASSPATH=$ORACLE_HOME/JRE:$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib export LANG=en_US export NLS_LANG=AMERICAN_AMERICA.ZHS16GBK umask 022
--oracle用户: export PATH export TMP=/tmp export TMPDIR=$TMP export ORACLE_HOSTNAME=rac1 export ORACLE_SID=orcl1 export ORACLE_BASE=/u01/oracle export ORACLE_HOME=/u01/app/oracle/product/11.2.0/db_1 export ORACLE_UNQNAME=orcl export TNS_ADMIN=$ORACLE_HOME/network/admin #export ORACLE_TERM=xterm export PATH=/usr/sbin:$PATH export PATH=$ORACLE_HOME/bin:$PATH export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib export CLASSPATH=$ORACLE_HOME/JRE:$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib export LANG=en_US export NLS_LANG=AMERICAN_AMERICA.ZHS16GBK export NLS_DATE_FORMAT='yyyy/mm/dd hh24:mi:ss' umask 022Node2:
--grid用户: export PATH export TMP=/tmp export TMPDIR=$TMP export ORACLE_SID=+ASM2 export ORACLE_BASE=/u01/grid export ORACLE_HOME=/u01/app/grid/11.2.0 export NLS_DATE_FORMAT='yyyy/mm/dd hh24:mi:ss' export TNS_ADMIN=$ORACLE_HOME/network/admin export PATH=/usr/sbin:$PATH export PATH=$ORACLE_HOME/bin:$PATH export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib export CLASSPATH=$ORACLE_HOME/JRE:$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib export LANG=en_US export NLS_LANG=AMERICAN_AMERICA.ZHS16GBK umask 022
--oracle用户: export PATH export TMP=/tmp export TMPDIR=$TMP export ORACLE_HOSTNAME=rac2 export ORACLE_SID=orcl2 export ORACLE_BASE=/u01/oracle export ORACLE_HOME=/u01/app/oracle/product/11.2.0/db_1 export ORACLE_UNQNAME=orcl export TNS_ADMIN=$ORACLE_HOME/network/admin #export ORACLE_TERM=xterm export PATH=/usr/sbin:$PATH export PATH=$ORACLE_HOME/bin:$PATH export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib export CLASSPATH=$ORACLE_HOME/JRE:$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib export LANG=en_US export NLS_LANG=AMERICAN_AMERICA.ZHS16GBK export NLS_DATE_FORMAT='yyyy/mm/dd hh24:mi:ss' umask 0228.创建所需目录
mkdir -p /u01/grid mkdir -p /u01/app/grid/11.2.0 mkdir -p /u01/oracle chown -R oracle:oinstall /u01 chown -R grid:oinstall /u01/grid chown -R grid:oinstall /u01/app/grid/11.2.0 chmod -R 775 /u019.配置limits.con
f增加如配置
vim /etc/security/limits.conf oracle soft nofile 1024 oracle hard nofile 65536 oracle soft nproc 2047 oracle hard nproc 16384 oracle soft stack 10240 oracle hard stack 32768 grid soft nofile 1024 grid hard nofile 65536 grid soft nproc 2047 grid hard nproc 16384 grid soft stack 10240 grid hard stack 3276810.修改内核参数
--注意将原来参数shmmall和shmmax注释掉 vim /etc/sysctl.conf fs.aio-max-nr = 1048576 fs.file-max = 6815744 kernel.shmall = 1073741824 kernel.shmmax = 4398046511104 kernel.shmmni = 4096 kernel.sem = 250 32000 100 128 net.ipv4.ip_local_port_range = 9000 65500 net.core.rmem_default = 262144 net.core.rmem_max = 4194304 net.core.wmem_default = 262144 net.core.wmem_max = 1048576 --使sysctl生效 sysctl -p
11.停止NTP服务
service ntpd stop chkconfig ntpd off mv /etc/ntp.conf /etc/ntp.conf.bak
11.安装相关软件包
yum install gcc compat-libstdc++-33 elfutils-libelf-devel glibc-devel glibc-headers gcc-c++ libaio-devel libstdc++-devel pdksh compat-libcap1-*
12.配置共享存储
for i in b c d e f g ;
do
echo "KERNEL==\"sd*\", BUS==\"scsi\", PROGRAM==\"/sbin/scsi_id --whitelisted --replace-whitespace --device=/dev/\$name\", RESULT==\"`/sbin/scsi_id --whitelisted --replace-whitespace --device=/dev/sd$i`\", NAME=\"asm-disk$i\", OWNER=\"grid\", GROUP=\"asmadmin\", MODE=\"0660\"" >> /etc/udev/rules.d/99-oracle-asmdevices.rules
done
--执行
/sbin/start_udev
13.上传并解压grid和oracle安装包(略)
二、Grid软件安装
1.安装grid,以grid用户登录,并执行./runInstaller进入安装界面
2.进入界面选择跳过软件更新,点击Next
2.选择Grid Infrastructure,点击Next:
3.选择高级安装,点击Next
4.默认Englist,点击Next
5.去掉Configure GNS选项,点击Next
6.点击Add选项,输入对应参数,参考/etc/hosts文件中配置
7.点击SSH Connectivity,输入grid的密码,点击Setup等待配置完成,然后点击Next
8.确认网络接口,eth0为Public,eth1为Private
9.选择Oracle ASM,点击Next
10.输入Disk Group Name,点击Change Discovery Path,在弹出的对话框中输入磁盘的路径,点击OK
11.选择ASM磁盘,点击Next
11.输入口令密码,点击Next
12.选择不使用IPMI,点击Next
13.默认选择,点击Next
14.确认Grid的安装路径,其中Grid软件的ORACLE_HOME不能是ORACLE_BASE的子目录
15.默认Inverntory,点击Next
16.该错误可以从Grid的安装文件的rpm目录下获取,Node1和Node2都安装即可,Device Checks for ASM可忽略
17.进入安装Grid安装前的概要信息界面,点击Install进行安装
18.根据红框中信息,现在Node1节点执行2个脚本,Node1节点全部执行完毕后,再在Node2上分别执行2个脚本,全部执行完毕后,点击OK,执行下一步
脚本执行结果如下
Node1:
[root@rac1 rpm]# /u01/app/oraInventory/orainstRoot.sh Changing permissions of /u01/app/oraInventory. Adding read,write permissions for group. Removing read,write,execute permissions for world. Changing groupname of /u01/app/oraInventory to oinstall. The execution of the script is complete.
[root@rac1 rpm]# /u01/app/11.2.0/grid/root.sh Performing root user operation for Oracle 11g The following environment variables are set as: ORACLE_OWNER= grid ORACLE_HOME= /u01/app/11.2.0/grid Enter the full pathname of the local bin directory: [/usr/local/bin]: Copying dbhome to /usr/local/bin ... Copying oraenv to /usr/local/bin ... Copying coraenv to /usr/local/bin ... Creating /etc/oratab file... Entries will be added to the /etc/oratab file as needed by Database Configuration Assistant when a database is created Finished running generic part of root script. Now product-specific root actions will be performed. Using configuration parameter file: /u01/app/11.2.0/grid/crs/install/crsconfig_params Creating trace directory User ignored Prerequisites during installation Installing Trace File Analyzer OLR initialization - successful root wallet root wallet cert root cert export peer wallet profile reader wallet pa wallet peer wallet keys pa wallet keys peer cert request pa cert request peer cert pa cert peer root cert TP profile reader root cert TP pa root cert TP peer pa cert TP pa peer cert TP profile reader pa cert TP profile reader peer cert TP peer user cert pa user cert Adding Clusterware entries to upstart CRS-2672: Attempting to start 'ora.mdnsd' on 'rac1' CRS-2676: Start of 'ora.mdnsd' on 'rac1' succeeded CRS-2672: Attempting to start 'ora.gpnpd' on 'rac1' CRS-2676: Start of 'ora.gpnpd' on 'rac1' succeeded CRS-2672: Attempting to start 'ora.cssdmonitor' on 'rac1' CRS-2672: Attempting to start 'ora.gipcd' on 'rac1' CRS-2676: Start of 'ora.cssdmonitor' on 'rac1' succeeded CRS-2676: Start of 'ora.gipcd' on 'rac1' succeeded CRS-2672: Attempting to start 'ora.cssd' on 'rac1' CRS-2672: Attempting to start 'ora.diskmon' on 'rac1' CRS-2676: Start of 'ora.diskmon' on 'rac1' succeeded CRS-2676: Start of 'ora.cssd' on 'rac1' succeeded ASM created and started successfully. Disk Group SYSTEMDG created successfully. clscfg: -install mode specified Successfully accumulated necessary OCR keys. Creating OCR keys for user 'root', privgrp 'root'.. Operation successful. CRS-4256: Updating the profile Successful addition of voting disk 03bd9e6851cf4fb4bf4c92e24a3d71cc. Successful addition of voting disk 362f2cfb5b3d4f29bf319c668e0efbe4. Successful addition of voting disk 57659c53f4284fbdbfeabafb20c3fbdd. Successfully replaced voting disk group with +SYSTEMDG. CRS-4256: Updating the profile CRS-4266: Voting file(s) successfully replaced ## STATE File Universal Id File Name Disk group -- ----- ----------------- --------- --------- 1. ONLINE 03bd9e6851cf4fb4bf4c92e24a3d71cc (/dev/asm-diskb) [SYSTEMDG] 2. ONLINE 362f2cfb5b3d4f29bf319c668e0efbe4 (/dev/asm-diskc) [SYSTEMDG] 3. ONLINE 57659c53f4284fbdbfeabafb20c3fbdd (/dev/asm-diskd) [SYSTEMDG] Located 3 voting disk(s). CRS-2672: Attempting to start 'ora.asm' on 'rac1' CRS-2676: Start of 'ora.asm' on 'rac1' succeeded CRS-2672: Attempting to start 'ora.SYSTEMDG.dg' on 'rac1' CRS-2676: Start of 'ora.SYSTEMDG.dg' on 'rac1' succeeded Configure Oracle Grid Infrastructure for a Cluster ... succeededNode2:
[root@rac2 grid]# /u01/app/oraInventory/orainstRoot.sh Changing permissions of /u01/app/oraInventory. Adding read,write permissions for group. Removing read,write,execute permissions for world. Changing groupname of /u01/app/oraInventory to oinstall. The execution of the script is complete.
[root@rac2 grid]# /u01/app/11.2.0/grid/root.sh Performing root user operation for Oracle 11g The following environment variables are set as: ORACLE_OWNER= grid ORACLE_HOME= /u01/app/11.2.0/grid Enter the full pathname of the local bin directory: [/usr/local/bin]: Copying dbhome to /usr/local/bin ... Copying oraenv to /usr/local/bin ... Copying coraenv to /usr/local/bin ... Creating /etc/oratab file... Entries will be added to the /etc/oratab file as needed by Database Configuration Assistant when a database is created Finished running generic part of root script. Now product-specific root actions will be performed. Using configuration parameter file: /u01/app/11.2.0/grid/crs/install/crsconfig_params Creating trace directory User ignored Prerequisites during installation Installing Trace File Analyzer OLR initialization - successful Adding Clusterware entries to upstart CRS-4402: The CSS daemon was started in exclusive mode but found an active CSS daemon on node rac1, number 1, and is terminating An active cluster was found during exclusive startup, restarting to join the cluster Configure Oracle Grid Infrastructure for a Cluster ... succeeded
19.临近执行完毕时,报了一个INS-20802的这种错误,导致这个错误的原因是在/etc/hosts中配置了SCAN的地址,尝试ping这个地址信息,如果可以成功,则这个错误可以忽略。
20.最后单击Close,完成Grid软件在Node1和Node2的安装操作
三、安装Oracle软件
1.安装oracle,以oracle用户登录,并执行./runInstaller进入安装界面
2.直接点击Next
3.选择跳过软件更新,点击Next
5.点击SSH Connectivity,输入Oracle的密码,点击setup,有如下提示,说明成功
6.默认English,点击Next
7.选择Enterprise Edition
8.默认路径,点击Next
9.选择Oracle用户组,默认选择,点击Next
10.Swap size错误增大即可,SCAN错误前面说过,选择Ignore all,点击Next
11.Oracle安装概要信息,点击Next
12.分别在Node1和Node2执行脚本
13.最后点击Close安装完成
四、创建ASM磁盘组
1.以grid用户登录,输入asmca命令,弹出ASM配置界面,点击Create
2.输入Disk Group Name,点击OK,会提示创建成功
3.创建成功后,会发现多出来一行记录,但是在state只显示MOUNTED(1of2)
4.点击Mount ALL,成功后state显示MOUNTED(2of2),点击Exit退出
五、安装数据库实例
1.使用Oracle用户登录,执行dbca命令,弹出如下界面,选择第一项,点击Next
2.点击创建数据库选项,点击Next
3.根据工作中的实际情况选择对应的模板,这里以默认模板为例
4.选择rac1和rac2,输入orcl实例名,点击Next
5.根据实际情况选择是否配置EM,点击Next
6.配置Oracle相关密码,点击Next
7.选择存储ASM,默认选择之前创建的磁盘组,点击Next
8.根据实际情况选择是否启用闪回恢复区,如果启用,需要在asmca中配置闪回区或放入到DATADG中,这里不配置
9.根据实际选择,这里不选择,点击Next
10.这里着重注意下配置正确的字符集,根据实际生产要求,点击Next
11.默认选择数据库存储信息,点击Next
12.点击Finish,开始创建数据库
13.最后完成数据库创建