1、ORACLE 11G RAC 安装配置(自整理)测试配置缓环境:Red Hat Enterprise Linux 5.8一、关闭防火墙rootrac01 # service iptables stoprootrac01 # chkconfig iptables offrootrac01 # chkconfig iptables listiptables 0:off 1:off 2:off 3:off 4:off 5:off 6:offrootrac01 # vi /etc/selinux/config# This file controls the state of SELinux on th
2、e system.# SELINUX= can take one of these three values:# enforcing - SELinux security policy is enforced.# permissive - SELinux prints warnings instead of enforcing.# disabled - No SELinux policy is loaded.SELINUX=disabled# SELINUXTYPE= can take one of these two values:# targeted - Targeted processe
3、s are protected,# mls - Multi Level Security protection.SELINUXTYPE=targeted二、修改 hosts 文件(所有节点)rootrac01 # vi /etc/hosts# Do not remove the following line, or various programs# that require network functionality will fail.127.0.0.1 localhost.localdomain localhost:1 localhost6.localdomain6 localhost6
4、172.18.3.211 rac01172.18.3.212 rac0210.10.10.211 rac01- rac01-priv10.10.10.212 rac02- rac02-priv172.18.3.213 rac01- rac01-vip172.18.3.214 rac02- rac02-vip172.18.3.215 rac- rac-scan172.18.3.216 rac- rac-scan172.18.3.217 rac- rac-scan三、添加组和用户创建组:rootrac01 # groupadd -g 1000 oinstallrootrac01 # group
5、add -g 1001 asmadminrootrac01 # groupadd -g 1002 dbarootrac01 # groupadd -g 1003 asmdbarootrac01 # groupadd -g 1004 asmoper创建 grid 用户:rootrac01 # useradd -u 1000 -g oinstall -G asmadmin,asmdba,asmoper,dba -d /home/grid -m grid为 grid 用户设密码:rootrac01 #passwd grid创建 oracle 用户:如果 oracle 用户不存在,则:rootrac0
6、1 # useradd -u 1001 -g oinstall -G dba,asmdba -d /home/oracle -m oracle如果 oracle 用户已经存在,则:rootrac01 # usermod -g oinstall -G dba,asmdba u 1001 oracle为 oracle 用户设密码:rootrac01 # passwd oracle检测 nobody 用户rootrac01 # id nobody如果不存在,则:rootrac01 # useradd nobody四、配 SSH 互信为 ssh 和 scp 创建连接ls -l /usr/local/b
7、in/sshls -l /usr/local/bin/scp不存在则创建rootrac01 # /bin/ln -s /usr/bin/ssh /usr/local/bin/sshrootrac01 # /bin/ln -s /usr/bin/scp /usr/local/bin/scp为 grid 用户配置 SSH:在每个节点上:rootrac01 # su gridgridrac01 # mkdir /.sshgridrac01 #cd .sshgridrac01 # ssh-keygen -t rsagridrac01 # ssh-keygen -t dsa在节点 1 上:gridrac
8、01 # touch authorized_keysgridrac01 # ssh rac01 cat /home/grid/.ssh/id_rsa.pub authorized_keysgridrac01 # ssh rac02 cat /home/grid/.ssh/id_rsa.pub authorized_keysgridrac01 # ssh rac01 cat /home/grid/.ssh/id_dsa.pub authorized_keysgridrac01 # ssh rac02 cat /home/grid/.ssh/id_dsa.pub authorized_keysgr
9、idrac01 # scp authorized_keys rac02:/home/grid/.ssh/分别在每个节点上:gridrac01 # ssh rac01 dategridrac01 # ssh rac02 dategridrac01 # ssh-agent $SHELLgridrac01 # ssh-add为 oracle 用户配置 SSH:在每个节点上:rootrac01 # su oracleoraclerac01 # mkdir /.sshoraclerac01 #cd .sshoraclerac01 # ssh-keygen -t rsaoraclerac01 # ssh-
10、keygen -t dsa在节点 1 上:oraclerac01 # touch authorized_keysoraclerac01 # ssh rac01 cat /home/oracle/.ssh/id_rsa.pub authorized_keysoraclerac01 # ssh rac02 cat /home/oracle/.ssh/id_rsa.pub authorized_keysoraclerac01 # ssh rac01 cat /home/oracle/.ssh/id_dsa.pub authorized_keysoraclerac01 # ssh rac02 cat
11、/home/oracle/.ssh/id_dsa.pub authorized_keysoraclerac01 # scp authorized_keys rac02:/home/oracle/.ssh/分别在每个节点上:oraclerac01 # ssh rac01 dateoraclerac01 # ssh rac02 dateoraclerac01 # ssh-agent $SHELLoraclerac01 # ssh-add五、配置 NTProotrac01 #vi /etc/ntp.conf.#server 0.centos.pool.ntp.org#server 1.centos.
12、pool.ntp.org#server 2.centos.pool.ntp.orgserver 172.18.3.115#server 127.127.1.0 # local clock#fudge 127.127.1.0 stratum 10rootrac01 # vi /etc/sysconfig/ntpd# Drop root to id ntp:ntp by default.OPTIONS=“-x -u ntp:ntp -p /var/run/ntpd.pid“# Set to yes to sync hw clock after successful ntpdateSYNC_HWCL
13、OCK=yes# Additional options for ntpdateNTPDATE_OPTIONS=“ 启动rootrac01 # chkconfig ntpd onrootrac01 # service ntpd startrootrac01 # ntpdate -d -u 172.18.3.115启用 name service cache daemonrootrac01 # chkconfig -level 35 nscd onrootrac01 # service nscd restart六、配置内核参数:rootrac01 # vi /etc/sysctl.conf# for
14、 oracle 11gfs.aio-max-nr = 1048576fs.file-max = 6815744kernel.shmall = 2147483648kernel.shmmax = 68719476736kernel.shmmni = 4096kernel.sem = 250 32000 100 128net.ipv4.ip_local_port_range = 9000 65500net.core.rmem_default = 262144net.core.rmem_max = 4194304net.core.wmem_default = 262144net.core.wmem_
15、max = 1048586使修改参数立即生效:rootrac01 # /sbin/sysctl -prootrac01 # /etc/security/limits.confgrid soft nproc 2047grid hard nproc 16384grid soft nofile 1024grid hard nofile 65536oracle soft nproc 2047oracle hard nproc 16384oracle soft nofile 1024oracle hard nofile 65536rootrac01 # /etc/pam.d/loginsession r
16、equired pam_limits.sorootrac01 # /etc/profileif $USER = “oracle“ | $USER = “grid“ ; thenif $SHELL = “/bin/ksh“ ; thenulimit -p 16384ulimit -n 65536elseulimit -u 16384 -n 65536fiumask 022fi七、对硬盘进行分区:以下操作在节点 1 完成:rootrac01 # fdisk /dev/sdbCommand (m for help): pDisk /dev/sdb: 8589 MB, 8589934592 bytes
17、255 heads, 63 sectors/track, 1044 cylindersUnits = cylinders of 16065 * 512 = 8225280 bytesDevice Boot Start End Blocks Id SystemCommand (m for help): nCommand actione extendedp primary partition (1-4)pPartition number (1-4): 1First cylinder (1-1044, default 1): Using default value 1Last cylinder or
18、 +size or +sizeM or +sizeK (1-1044, default 1044): Using default value 1044Command (m for help): pDisk /dev/sdb: 8589 MB, 8589934592 bytes255 heads, 63 sectors/track, 1044 cylindersUnits = cylinders of 16065 * 512 = 8225280 bytesDevice Boot Start End Blocks Id System/dev/sdb1 1 1044 8385898+ 83 Linu
19、xCommand (m for help): wThe partition table has been altered!Calling ioctl() to re-read partition table.Syncing disks.fdisk /dev/sdcfdisk /dev/sdd八、安装 asmlib 并进行配置rootrac01 #uname r在每个节点上都进行安装rootrac01 # rpm -ihv oracleasm-support-2.1.3-1.el5.x86_64.rpmrootrac01 # rpm -ihv oracleasm-2.6.18-194.el5-2
20、.0.5-1.el5.x86_64.rpmrootrac01 # rpm -ihv oracleasmlib-2.0.4-1.el5.x86_64.rpm配置 asmlib以下操作在每个节点上进行:rootrac01 # oracleasm configure -iConfiguring the Oracle ASM library driver.This will configure the on-boot properties of the Oracle ASM librarydriver. The following questions will determine whether th
21、e driver isloaded on boot and what permissions it will have. The current valueswill be shown in brackets (). Hitting without typing ananswer will keep that current value. Ctrl-C will abort.Default user to own the driver interface : gridDefault group to own the driver interface : asmadminStart Oracle
22、 ASM library driver on boot (y/n) n: yScan for Oracle ASM disks on boot (y/n) y: Writing Oracle ASM library driver configuration: donerootrac01 # oracleasm initCreating /dev/oracleasm mount point: /dev/oracleasmLoading module “oracleasm“: oracleasmMounting ASMlib driver filesystem: /dev/oracleasm初始化
23、 ASM 磁盘以下操作在节点 1 完成:rootasm01 # oracleasm createdisk disk01 /dev/sdb1Writing disk header: doneInstantiating disk: donerootasm01 # oracleasm createdisk disk02 /dev/sdc1Writing disk header: doneInstantiating disk: doneoracleasm createdisk disk03 /dev/sdd1oracleasm createdisk disk04 /dev/sde1oracleasm
24、createdisk disk05 /dev/sdf1oracleasm createdisk disk06 /dev/sdg1检查 ASM 硬盘配置节点 1:rootrac01 asmlib# oracleasm listdisksDISK01DISK02DISK03其他节点:rootrac02 asmlib# oracleasm listdisks-注意:此处命令输出为空是正常rootrac02 asmlib# oracleasm scandisksReloading disk partitions: doneCleaning any stale ASM disks.Scanning sy
25、stem for ASM disks.Instantiating disk “DISK01“Instantiating disk “DISK02“Instantiating disk “DISK03“rootrac02 asmlib# oracleasm listdisksDISK01DISK02DISK03九、Grid 安装过程grid 用户:gridrac01 # vi .bash_profileexport ORACLE_SID=+ASM1/+ASM2export ORACLE_BASE=/u01/app/oracleexport ORACLE_HOME=/u01/app/grid/11
26、.2export PATH=$PATH:$ORACLE_HOME/binoracle 用户:oraclerac01 # vi .bash_profileexport ORACLE_SID=racdb1/racdb2export ORACLE_UNQNAME=$ORACLE_SIDexport ORACLE_BASE=/u01/app/oracleexport ORACLE_HOME=$ORACLE_BASE/11.2/db_1export PATH=$PATH:$ORACLE_HOME/bin建立相关目录:rootrac01 # mkdir -p /u01/app/oraclerootrac0
27、1 # mkdir -p /u01/app/oracle/u01/app/grid/11.2rootrac01 # chown -R grid:oinstall /u01/app/oraclerootrac01 # chown -R grid:oinstall /u01/app/oracle/u01/app/grid/11.2rootrac01 # chmod 775 -R /u01/app/oraclerootrac01 # chmod 775 -R /u01/app/oracle/u01/app/grid/11.2rootrac01 #mkdir -p /u01/app/oracleroo
28、trac01 #mkdir -p /u01/app/oracle/11.2/db_1rootrac01 #chown -R oracle:oinstall /u01/app/oracle/11.2/db_1rootrac01 #chmod 775 -R /u01/app/oracle/11.2/db_1安装 Grid Infrastructure 软件以下图形界面:节点 1 的 root.sh 输出 LOG 节点 2 的 root.sh 输出 LOGrac01_grid_root.log rac02_grid_root.log确认 Grid 安装成功CRS 状态gridrac01 $ crs_
29、stat -tName Type Target State Host-ora.CRSDG.dg oraup.type ONLINE ONLINE rac01oraER.lsnr oraer.type ONLINE ONLINE rac01oraN1.lsnr oraer.type ONLINE ONLINE rac01ora.asm ora.asm.type ONLINE ONLINE rac01ora.eons ora.eons.type ONLINE ONLINE rac01ora.gsd ora.gsd.type OFFLINE OFFLINEoranetwork orark.type
30、ONLINE ONLINE rac01ora.oc4j ora.oc4j.type OFFLINE OFFLINEora.ons ora.ons.type ONLINE ONLINE rac01oraSM1.asm application ONLINE ONLINE rac01ora01.lsnr application ONLINE ONLINE rac01ora.rac01.gsd application OFFLINE OFFLINEora.rac01.ons application ONLINE ONLINE rac01ora.rac01.vip orat1.type ONLINE O
31、NLINE rac01oraSM2.asm application ONLINE ONLINE rac02ora02.lsnr application ONLINE ONLINE rac02ora.rac02.gsd application OFFLINE OFFLINEora.rac02.ons application ONLINE ONLINE rac02ora.rac02.vip orat1.type ONLINE ONLINE rac02ora.scan1.vip oraip.type ONLINE ONLINE rac01标为蓝色的四个服务,在 11g 里面是可选项,并且默认是 of
32、fline,可忽略。voting disk 状态gridrac01 $ crsctl query css votedisk# STATE File Universal Id File Name Disk group- - - - -1. ONLINE 7b8903f49cc84fa8bf06d199bdf5dfe3 (ORCL:DISK01) CRSDGOCR 状态gridrac01 $ ocrcheckStatus of Oracle Cluster Registry is as follows :Version : 3Total space (kbytes) : 262120Used sp
33、ace (kbytes) : 2264Available space (kbytes) : 259856ID : 1510360228Device/File Name : +CRSDGDevice/File integrity check succeededDevice/File not configuredDevice/File not configuredDevice/File not configuredDevice/File not configuredCluster registry integrity check succeededLogical corruption check
34、bypassed due to non-privileged userASM 磁盘组配置检查监听状态gridrac01 $ lsnrctl statusLSNRCTL for Linux: Version 11.2.0.1.0 - Production on 16-MAR-2011 16:24:36Copyright (c) 1991, 2009, Oracle. All rights reserved.Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=LISTENER)STATUS of the LISTENER-Alias LIS
35、TENERVersion TNSLSNR for Linux: Version 11.2.0.1.0 - ProductionStart Date 16-MAR-2011 14:27:14Uptime 0 days 1 hr. 57 min. 27 secTrace Level offSecurity ON: Local OS AuthenticationSNMP OFFListener Parameter File /u01/app/grid/11.2/network/admin/listener.oraListener Log File /u01/app/oracle/diag/tnsls
36、nr/rac01/listener/alert/log.xmlListening Endpoints Summary.(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=LISTENER)(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=172.18.3.211)(PORT=1521) (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=172.18.3.213)(PORT=1521)Services Summary.Service “+ASM“ has 1 instance(s).Instance
37、 “+ASM1“, status READY, has 1 handler(s) for this service.The command completed successfullygridrac01 $如果没有+ASM 服务,则需要重新配置监听程序。创建新磁盘组使用 asmca,创建 DATADG 和 FLASHDG 两个磁盘组。DATA 创建成功,接下来创建 FLASHDG:FLASHDG 创建成功,退出 ASMCA。十、Database 安装与配置安装前配置配置 oracle 用户 PROFILEoraclerac01 # vi .bash_profileexport ORACLE_SID=racdb1/racdb2export ORACLE_UNQNAME=$ORACLE_SIDexport ORACLE_BASE=/u01/app/oracleexport ORACLE_HOME=$ORACLE_BASE/11.2/db_1export PATH=$PATH:$ORACLE_HOME/binrootrac01 #xhost +rootrac01 #su oracle安装 oracle database 软件以下图形界面: