DNS Server: 192.168.6.101
FreeNAS Server : 192.168.6.102
SCAN IP: 192.168.6.107, 192.168.6.108
RAC1 |
RAC2 |
|
Hostname |
rac1.vmrac.com |
rac2.vmrac.com |
Public IP |
192.168.6.103 |
192.168.6.104 |
Private IP |
192.168.100.103 |
192.168.100.104 |
Virtual IP |
192.168.6.105 |
192.168.6.106 |
操作系统为 CentOS 5.8 x86_64。为满足Oracle安装需求,设置系统swap空间至少为内存1.5倍,最大16G。
# yum --disablerepo=\* --enablerepo=c5-media -y install bind bind-chroot caching-nameserver
cd /var/named/chroot/etc/
cp -p named.caching-nameserver.conf named.conf
cp -p named.rfc1912.zones named.zones
#########################################################
# 修改红色部分
vi named.conf
options {
listen-on port 53 { any; };
listen-on-v6 port 53 { ::1; };
directory "/var/named";
dump-file "/var/named/data/cache_dump.db";
statistics-file "/var/named/data/named_stats.txt";
memstatistics-file "/var/named/data/named_mem_stats.txt";
// Those options should be used carefully because they disable port
// randomization
// query-source port 53;
// query-source-v6 port 53;
allow-query { any; };
allow-query-cache { any; };
};
logging {
channel default_debug {
file "data/named.run";
severity dynamic;
};
};
view localhost_resolver {
match-clients { any; };
match-destinations { any; };
recursion yes;
include "/etc/named.zones";
};
#########################################################
vi named.zones
# 修改顶级域内容为/dev/null,目的是为了通过CRS安装的验证。
zone "." IN {
type hint;
file "/dev/null";
};
#以下两个zone为新增的,包含正向和反向zone
zone "vmrac.com" IN {
type master;
file "vmrac.com.zero";
allow-update { none; };
};
zone "6.168.192.in-addr.arpa" IN {
type master;
file "6.168.192.local";
allow-update { none; };
};
#########################################################
cd /var/named/chroot/var/named/
cp -p named.zero vmrac.com.zero
cp -p named.local 6.168.192.local
# 这里加入了scan,还可以加入hosts里面的其他配置
# vi vmrac.com.zero
$TTL 86400
@ IN SOA vmrac.com. root.vmrac.com. (
42 ; serial (d. adams)
3H ; refresh
15M ; retry
1W ; expiry
1D ) ; minimum
IN NS vmrac.com.
rac-scan IN A 192.168.6.107
rac-scan IN A 192.168.6.108
rac-scan.vmrac.com IN A 192.168.6.107
rac-scan.vmrac.com IN A 192.168.6.108
# vi 6.168.192.local
$TTL 86400
@ IN SOA vmrac.com. root.vmrac.com. (
1997022700 ; Serial
28800 ; Refresh
14400 ; Retry
3600000 ; Expire
86400 ) ; Minimum
IN NS vmrac.com.
1 IN PTR vmrac.com.
107 IN PTR rac-scan.vmrac.com.
108 IN PTR rac-scan.vmrac.com.
#########################################################
重新启动DNS服务
chkconfig named on
service named restart
共享存储的设置见《搭建基于FreeNAS的共享存储》
vi /etc/fstab
tmpfs /dev/shm tmpfs defaults,size=3276M 0 0
为了启用Oracle 11g AMM特性,此处size至少设置为物理内存的80%
mount -o remount /dev/shm
yum --disablerepo=\* --enablerepo=c5-media -y install binutils compat-db compat-gcc-34 compat-gcc-34-c++ compat-libstdc++-33 elfutils-libelf-devel gcc gcc-c++ glibc-* libXp.so.6 libXt.so.6 libXtst.so.6 libgcc_s.so.1 ksh libXp libaio-devel numactl numactl-devel sysstat unixODBC unixODBC-devel pdksh
如果:pdksh包yum不到,需要手工安装
# rpm -e ksh 如果和 ksh有冲突,可以把ksh卸载掉
# rpm -i pdksh-5.2.14-37.el5.i386.rpm
# rpm -i pdksh-5.2.14-37.el5.x86_64.rpm
chkconfig iptables off
service iptables stop
sed -i 's/SELINUX=enforcing/SELINUX=disabled/' /etc/selinux/config
# 在hosts文件里面加入地址信息
vi /etc/hosts
# public
192.168.6.103 rac1.vmrac.com rac1
192.168.6.104 rac2.vmrac.com rac2
# private
192.168.100.103 rac1-priv.vmrac.com rac1-priv
192.168.100.104 rac2-priv.vmrac.com rac2-priv
# virtual
192.168.6.105 rac1-vip.vmrac.com rac1-vip
192.168.6.106 rac2-vip.vmrac.com rac2-vip
# 配置DNS信息
vi /etc/resolv.conf
search vmrac.com
nameserver 192.168.6.101
在虚拟机的测试环境中,一个简单的办法是两个节点互为NTP服务器。
mv /etc/ntp.conf /etc/ntp.conf.bak
vi /etc/ntp.conf
RAC1 |
RAC2 |
server rac1 server rac2 fudge rac1 stratum 10 driftfile /etc/ntp/drift |
server rac1 server rac2 fudge rac2 stratum 10 driftfile /etc/ntp/drift |
chown ntp:ntp /etc/ntp
vi /etc/sysconfig/ntpd
# 加入 -x 参数
OPTIONS="-x -u ntp:ntp -p /var/run/ntpd.pid"
chkconfig ntpd on
service ntpd restart
ntpq -p
########################################
vi /etc/sysctl.conf
kernel.shmmni = 4096
kernel.sem = 250 32000 100 128
fs.file-max = 6815744
fs.aio-max-nr = 1048576
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
/sbin/sysctl -p
########################################
vi /etc/security/limits.conf
# Added for Oracle Shell Limits
oracle soft nproc 2047
oracle hard nproc 16384
oracle soft nofile 1024
oracle hard nofile 65536
grid soft nproc 2047
grid hard nproc 16384
grid soft nofile 1024
grid hard nofile 65536
########################################
vi /etc/pam.d/login
# Added for Oracle Shell Limits
session required pam_limits.so
groupadd oinstall
groupadd dba
groupadd asmdba
groupadd asmadmin
groupadd asmoper
useradd -g oinstall -G dba,asmdba -d /home/oracle -s /bin/bash -m oracle
echo oracle | passwd --stdin oracle
useradd -g oinstall -G dba,asmdba,asmadmin,asmoper -d /home/grid -s /bin/bash -m grid
echo grid | passwd --stdin grid
mkdir -p /u01/app/oracle
mkdir -p /u01/app/grid
mkdir -p /u01/app/grid_home
mkdir -p /u01/oradata
mkdir -p /u01/redo
mkdir -p /u02/archivelog
mkdir -p /u02/rmanbackup
mkdir -p /u02/dpdump
mkdir -p /home/oracle/script
mkdir -p /home/oracle/upload
mkdir -p /home/grid/upload
chown -R oracle:oinstall /home/oracle
chown -R grid:oinstall /home/grid
chown -R oracle:oinstall /u01
chown -R oracle:oinstall /u02
chown -R grid:oinstall /u01/app/grid
chown -R grid:oinstall /u01/app/grid_home
chmod -R 775 /u01
chmod -R 775 /u02
# cp ./rlwrap_static_x64 /usr/bin/
# chmod +x /usr/bin/rlwrap*
# ln -s /usr/bin/rlwrap_static_x64 /usr/bin/rlwrap
# vi /home/grid/.bash_profile
RAC1 |
RAC2 |
export ORACLE_HOSTNAME=`hostname` export ORACLE_BASE=/u01/app/grid export GI_HOME=/u01/app/grid_home export ORACLE_HOME=${GI_HOME} export ORACLE_HOME_LISTNER=${ORACLE_HOME} export ORACLE_PATH=${ORACLE_HOME}/rdbms/admin export ORACLE_SID=+ASM1 export PATH=${PATH}:${ORACLE_HOME}/bin export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:${ORACLE_HOME}/lib export SQLPATH=~/script export NLS_LANG=AMERICAN_AMERICA.ZHS16GBK
alias ct='crs_stat -t' alias asmcmd='rlwrap asmcmd'
|
export ORACLE_HOSTNAME=`hostname` export ORACLE_BASE=/u01/app/grid export GI_HOME=/u01/app/grid_home export ORACLE_HOME=${GI_HOME} export ORACLE_HOME_LISTNER=${ORACLE_HOME} export ORACLE_PATH=${ORACLE_HOME}/rdbms/admin export ORACLE_SID=+ASM2 export PATH=${PATH}:${ORACLE_HOME}/bin export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:${ORACLE_HOME}/lib export SQLPATH=~/script export NLS_LANG=AMERICAN_AMERICA.ZHS16GBK
alias ct='crs_stat -t' alias asmcmd='rlwrap asmcmd'
|
# vi /home/oracle/.bash_profile
RAC1 |
RAC2 |
export ORACLE_HOSTNAME=`hostname` export ORACLE_BASE=/u01/app/oracle export ORACLE_HOME=${ORACLE_BASE}/product/11.2.0/dbhome_1 export ORACLE_HOME_LISTNER=${ORACLE_HOME} export ORACLE_PATH=${ORACLE_HOME}/rdbms/admin export ORACLE_SID=demo1 export PATH=${PATH}:${ORACLE_HOME}/bin export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:${ORACLE_HOME}/lib export SQLPATH=~/script export NLS_LANG=AMERICAN_AMERICA.ZHS16GBK
alias sqlplus='rlwrap sqlplus' alias rman='rlwrap rman' alias dgmgrl='rlwrap dgmgrl'
|
export ORACLE_HOSTNAME=`hostname` export ORACLE_BASE=/u01/app/oracle export ORACLE_HOME=${ORACLE_BASE}/product/11.2.0/dbhome_1 export ORACLE_HOME_LISTNER=${ORACLE_HOME} export ORACLE_PATH=${ORACLE_HOME}/rdbms/admin export ORACLE_SID=demo2 export PATH=${PATH}:${ORACLE_HOME}/bin export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:${ORACLE_HOME}/lib export SQLPATH=~/script export NLS_LANG=AMERICAN_AMERICA.ZHS16GBK
alias sqlplus='rlwrap sqlplus' alias rman='rlwrap rman' alias dgmgrl='rlwrap dgmgrl'
|
11g中的用户等效性,通过GI安装文件目录下的脚本执行。在安装的过程中,需要输入对应用户的密码信息。
# ./sshUserSetup.sh -user grid -hosts "rac1 rac2" - noPromptPassphrase -confirm -advanced
# ./sshUserSetup.sh -user oracle -hosts "rac1 rac2" - noPromptPassphrase -confirm -advanced
共享存储的设置见《搭建基于FreeNAS的共享存储》
本节的操作如无特殊说明,都是使用root用户执行。
涉及文件(和系统内核统一版本)
Ø oracleasm-support-2.1.7-1.el5.x86_64.rpm
Ø oracleasm-2.6.18-308.el5-2.0.5-1.el5.x86_64.rpm
Ø oracleasmlib-2.0.4-1.el5.x86_64.rpm
安装ASM(All)
# rpm -ivh *.rpm
默认安装顺序和上面文件列表的排序一致
配置ASM(All)
# oracleasm configure -i
在提示输入用户和组信息的时候,输入grid和asmadmin
初始化磁盘路径,默认/dev/oracleasm/disks/ (All)
# oracleasm init
# oracleasm createdisk ocr1 /dev/sda5
# oracleasm createdisk fra1 /dev/sda6
# oracleasm createdisk data1 /dev/sda7
# oracleasm createdisk data2 /dev/sda8
刷新ASM磁盘信息(All)
# oracleasm scandisks
# oracleasm listdisks
本节的操作如无特殊说明,都是使用grid用户执行。
在实际安装之前,通过GI安装文件目录下的runcluvfy工具进行验证。
$ ./runcluvfy.sh stage -pre crsinst -n rac1,rac2 -verbose
修改静默安装配置文件my_grid_install_rac.rsp
配置文件要特别注意,ORACLE_HOME不能在ORACLE_BASE路径下面。(oracle用户的要求相反,ORACLE_HOME要在ORACLE_BASE下面)
# cat /home/grid/upload/my_grid_install_rac.rsp | grep -v ^# | grep -v ^$
# 仅保留了部分重要的参数
ORACLE_HOSTNAME=rac1.vmrac.com
INVENTORY_LOCATION=/u01/app/oraInventory
SELECTED_LANGUAGES=en
oracle.install.option=CRS_CONFIG
ORACLE_BASE=/u01/app/grid
ORACLE_HOME=/u01/app/grid_home
oracle.install.asm.OSDBA=asmdba
oracle.install.asm.OSOPER=asmoper
oracle.install.asm.OSASM=asmadmin
oracle.install.crs.config.gpnp.scanName=rac-scan.vmrac.com
oracle.install.crs.config.gpnp.scanPort=1521
oracle.install.crs.config.clusterName=rac-cluster
oracle.install.crs.config.gpnp.configureGNS=false
oracle.install.crs.config.autoConfigureClusterNodeVIP=false
oracle.install.crs.config.clusterNodes=rac1:rac1-vip,rac2:rac2-vip
oracle.install.crs.config.networkInterfaceList=eth0:192.168.6.0:1,eth1:192.168.100.0:2
oracle.install.crs.config.storageOption=ASM_STORAGE
oracle.install.crs.config.useIPMI=false
oracle.install.asm.SYSASMPassword=888888
oracle.install.asm.diskGroup.name=OCR
oracle.install.asm.diskGroup.redundancy=EXTERNAL
oracle.install.asm.diskGroup.AUSize=1
oracle.install.asm.diskGroup.disks=/dev/oracleasm/disks/OCR1
oracle.install.asm.diskGroup.diskDiscoveryString=/dev/oracleasm/disks/*
oracle.install.asm.monitorPassword=888888
注意:-responseFile参数必须使用绝对路径
$ ./runInstaller -silent -ignoreSysPrereqs -ignorePrereq -showProgress -responseFile /home/grid/upload/my_grid_install_rac.rsp
(All,Order)
顺利执行完安装之后,还是以root身份运行配置文件。运行的顺序是rac1,rac2,而且必须等前一个运行完成之后才能进行下一个。在运行root.sh的时候,可以通过log文件的内容来监控进度。
# /u01/app/oraInventory/orainstRoot.sh
# /u01/app/grid_home/root.sh
(RAC1)
在所有节点都执行了上面的操作之后,还需要以grid用户执行configToolAllCommands 。这个脚本必须在执行安装过程的节点上执行,并且需要提供一个配置文件。
$ cd $ORACLE_HOME/cfgtoollogs/
# 编辑一个响应文件保存ASM的密码,生成密码文件的过程需要使用
$ vi cfgrsp.properties
oracle.assistants.asm|S_ASMPASSWORD=888888
oracle.assistants.asm|S_ASMMONITORPASSWORD=888888
$ chmod 600 cfgrsp.properties
$ ./configToolAllCommands RESPONSE_FILE=./cfgrsp.properties
本节的操作如无特殊说明,都是使用grid用户执行。
在安装GRID的过程中,已经建立了OCR磁盘组,这里增加其他的两个磁盘组。为了演示不同的语法,这里用了增加磁盘的做法。
$ asmca -silent -createDiskGroup -sysAsmPassword 888888 -diskString '/dev/oracleasm/disks/*' -diskGroupName FRA -diskList '/dev/oracleasm/disks/FRA1' -redundancy EXTERNAL -compatible.asm 11.2 -compatible.rdbms 11.2
$ asmca -silent -createDiskGroup -sysAsmPassword 888888 -diskString '/dev/oracleasm/disks/*' -diskGroupName DATA -diskList '/dev/oracleasm/disks/DATA1' -redundancy EXTERNAL -compatible.asm 11.2 -compatible.rdbms 11.2
$ asmca -silent -addDisk -sysAsmPassword 888888 -diskGroupName DATA -diskList '/dev/oracleasm/disks/DATA2'
本节的操作如无特殊说明,都是使用oracle用户执行。
在实际安装之前,通过cluvfy工具进行验证。这个时候因为仅安装了GI软件,所以暂时使用grid用户目录下的工具来运行。
$ /u01/app/grid_home/bin/ cluvfy stage -pre dbinst -n rac1,rac2 -verbose
确认并修改静默安装配置文件my_db_install_swonly_rac.rsp
$ cat /home/oracle/upload/my_db_install_swonly_rac.rsp | grep -v ^# | grep -v ^$
# 仅保留部分参数,和单机安装最大的一个区别就是oracle.install.db.CLUSTER_NODES参数
oracle.install.option=INSTALL_DB_SWONLY
ORACLE_HOSTNAME=rac1.vmrac.com
UNIX_GROUP_NAME=oinstall
INVENTORY_LOCATION=/u01/app/oraInventory
SELECTED_LANGUAGES=en
ORACLE_HOME=/u01/app/oracle/product/11.2.0/dbhome_1
ORACLE_BASE=/u01/app/oracle
oracle.install.db.InstallEdition=EE
oracle.install.db.EEOptionsSelection=false
oracle.install.db.DBA_GROUP=dba
oracle.install.db.OPER_GROUP=oinstall
oracle.install.db.CLUSTER_NODES=rac1,rac2
DECLINE_SECURITY_UPDATES=true
注意:-responseFile参数必须使用绝对路径
$ ./runInstaller -silent -force -showProgress -responseFile /home/oracle/upload/my_db_install_swonly_rac.rsp
(All,Order)
最后步骤是用root身份执行下面文件。
# /u01/app/oracle/product/11.2.0/dbhome_1/root.sh
本节的操作如无特殊说明,都是使用oracle用户执行。
$ cluvfy stage -pre dbcfg -n rac1,rac2 -d $ORACLE_HOME
确认并修改静默安装配置文件my_dbca_createdb_rac.rsp(注意修改GDBNAME,SID,TOTALMEMORY和密码)
$ cat /home/oracle/upload/my_dbca_createdb_rac.rsp | grep -v ^# | grep -v ^$
# 仅保留部分参数,和单机安装最大的一个区别就是NODELIST参数
OPERATION_TYPE = "createDatabase"
GDBNAME = "demo"
SID = "demo"
NODELIST=rac1,rac2
TEMPLATENAME = "General_Purpose.dbc"
SYSPASSWORD = "888888"
SYSTEMPASSWORD = "888888"
STORAGETYPE=ASM
DISKGROUPNAME=DATA
RECOVERYGROUPNAME=FRA
CHARACTERSET = "ZHS16GBK"
NATIONALCHARACTERSET= "AL16UTF16"
注意:-responseFile参数必须使用绝对路径
$ dbca -silent -responseFile /home/oracle/upload/my_dbca_createdb_rac.rsp
我的Blog文章
《CentOS环境配置Oracle 11g R2 Data Guard》
《CentOS 下修改/dev/shm 大小解决ORA-00845》