Oracle RAC集群安装
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Oracle RAC集群安装相关的知识,希望对你有一定的参考价值。
安装企业版Oracle数据库需要安装两部分:Oracle RAC, Oracle Database. Oracle RAC原理请参考这篇文章。本篇原创介绍的是RAC 安装的实操部分,数据库的安装部分请参考这篇文章。
以Oracle 12C为例。
Oracle官方网站下载grid 安装包:
http://www.oracle.com/technetwork/database/enterprise-edition/downloads/oracle12c-linux-12201-3608234.html
安装前准备。
oracle rac作为集群软件,在安装之前需要对各个要安装的服务器进行集群配置,以下操作需要在三台server上面依次完成:
1) IP地址划分
本次以三台服务器为集群节点为例,划分ip地址如下(关于oracle rac ip地址分类介绍请看这里):
Public ip:
192.168.0.10
192.168.0.11
192.168.0.12
Private ip:
192.168.1.10
192.168.1.11
192.168.1.12
Virtual ip:
192.168.0.13
192.168.0.14
192.168.0.15
Scan ip:
192.168.0.16
所以在三台服务器(test-4,test-5,test-6)上面/etc/hosts的配置如下(在一台server上面配置好了以后直接拷贝到另外两台机器):
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.0.10 test-4 test-4.localdomain
192.168.0.13 test-4-vip
192.168.0.11 test-5 test-5.localdomain
192.168.0.14 test-5-vip
192.168.0.12 test-6 test-6.localdomain
192.168.0.15 test-6-vip
192.168.0.16 scan4 scan4.localdomain
192.168.1.10 test-4-priv
192.168.1.11 test-5-priv
192.168.1.12 test-6-priv
从这份配置中可以看到每个ip对应的host。public ip和private ip在安装之前需要ifconfig配置完成,virtual ip,scan ip不需要ifconfig配置。
2)创建新用户(grid,oracle)和组(oinstall,dba,asmadmin,asmdba,asmoper,oper),以其中一台 test-5上的操作为例:
[[email protected] ~]# groupadd -g 501 oinstall
[[email protected] ~]# groupadd -g 502 dba
[[email protected] ~]# groupadd -g 504 asmadmin
[[email protected] ~]# groupadd -g 506 asmdba
[[email protected] ~]# groupadd -g 507 asmoper
[[email protected] ~]# useradd -u 5001 -g oinstall -G dba,asmadmin,asmdba,asmoper -d /home/grid -s /bin/bash -c "grid" grid
[[email protected] ~]# su - grid
[[email protected] ~]$ id grid
uid=5001(grid) gid=501(oinstall) groups=501(oinstall),502(dba),504(asmadmin),506(asmdba),507(asmoper)
[[email protected] ~]# groupadd -g 503 oper
[[email protected] ~]# useradd -u 5002 -g oinstall -G dba,oper,asmdba -d /home/oracle -s /bin/bash -c "oracle" oracle
[[email protected] ~]# su - oracle
[[email protected] ~]$ id oracle
uid=5002(oracle) gid=501(oinstall) groups=501(oinstall),502(dba),506(asmdba),503(oper
3)修改系统 linux limits文件 /etc/security/limits.conf:
cp /etc/security/limits.conf /etc/security/limits.conf.bak
echo "oracle soft nproc 2047" >>/etc/security/limits.conf
echo "oracle hard nproc 16384" >>/etc/security/limits.conf
echo "oracle soft nofile 1024" >>/etc/security/limits.conf
echo "oracle hard nofile 65536" >>/etc/security/limits.conf
echo "grid soft nproc 2047" >>/etc/security/limits.conf
echo "grid hard nproc 16384" >>/etc/security/limits.conf
echo "grid soft nofile 1024" >>/etc/security/limits.conf
echo "grid hard nofile 65536" >>/etc/security/limits.conf
4)修改/etc/profile:
cp /etc/profile /etc/profile.bak
echo ‘if [ $USER = "oracle" ]||[ $USER = "grid" ]; then‘ >> /etc/profile
echo ‘if [ $SHELL = "/bin/ksh" ]; then‘ >> /etc/profile
echo ‘ulimit -p 16384‘ >> /etc/profile
echo ‘ulimit -n 65536‘ >> /etc/profile
echo ‘else‘ >> /etc/profile
echo ‘ulimit -u 16384 -n 65536‘ >> /etc/profile
echo ‘fi‘ >> /etc/profile
echo ‘fi‘ >> /etc/profile
5)在三个节点分别运行以下命令:
cp /etc/sysctl.conf /etc/sysctl.conf.bak
echo "fs.aio-max-nr = 1048576" >> /etc/sysctl.conf
echo "fs.file-max = 6815744" >> /etc/sysctl.conf
echo "kernel.shmall = 2097152" >> /etc/sysctl.conf
echo "kernel.shmmax = 1054472192" >> /etc/sysctl.conf
echo "kernel.shmmni = 4096" >> /etc/sysctl.conf
echo "kernel.sem = 250 32000 100 128" >> /etc/sysctl.conf
echo "net.ipv4.ip_local_port_range = 9000 65500" >> /etc/sysctl.conf
echo "net.core.rmem_default = 262144" >> /etc/sysctl.conf
echo "net.core.rmem_max = 4194304" >> /etc/sysctl.conf
echo "net.core.wmem_default = 262144" >> /etc/sysctl.conf
echo "net.core.wmem_max = 1048586" >> /etc/sysctl.conf
echo "net.ipv4.tcp_wmem = 262144 262144 262144" >> /etc/sysctl.conf
echo "net.ipv4.tcp_rmem = 4194304 4194304 4194304" >> /etc/sysctl.conf
sysctl -p
6)grid用户的 .bash_profile:
# .bash_profile
# Get the aliases and functions
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
# User specific environment and startup programs
TMP=/tmp; export TMP
TMPDIR=$TMP; export TMPDIR
#node1 :ORACLE_SID=+ASM1 ; node2 : ORACLE_SID=+ASM2 : node3: ORACLE_SID=+ASM3
ORACLE_SID=+ASM1; export ORACLE_SID
ORACLE_BASE=/u01/app/grid/; export ORACLE_BASE
ORACLE_HOME=/u01/app/grid_home; 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
umask 022
7)oracle用户的 .bash_profile(Oracle SID根据后面自己安装的数据库名字做相应改动,sqlplus根据这个环境变量决定连接哪个数据库实例):
# .bash_profile
# Get the aliases and functions
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
# User specific environment and startup programs
PATH=$PATH:$HOME/bin
export PATH
TMP=/tmp; export TMP
TMPDIR=$TMP; export TMPDIR
ORACLE_BASE=/u01/app/oracle/; export ORACLE_BASE
ORACLE_HOME=/u01/app/oracle_home; export ORACLE_HOME
#node1:ORACLE_SID=racdb1 , node2:ORACLE_SID=racdb2 , node3:ORACLE_SID=racdb3
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
JAVA_HOME=/opt/jdk1.8.0_121; export JAVA_HOME
PATH=$JAVA_HOME/bin:$PATH; export PATH
umask 022
依次在三个host完成上面1)-7)的配置。
8)在三个节点上配置grid 用户和Oracle用户的无密码登陆,即三台host中从任何一台host上面用grid或者oracle用户都可以直接ssh到另外一台机器执行命令。以oracle和grid用户运行命令下面命令,以oracle用户为例,在test-5上面运行:
sed -i ‘s/UserKnownHostsFile \/dev\/null//g‘ /etc/ssh/ssh_config
sed -i ‘s/StrictHostKeyChecking no/StrictHostKeyChecking ask/g‘ /etc/ssh/ssh_config
ssh-keygen -N "" -f ~/.ssh/id_rsa
ssh-keygen -N "" -y -f ~/.ssh/id_rsa > ~/.ssh/id_rsa.pub
cat ~/.ssh/id_rsa.pub
把最后一步cat得到的公钥放到test-4,test-6的oracle用户~/.ssh/authorized_keys里面。在test-5上面运行:
ssh test-4 date
ssh test-6 date
去测试。在test-4和test-6上面执行同样的步骤,把公钥放到另外两台host对应的authorized_keys里面。
9)
mkdir -p /u01/app/grid
mkdir -p /u01/app/11.2.0/grid
mkdir -p /u01/app/oracle
chown -R oracle:oinstall /u01
chown -R grid:oinstall /u01/app/grid
chown -R grid:oinstall /u01/app/11.2.0
chmod -R 775 /u01
10)停止NTP服务
service ntpd stop
chkconfig ntpd off
rm -f /etc/ntp.conf
11)
以上是关于Oracle RAC集群安装的主要内容,如果未能解决你的问题,请参考以下文章
Linux系统Oracle 12cR2 RAC集群安装与维护管理(12.2)专题
安装ORACLE高可用RAC集群11g校验集群安装的可行性输出信息
安装 Oracle 11g RAC(空集群节点)时出现问题 INS-35423