Oracle 12c RAC 配置
一、系统版本
操作系统版本:
[root@db1 ~]# cat /etc/redhat-release
CentOS Linux release 7.7.1908 (Core)
数据库版本:
grid :12.2.0.1
oracle:12.2.0.1
二、规划
服务器主机名 | db1 | db2 |
公共IP地址 | 10.1.1.10 | 10.1.1.20 |
虚拟IP地址 | 10.1.1.11 | 10.1.1.21 |
私有IP地址 | 192.168.100.10 | 192.168.100.20 |
ORACLE RAC SID | orcl1 | orcl2 |
集群实例名称 | orcl | |
SCAN IP | 10.1.1.100 | |
操作系统 | CentOS Linux release 7.7.1908 (Core) | |
Oracle 版本 | Oracle 12.2.0.1 for linux |
三、安装前的准备
1、设置主机名称
2、关闭主机selinux,防火墙(db1,db2)
[root@db1 ~]# vi /etc/selinux/config
关闭防火墙
3、设置/etc/hosts
db1:
db2:
4、关闭透明大页内存HugePage(db1,db2)
cd /etc/default/
cp grub grub.bak
vi grub
将GRUB_CMDLINE_LINUX="crashkernel=auto spectre_v2=retpoline rhgb quiet" 修改为
GRUB_CMDLINE_LINUX="rhgb quiet transparent_hugepage=never"
grub2-mkconfig -o /boot/grub2/grub.cfg
reboot重启操作系统
检查生效:
[root@db1 ~]# grep AnonHugePages /proc/meminfo
AnonHugePages: 0 kB
5、禁用chronyd
在RHEL7.0之前使用的是ntp服务协议,来同步服务器的时间,分为服务端和客户端;
在RHEL7.0之后采用的chronyd服务来同步时间;
在 rac的环境下需要关闭chronyd服务:(db1,db2)
6、关闭avahi-deamon服务(db1,db2)
avahi-deamon可能带来网络问题和bug,尤其是对rac系统,oracle建议关闭
7、关闭linux 7的virbr0网卡服务192.168.122.1,重启后生效
systemctl stop libvirtd.service
systemctl stop libstoragemgmt.service
systemctl disable libstoragemgmt.service
systemctl disable libvirtd.service
8、配置NOZEROCONF(防止出现自动配置 IPv4 地址: 169.254.51.177这样的地址)
vi /etc/sysconfig/network增加以下内容
NOZEROCONF=yes
也可以直接执行如下语法完成修改:
echo "NOZEROCONF=yes" >>/etc/sysconfig/network
9、创建用户和用户组并设置oracle,grid用户密码;
/usr/sbin/groupadd -g 54321 oinstall
/usr/sbin/groupadd -g 54322 dba
/usr/sbin/groupadd -g 54323 oper
/usr/sbin/groupadd -g 54324 backupdba
/usr/sbin/groupadd -g 54325 dgdba
/usr/sbin/groupadd -g 54326 kmdba
/usr/sbin/groupadd -g 54327 asmdba
/usr/sbin/groupadd -g 54328 asmoper
/usr/sbin/groupadd -g 54329 asmadmin
/usr/sbin/groupadd -g 54330 racdba
/usr/sbin/useradd -u 54321 -g oinstall -G dba,asmdba,oper oracle
/usr/sbin/useradd -u 54322 -g oinstall -G dba,oper,backupdba,dgdba,kmdba,asmdba,asmoper,asmadmin,racdba grid
echo "oracle" | passwd --stdin oracle
echo "grid" | passwd --stdin grid
10、创建安装目录,赋予权限
mkdir -p /u01/app/12.2.0/grid
mkdir -p /u01/app/grid
mkdir -p /u01/app/oracle/product/12.2.0/db_1
mkdir -p /u01/app/oraInventory
chown -R grid.oinstall /u01/app/oraInventory/
chown -R grid:oinstall /u01
chown -R oracle:oinstall /u01/app/oracle
chmod -R 775 /u01/
四、设置ASM磁盘(VM下添加磁盘)
序号 | 磁盘名称 | 容量 | 数量 | 描述 |
1 | OCR | 5G | 3 | Voting节点配置信息,Ocr集群配置等信息 |
2 | DATA | 50G | 1 | 存放oracle数据库三大文件 |
3 | Mgmt | 40G | 1 | 存放管理文件 |
4 | FLA | 30G | 1 | 存放归档日志 |
vmware workstation rac配置共享vmx文件添加如下,才能获取磁盘的uuid;
disk.EnableUUID ="TRUE"
disk.locking = "FALSE"
diskLib.dataCacheMaxSize = "0"
diskLib.dataCacheMaxReadAheadSize = "0"
diskLib.dataCacheMinReadAheadSize = "0"
diskLib.dataCachePageSize = "4096"
diskLib.maxUnsyncedWrites = "0"
将磁盘分区,并获取uuid:
[root@db1 ~]# /usr/lib/udev/scsi_id -g /dev/sda5
36000c29e1d6463ee388717d93e3791b5
[root@db1 ~]# /usr/lib/udev/scsi_id -g /dev/sdb5
36000c29aad7d3b33ffa17d0c70f25760
[root@db1 ~]# /usr/lib/udev/scsi_id -g /dev/sdc5
36000c299b3371b0192e1ccb95df2a92f
[root@db1 ~]# /usr/lib/udev/scsi_id -g /dev/sdd5
36000c298beca070ef5735f7641929d43
[root@db1 ~]# /usr/lib/udev/scsi_id -g /dev/sde5
36000c2903075def28b935dc113c99787
[root@db1 ~]# /usr/lib/udev/scsi_id -g /dev/sdf5
36000c29ae570a3606d83b44fc2cca8df
编辑保存:99-oracle-asmdevices.rules
KERNEL=="sd*", ENV{DEVTYPE}=="disk", SUBSYSTEM=="block", PROGRAM=="/usr/lib/udev/scsi_id -g -u -d $devnode", RESULT=="36000c29e1d6463ee388717d93e3791b5", RUN+="/bin/sh -c 'mknod /dev/asmdiska b $major $minor; chown grid:asmadmin /dev/asmdiska; chmod 0660 /dev/asmdiska'"
KERNEL=="sd*", ENV{DEVTYPE}=="disk", SUBSYSTEM=="block", PROGRAM=="/usr/lib/udev/scsi_id -g -u -d $devnode", RESULT=="36000c29aad7d3b33ffa17d0c70f25760", RUN+="/bin/sh -c 'mknod /dev/asmdiskb b $major $minor; chown grid:asmadmin /dev/asmdiskb; chmod 0660 /dev/asmdiskb'"
KERNEL=="sd*", ENV{DEVTYPE}=="disk", SUBSYSTEM=="block", PROGRAM=="/usr/lib/udev/scsi_id -g -u -d $devnode", RESULT=="36000c299b3371b0192e1ccb95df2a92f", RUN+="/bin/sh -c 'mknod /dev/asmdiskc b $major $minor; chown grid:asmadmin /dev/asmdiskc; chmod 0660 /dev/asmdiskc'"
KERNEL=="sd*", ENV{DEVTYPE}=="disk", SUBSYSTEM=="block", PROGRAM=="/usr/lib/udev/scsi_id -g -u -d $devnode", RESULT=="36000c298beca070ef5735f7641929d43", RUN+="/bin/sh -c 'mknod /dev/asmdiskd b $major $minor; chown grid:asmadmin /dev/asmdiskd; chmod 0660 /dev/asmdiskd'"
KERNEL=="sd*", ENV{DEVTYPE}=="disk", SUBSYSTEM=="block", PROGRAM=="/usr/lib/udev/scsi_id -g -u -d $devnode", RESULT=="36000c2903075def28b935dc113c99787", RUN+="/bin/sh -c 'mknod /dev/asmdiske b $major $minor; chown grid:asmadmin /dev/asmdiske; chmod 0660 /dev/asmdiske'"
KERNEL=="sd*", ENV{DEVTYPE}=="disk", SUBSYSTEM=="block", PROGRAM=="/usr/lib/udev/scsi_id -g -u -d $devnode", RESULT=="36000c29ae570a3606d83b44fc2cca8df", RUN+="/bin/sh -c 'mknod /dev/asmdiskf b $major $minor; chown grid:asmadmin /dev/asmdiskf; chmod 0660 /dev/asmdiskf'"0660 /dev/asmdiskf'"
重启UDEV:
systemctl restart systemd-udevd.service
udevadm control --reload-rules
/sbin/udevadm trigger --type=devices --action=add
/sbin/udevadm trigger --type=devices --action=change
结果如图所示:
五、设置内核参数、session限制、环境变量、修改资源限制
[root@db1 ~]# cat /home/oracle/.bash_profile (oracle环境变量)
# .bash_profile
# Get the aliases and functions
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
# User specific environment and startup programs
PATH=$PATH:$HOME/.local/bin:$HOME/bin
export PATH
ORACLE_SID=orcl1;export ORACLE_SID
ORACLE_UNQNAME=orcl;export ORACLE_UNQNAME
JAVA_HOME=/usr/local/java; export JAVA_HOME
ORACLE_BASE=/u01/app/oracle; export ORACLE_BASE
ORACLE_HOME=$ORACLE_BASE/product/12.2.0/db_1; export ORACLE_HOME
ORACLE_TERM=xterm; export ORACLE_TERM
NLS_DATE_FORMAT="YYYY:MM:DDHH24:MI:SS"; export NLS_DATE_FORMAT
NLS_LANG=american_america.ZHS16GBK; export NLS_LANG
TNS_ADMIN=$ORACLE_HOME/network/admin; export TNS_ADMIN
ORA_NLS11=$ORACLE_HOME/nls/data; export ORA_NLS11
PATH=.:${JAVA_HOME}/bin:${PATH}:$HOME/bin:$ORACLE_HOME/bin:$ORA_CRS_HOME/bin
PATH=${PATH}:/usr/bin:/bin:/usr/bin/X11:/usr/local/bin
export PATH
LD_LIBRARY_PATH=$ORACLE_HOME/lib
LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:$ORACLE_HOME/oracm/lib
LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:/lib:/usr/lib:/usr/local/lib
export LD_LIBRARY_PATH
CLASSPATH=$ORACLE_HOME/JRE
CLASSPATH=${CLASSPATH}:$ORACLE_HOME/jlibCLASSPATH=${CLASSPATH}:$ORACLE_HOME/rdbms/jlib
CLASSPATH=${CLASSPATH}:$ORACLE_HOME/network/jlib
export CLASSPATH
THREADS_FLAG=native; export THREADS_FLAG
export TEMP=/tmp
export TMPDIR=/tmp
umask 022
[root@db1 ~]# cat /home/grid/.bash_profile (设置grid环境变量)
# .bash_profile
# Get the aliases and functions
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
# User specific environment and startup programs
PATH=$PATH:$HOME/.local/bin:$HOME/bin
export PATH
PATH=$PATH:$HOME/bin
export ORACLE_SID=+ASM1
export ORACLE_BASE=/u01/app/grid
export ORACLE_HOME=/u01/app/12.2.0/grid
export PATH=$ORACLE_HOME/bin:$PATH:/usr/local/bin/:.
export TEMP=/tmp
export TMP=/tmp
export TMPDIR=/tmp
umask 022
export PATH
设置shmfs空间大小
vi /etc/fstab
shmfs /dev/shm tmpfs defaults,size=8g 0 0
使生效: mount -a
修改资源限制:
cat >> /etc/security/limits.conf <<EOF
grid soft nproc 2047
grid hard nproc 16384
grid soft nofile 1024
grid hard nofile 65536
grid soft stack 10240
grid hard stack 32768
oracle soft nproc 2047
oracle hard nproc 16384
oracle soft nofile 1024
oracle hard nofile 65536
oracle soft stack 10240
oracle hard stack 32768
oracle soft memlock 3145728
oracle hard memlock 3145728
EOF
确保加载了最新版本的 PAM,然后在 /etc/pam.d/login 文件中添加或编辑以下行:
cat >> /etc/pam.d/login <<EOF
session required pam_limits.so
EOF
修改内核参数:
cat >> /etc/sysctl.conf <<EOF
fs.file-max = 6815744
kernel.sem = 250 32000 100 128
kernel.shmmni = 4096
kernel.shmall = 1073741824
kernel.shmmax = 4398046511104
kernel.panic_on_oops = 1
net.core.rmem_default = 262144
net.core.rmem_max = 4194304
net.core.wmem_default = 262144
net.core.wmem_max = 1048576
net.ipv4.conf.all.rp_filter = 2
net.ipv4.conf.default.rp_filter = 2
fs.aio-max-nr = 1048576
net.ipv4.ip_local_port_range = 9000 65500
六、安装rac集群所需要的rpm包
yum install binutils compat-libstdc++-33 gcc gcc-c++ glibc glibc.i686 glibc-devel ksh libgcc.i686 libstdc++-devel libaio libaio.i686 libaio-devel libaio-devel.i686 libXext libXext.i686 libXtst libXtst.i686 libX11 libX11.i686 libXau libXau.i686 libxcb libxcb.i686 libXi libXi.i686 make sysstat unixODBC unixODBC-devel zlib-devel zlib-devel.i686 compat-libcap1 -y
(配置本地yum或者网络yum来安装相关包)
七、上传文件到/home/software目录(grid,db软件)
mkdir /home/software
将grid压缩包解压到目录-d /u01/app/12.2.0/grid
从Oracle 12cR2开始,软件直接解压缩到GRID_HOME 或者ORACLE_HOME,而不是在安装时复制过去。 该操作只需要在节点1上完成解压缩即可。
我们这里是安装GRID,用grid用户来解压缩GI:
[root@db1 software]# unzip -d /u01/app/12.2.0/grid linuxx64_12201_grid_home.zip
在每个节点安装cvu软件 rpm包
cd /u01/app/12.2.0/grid/cv/rpm
rpm -ivh cvuqdisk-1.0.10-1.rpm
[root@db1 rpm]# rpm -ivh cvuqdisk-1.0.10-1.rpm
Preparing... ################################# [100%]
Using default group oinstall to install package
Updating / installing...
1:cvuqdisk-1.0.10-1 ################################# [100%]
注意:节点db2将db1 cvu拷贝过去安装;
在节点一配置ssh互信,步骤如下:
--使用root将数据库软件拷贝至/home/oracle/下:
# chown oracle.oinstall linuxx64_12201_database.zip
# su - oracle
$ unzip linuxx64_12201_database.zip
$ cd database/sshsetup/
$ ./sshUserSetup.sh -user oracle -hosts "db1 db2" -advanced -noPromptPassphrase
$ ./sshUserSetup.sh -user grid -hosts "db1 db2" -advanced -noPromptPassphrase
--最后在db1使用oracle和grid用户都执行以下两条命令验证互信:
$ ssh db2 date
$ ssh db2-priv date
db2上使用oracle和grid用户执行下面命令验证互信:
$ ssh db1 date
$ ssh db1-priv date
八、开始安装grid组件
安装前执行安装rac前两节点安装检测脚本(runcluvfy.sh )
[oracle@db1 grid]$ pwd
/u01/app/12.2.0/grid
./runcluvfy.sh stage -pre crsinst -n db1,db2 -verbose >>/home/grid/check.txt
查看结果:
直到没有安装前检测没有失败为止;
使用grid用户登录图形系统,开始安装grid集群基础设施
用ASMCA创建磁盘组 创建DATA用于存放三大数据文件(控制文件,redo日志文件,数据文件)
创建FLA用于存放归档日志文件
九、开始安装oracle数据库软件和建CDB库和pdb01库
十、检查rac库状态
十一、客户端连接测试