硬件要求
三台node节点服务器
一台DNS解析服务器
一台openfile共享存储服务器
配置好openfile和DNS后操作如下。
本文以2个节点为例
cd /usr/local
unzip linux_11gR2_grid.zip
unzip linux.x64_11gR2_database_1of2.zip
unzip linux.x64_11gR2_database_2of2.zip
rpm -ivh --nodeps oracleasmlib-2.0.4-1.el5.x86_64.rpm
rpm -ivh --nodeps oracleasm-support-2.1.7-1.el5.x86_64.rpm
rpm -ivh --nodeps oracleasm-2.6.18-194.el5-2.0.5-1.el5.x86_64.rpm
rpm -ivh --nodeps oracleasm-2.6.18-194.el5-debuginfo-2.0.5-1.el5.x86_64.rpm
rpm -ivh --nodeps oracleasm-2.6.18-194.el5debug-2.0.5-1.el5.x86_64.rpm
rpm -ivh --nodeps oracleasm-2.6.18-194.el5xen-2.0.5-1.el5.x86_64.rpm
rpm -ivh --nodeps openmotif21-2.1.30-11.RHEL5.s390.rpm
重要//需要配置gmdsetup
(6)///每台机子都要修改
[root@localhost named]# vim /etc/resolv.conf
nameserver 192.168.10.252
更改resolv.conf文件之后就可以进行解析.///每台机子都要修改
[root@localhost named]# host www.scan.com
www.scan.com has address 192.168.10.240
[root@localhost named]#nslookup
> www.scan.com
(1)光驱挂到本地目录
mkdir -p /mnt/cdrom
mount /dev/cdrom /mnt/cdrom
(2)配置本地源
vim /etc/yum.repos.d/mycdrom.repo
[Server]
name=rhel6server
baseurl=file:///mnt/cdrom/Server
enable=1
gpcheck=1
gpgkey=file:///mnt/cdrom/RPM-GPG-KEY-redhat-release
//不能加空格,全部顶格写
软件安装
yum install xxxxxxx
(3)安装中文包
yum install -y m17n-db-common-cjk* m17n-db-chinese* fonts-ISO8859-2-75dpi*
vim /etc/sysconfig/i18n
LANG="zh_CN.UTF-8"
重启系统验证 ,还可以直接 ctrl+alt+backspace
xshell 设置语言为GBK,不然出现乱码
(4)rac所需软件包
expect是运行此程序所需的包,不是oracle
yum install -y expect* iscsi* binutils* compat-libstdc++* expat* elfutils-libelf* gcc* glibc* ksh* libgcc*
yum install -y pdksh* libgomp* compat-db* libXp* libaio* cpp* setarch* sysstat* unixODBC* libstdc++* make-3*
(5)检查网络接口并设定网络地址
[root@localhost ~]#ifconfig
节点 接口 主机名 ip 描述
1 eth0 rac1 192.168.10.245 公网,Public IP
1 eth1 rac1-priv 192.168.101.101 内网,PRIVATE IP
1 eth1 rac1-vip 192.168.10.247 VIP,浮动ip地址,不需要手动设置
2 eth0 rac2 192.168.10.246
2 eth1 rac2-priv 192.168.100.102
2 eth1 rac2-vip 192.168.10.250
检查每台主机有2个网络接口eth0和eth1对应的ip是正确的。
eth1不需要设置网关。
按照网络规划,为eth0设定好公共ip,为eth1设定好心跳ip,浮动ip地址不需要手动设置。
编辑主机名解析
编辑两台机器的vim /etc/hosts文件如下:
[root@localhost ~]# vim /etc/hosts
127.0.0.1 localhost.localdomain localhost
192.168.10.245 rac1
192.168.10.246 rac2
192.168.10.247 rac3
192.168.100.101 rac1-priv
192.168.100.102 rac2-priv
192.168.100.103 rac3-priv
192.168.10.242 rac1-vip //空地址
192.168.10.243 rac2-vip
192.168.10.244 rac3-vip
修改主机名称,在所有节点执行
vim /etc/sysconfig/network
NETWORKING=yes
NETWORKING_IPV6=no
HOSTNAME=rac1
(6) 创建用户和组
groupadd -g 501 oinstall
groupadd -g 502 dba
groupadd -g 503 oper
groupadd -g 504 asmadmin
groupadd -g 505 asmoper
groupadd -g 506 asmdba
useradd -u 501 -g oinstall -G dba,asmdba,oper oracle
useradd -u 502 -g oinstall -G asmadmin,asmdba,asmoper,oper,dba grid
mkdir -p /oracle/app/
chown -R grid:oinstall /oracle/app/
chmod -R 775 /oracle/app/
mkdir -p /oracle/app/oraInventory
chown -R grid:oinstall /oracle/app/oraInventory
chmod -R 775 /oracle/app/oraInventory
mkdir -p /oracle/app/11.2.0/grid/product/db_1
chown -R grid:oinstall /oracle/app/11.2.0/grid/product/db_1
chmod -R 775 /oracle/app/11.2.0/grid/product/db_1
mkdir -p /oracle/app/grid
chown -R grid:oinstall /oracle/app/grid
chmod -R 775 /oracle/app/grid
mkdir -p /oracle/app/oracle
mkdir -p /oracle/app/oracle/product/11.2.0/db_1
chown -R oracle:oinstall /oracle/app/oracle
chmod -R 775 /oracle/app/oracle
#-----passwd grid
echo "111111" | passwd grid --stdin > /dev/null 2>&1
#-----passwd oracle
echo "111111" | passwd oracle --stdin > /dev/null 2>&1
chown -R grid:oinstall /usr/local/grid
chown -R oracle:oinstall /usr/local/database
(7)修改环境变量
(7.1)修改grid用户环境变量
[root@rac1 ~]# vim /home/grid/.bash_profile
TMP=/tmp; export TMP
TMPDIR=$TMP; export TMPDIR
ORACLE_SID=+ASM1; export ORACLE_SID
ORACLE_BASE=/oracle/app/grid; export ORACLE_BASE
ORACLE_HOME=/oracle/app/11.2.0/grid/product/db_1; export ORACLE_HOME
NLS_DATE_FORMAT="yyyy-mm-dd HH24:MI:SS"; export NLS_DATE_FORMAT
THREADS_FLAG=native; export THREADS_FLAG
PATH=$ORACLE_HOME/bin:$PATH; export PATH
THREADS_FLAG=native; export THREADS_FLAG
PATH=$ORACLE_HOME/bin:$PATH; export PATH
if [ $USER = "oracle" ] || [ $USER = "grid" ]; then
if [ $SHELL = "/bin/ksh" ]; then
ulimit -p 16384
ulimit -n 65536
else
ulimit -u 16384 -n 65536
fi
umask 022
fi
# 这里注意: 测试发现安装RAC的时候, grid用户的ORACLE_BASE不能包含ORACLE_HOME,
# 比如 /u01/grid , /u01/grid/11.2 就不行。
使配置文件生效,同样在其他节点的Grid用户.bash_profile 中加入,
并注意修改 ORACLE_SID=+ASM2
[root@rac1 asm]# source /home/grid/.bash_profile
(7.2)修改oracle用户环境变量
TMP=/tmp; export TMP
TMPDIR=$TMP; export TMPDIR
ORACLE_BASE=/oracle/app/oracle; export ORACLE_BASE
ORACLE_HOME=$ORACLE_BASE/product/11.2.0/db_1; export ORACLE_HOME
ORACLE_SID=racdb1; export ORACLE_SID
ORACLE_TERM=xterm; export ORACLE_TERM
PATH=/usr/sbin:$PATH; export PATH
PATH=$ORACLE_HOME/bin:$PATH; export PATH
LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib; export LD_LIBRARY_PATH
CLASSPATH=$ORACLE_HOME/JRE:$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib;
export CLASSPATH
NLS_DATE_FORMAT="yyyy-mm-dd HH24:MI:SS"; export NLS_DATE_FORMAT
NLS_LANG=AMERICAN_AMERICA.ZHS16GBK;export NLS_LANG
if [ $USER = "oracle" ] || [ $USER = "grid" ]; then
if [ $SHELL = "/bin/ksh" ]; then
ulimit -p 16384
ulimit -n 65536
else
ulimit -u 16384 -n 65536
fi
umask 022
fi
使配置文件生效,同样在其他节点的oracle用户.bash_profile 中加入,
并注意修改 ORACLE_SID=racdb2
(8)修改系统参数
在所有节点都执行
cat >> /etc/profile <<EOF
if [ \$USER = "oracle" ] || [ \$USER = "grid" ]; then
if [ \$SHELL = "/bin/ksh" ]; then
ulimit -p 16384
ulimit -n 65536
else
ulimit -u 16384 -n 65536
fi
umask 022
fi
EOF
(8.1)[root@localhost ~]vim /etc/sysctl.conf
添加
fs.aio-max-nr = 1048576
fs.file-max = 6815744
kernel.shmall = 2097152
kernel.shmmax = 536870912
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 = 1048586
保存后执行下面的命令让配置生效:
sysctl -p
(8.2)vim /etc/security/limits.conf
grid soft nproc 2047
grid hard nproc 16384
grid soft nofile 1024
grid hard nofile 65536
oracle soft nproc 2047
oracle hard nproc 16384
oracle soft nofile 1024
oracle hard nofile 65536
(8.3)vim /etc/pam.d/login
session required pam_limits.so
(8.4)vim /etc/profile
if [ $USER = "oracle" ] || [ $USER = "grid" ]; then
if [ $SHELL = "/bin/ksh" ]; then
ulimit -p 16384
ulimit -n 65536
else
ulimit -u 16384 -n 65536
fi
umask 022
fi
(8.5)vi /etc/csh.login
if ( $USER = "oracle" || $USER = "grid" ) then
limit maxproc 16384
limit descriptors 65536
endif
EOFCSH
手动
(9)建立oracle,grid等效用户
(9.1)首先两个节点间互ping,要确定是通的
[root@rac1 asm]# ping rac2
[root@rac1 asm]# ping rac2-priv
rm -f /home/oracle/.ssh/*;
rm -f /home/grid/.ssh/*;
su - grid -c 'ssh-keygen -t rsa -f ~/.ssh/id_rsa -P ""'
su - oracle -c 'ssh-keygen -t rsa -f ~/.ssh/id_rsa -P ""'
su - grid -c 'cp /home/grid/.ssh/id_rsa.pub /home/grid/.ssh/authorized_keys'
su - oracle -c 'cp /home/oracle/.ssh/id_rsa.pub /home/oracle/.ssh/authorized_keys'
节点rac2,3同上,相互复制
(9.4)验证oracle用户等效性,在所有节点执行
[oracle@rac1 ~]$ ssh rac1 date
[oracle@rac1 ~]$ ssh rac2 date
[oracle@rac1 ~]$ ssh rac1-priv date
[oracle@rac1 ~]$ ssh rac2-priv date
(9.5)验证grid用户等效性
[grid@rac1 ~]$ ssh rac1 date
[grid@rac1 ~]$ ssh rac2 date
同上
(10)集群时间同步服务
要停用 NTP 服务,必须停止当前的 ntpd 服务,从初始化序列中禁用该服务,并删除 ntp.conf 文件。
当安装程序发现 NTP 协议处于非活动状态时,安装集群时间同步服务将以活动模式自动进行安装并通过所有节点的时间。如果发现配置了 NTP,则以观察者模式启动集群时间同步服务,Oracle Clusterware 不会在集群中进行活动的时间同步。
service ntpd stop
chkconfig ntpd off
mv /etc/ntp.conf /etc/ntp.conf.original
rm /var/run/ntpd.pid
rm -f /etc/ntp.conf
(11)[root@rac3 ~]# cat /proc/meminfo |grep MemTotal
MemTotal: 2911172 kB
[root@rac3 ~]# cat /proc/meminfo | grep SwapTotal
SwapTotal: 6094840 kB
If you have less than 4GB of memory (between your RAM and SWAP), you can add temporary swap space by creating a temporary swap file
dd if=/dev/zero of=tempswap bs=1k count=500000
chmod 600 tempswap
mke2fs tempswap
mkswap tempswap
swapon tempswap
(12)配置ASM
(12.3)磁盘分区。在节点1完成
fdisk /dev/sdb sdc sdd
partprobe
fdisk -l
(12.1)初始化 asmlib,在所有节点执行
[root@rac1 ~]# oracleasm configure -i
Configuring the Oracle ASM library driver.
Default user to own the driver interface [grid]: grid
Default group to own the driver interface [asmadmin]: asmadmin
Start Oracle ASM library driver on boot (y/n) [y]: y
Scan for Oracle ASM disks on boot (y/n) [y]: y
Writing Oracle ASM library driver configuration: done
(12.2)ASMlib加载到内核,在所有节点执行
[root@rac2 ~]# oracleasm init
(12.3)创建 asm 磁盘,在节点1执行
[root@rac1 by-path]# oracleasm createdisk CRSVOL1 /dev/sdb1
Writing disk header: done
Instantiating disk: done
[root@rac1 by-path]# oracleasm createdisk DATAVOL1 /dev/sdc1
Writing disk header: done
Instantiating disk: done
[root@rac1 by-path]# oracleasm createdisk FRAVOL1 /dev/sdd1
Writing disk header: done
Instantiating disk: done
[root@rac1 ~]# /usr/sbin/oracleasm listdisks
在节点2,3执行扫描,识别asm盘
[root@rac2 ~]# /usr/sbin/oracleasm scandisks
(13)安装cvuqdisk软件包(在所有节点执行)
cvuqdisk软件包用于发现共享存储,在grid 安装软件的rpm目录中,
cd /usr/local/grid/rpm/
[root@rac2 rpm]# export CVUQDISK_GRP=oinstall
[root@rac2 rpm]# rpm -ivh cvuqdisk-1.0.7-1.rpm
//问题!!!!(13)安装grid前检查(在所有节点执行)
[root@rac1 rpm]# su - grid
[grid@rac1 ~]$ cd /usr/local/grid/
[grid@rac1 grid]$ ./runcluvfy.sh stage -pre crsinst -fixup -n rac1,rac2,rac3 -verbose
[grid@rac1 grid]$./runcluvfy.sh stage -post hwos -n rac1,rac2,rac3 -verbose
(14)安装Grid Infrastructure
登陆到grid 用户,执行安装文件,在节点1执行;
[grid@rac1 grid]$ ./runInstaller
在安装后
(1)确认 ctssd 处于活动状态,请作为网格安装所有者 (grid) 输入以下命令:
[grid@rac01 ~]$ crsctl check ctss
(2)检查 Clusterware 资源
[grid@rac01 ~]$crs_stat -t -v
(3)检查集群节点
[grid@rac01 ~]$olsnodes -n
(4)检查两个节点上的 Oracle TNS 监听器进程 (在各节点测试)
[grid@rac01 ~]$srvctl status listener
[grid@rac01 ~]$ps -ef | grep lsnr | grep -v 'grep' | grep -v 'ocfs' | awk '{print $9}'
(5)确认针对 Oracle Clusterware 文件的 Oracle ASM 功能
确认当前正在运行已安装的 Oracle ASM
[grid@rac01 ~]$srvctl status asm -a
检查 Oracle 集群注册表 (OCR):
[grid@racnode1 ~]$ocrcheck
检查表决磁盘:
[grid@racnode1 ~]$crsctl query css votedisk
(15)为数据和快速恢复区创建 ASM 磁盘组:
[grid@racnode1 ~]$asmca
(16)安装oracle软件
以oracle用户登录到节点1
[oracle@rac1 ~]$ cd /usr/local/database/
[oracle@rac1 database]$ ./runInstaller
(17)创建集群数据库
使用dbca创建,创建之前确保已安装的所有服务(Oracle TNS 监听器、Oracle Clusterware 进程等)正在运行。
[grid@rac1 ~]$ crs_stat -t -v
[oracle@rac1 database]$ dbca