在CentOS系统上搭建RAC(Real Application Clusters)集群是一个复杂但非常强大的过程,它能够提供高可用性和负载均衡,本文将详细介绍如何在CentOS7.6上搭建一个两个节点的RAC集群。
一、系统环境配置
1.
本次搭建的是两个节点的RAC集群,每个节点均有两个网卡:public网卡和private网卡,两个节点的主机名分别为rac1和rac2。
2. 参数设置(RAC1&RAC2)
编辑/etc/hosts文件:
vim /etc/hosts
注释掉以下内容:
#127.0.0.1 localhost rac1 localhost4 localhost4.localdomain4 #::1 localhost rac1 localhost6 localhost6.localdomain6
追加以下内容:
# RACPUBLICIP 192.168.100.101 rac1 192.168.100.102 rac2 # RACPRIVATEIP 10.10.10.101 rac1priv 10.10.10.102 rac2priv # RACVIP 192.168.100.201 rac1vip 192.168.100.202 rac2vip # RACSCANIP 192.168.100.200 racscan
3. 关闭防火墙
关闭防火墙服务并禁用SELinux:
systemctl disable firewalld.service vi /etc/selinux/config
将enforcing
更改为disabled
:
SELINUX=disabled
挂载系统光盘并配置本地yum源:
mkdir /yums cd /run/media/root/CentOS\ 7\ x86_64/Packages cp * /yums rpm ivh deltarpm3.63.el7.x86_64.rpm rpm ivh pythondeltarpm3.63.el7.x86_64.rpm rpm ivh createrepo0.9.928.el7.noarch.rpm cd /yums createrepo . vi /etc/yum.repos.d/yum.local.repo [local] name=yum local repo baseurl=file:///yums gpgcheck=0 enable=1
安装依赖包:
yum install y bc compatlibcap1* compatlibcap* binutils compatlibstdc++33 elfutilslibelf elfutilslibelfdevel gcc gccc++ glibc2.5 glibccommon glibcdevel glibcheaders ksh libaio libaiodevel libgcc libstdc++ libstdc++devel make sysstat unixODBC unixODBCdevel
手动上传并安装其他依赖包:
rpm ivh cvuqdisk1.0.101.rpm rpm ivh rlwrap0.371.el6.x86_64.rpm yum install y compatlibstdc++333.2.372.el7.x86_64.rpm kmod2021.el7.x86_64.rpm kmodlibs2021.el7.x86_64.rpm
关闭透明大页:
cp /etc/default/grub /etc/default/grub.bak vi /etc/default/grub GRUB_CMDLINE_LINUX="rd.lvm.lv=centos/root rd.lvm.lv=centos/swap rhgb quiet transparent_hugepage=never"
更新GRUB配置:
grub2mkconfig o /boot/grub2/grub.cfg
重启系统使配置生效:
reboot
二、操作系统配置
1. 准备OS
确保操作系统版本和内核一致,建议使用CentOS 7.8。
2. 添加网卡
为每个节点添加两块网卡:public网卡和private网卡,并配置相应的IP地址。
3. 修改主机名
编辑/etc/hostname文件,设置主机名为rac1和rac2:
vim /etc/hostname rac1
应用主机名更改:
hostnamectl sethostname rac1 static
对rac2节点重复上述步骤。
4. 配置静态IP地址
编辑网卡配置文件(如ifcfgens33),设置静态IP地址:
vim /etc/sysconfig/networkscripts/ifcfgens33 TYPE=Ethernet BOOTPROTO=none NAME=eth0 DEVICE=eth0 ONBOOT=yes IPADDR=192.168.100.101 NETMASK=255.255.255.0 GATEWAY=192.168.100.1
对private网卡和VIP网卡进行类似配置。
5. 关闭防火墙和禁用SELinux
systemctl stop firewalld.service systemctl disable firewalld.service vi /etc/selinux/config SELINUX=disabled
6. 修改/etc/hosts文件
编辑/etc/hosts文件,添加节点信息:
vim /etc/hosts 192、168.100.101 rac1 192、168.100.102 rac2 192、168.100.201 rac1vip 192、168.100.202 rac2vip
7. 添加组和用户
创建grid和oracle用户:
groupadd oinstall groupadd dba useradd g oinstall G dba grid useradd g dba oracle passwd grid passwd oracle
8. 创建安装目录并挂载/u01目录
mkdir p /u01/app/oraInventory mkdir p /u01/app/grid01/product/21000/dbhome_1 chown R grid:oinstall /u01/app/oraInventory chown R oracle:oinstall /u01/app/grid01/product/21000/dbhome_1 mount o bind /tmp /u01/app/oraInventory/tmp mount o bind /tmp /u01/app/grid01/product/21000/dbhome_1/tmp
9. 配置grid和oracle用户的环境变量文件
编辑~grid/.bash_profile和~oracle/.bash_profile文件,添加以下内容:
export ORACLE_BASE=/u01/app/oracle export ORACLE_HOME=$ORACLE_BASE/product/21000/dbhome_1 export ORACLE_SID=orcl export PATH=$PATH:$ORACLE_HOME/bin export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib:$LD_LIBRARY_PATH export CLASSPATH=$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib:$ORACLE_HOME/network/jlib:$CLASSPATH
10. 配置root用户的环境变量
编辑/etc/profile文件,添加以下内容:
export ORACLE_BASE=/u01/app/oracle export ORACLE_HOME=$ORACLE_BASE/product/21000/dbhome_1 export ORACLE_SID=orcl export PATH=$PATH:$ORACLE_HOME/bin export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib:$LD_LIBRARY_PATH export CLASSPATH=$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib:$ORACLE_HOME/network/jlib:$CLASSPATH
使环境变量生效:
source /etc/profile
11. 安装软件依赖包
yum install y binutils compatlibstdc++33 glibc glibcdevel ksh libaio libgcc libstdc++ libstdc++devel libXcb libXau libXi libXtst libXrender libXrenderdevel make nettools nfsutils smartmontools sysstat e2fsprogs e2fsprogslibs fontconfigdevel expect opensshclients readline psmisc unzip wget curl tar gzip less which lsof procp telnet rsync openssl kmod2021.el7.x86_64 kmodlibs2021.el7.x86_64
12. 配置内核参数
编辑/etc/sysctl.conf文件,添加以下内容:
fs.filemax = 6815744 kernel.sem = 250 32000 100 128 kernel.shmall = 2097152 kernel.shmmax = 536870912 kernel.shmmni = 4096 kernel.shmall = 524288 kernel.shmmax = 4398046544324 kernel.panic_on_oops = 1 kernel.msgmnb = 65536 kernel.msgmax = 65536 kernel.shm_rmid_forced = 0 kernel.shmmni = 4096 vm.swappiness = 10 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 = 1048576 fs.aiomaxnr = 1048576 fs.filemax = 6815744 vm.overcommit_memory = 5 vm.overcommit_ratio = 50 kernel.threadsmax = 327680 kernel.pid_max = 327680 kernel.stack_size_max = 51200 ksoftirqd/3600 100000 1500000 1500000 300 mlockall vfs license splice lrwx md5 sha512 flock brkint nptl devpts vserver fsnotify delegate portmap aio_debug infiniband_debug iparmmid ipcrm mid ipcrm_hold ipcrm_lock ipcrm_owner ipcrm_session ipcrm_timeout ipcrm_mode ipcrm_usage ipcrm_all ipcrm_by_uid ipcrm_by_module ipcrm_by_task ipcrm_by_stack ipcrm_by_user ipcrm_by_key ipcrm_by_pattern ipcrm_by_share ipcrm_by_exclusive ipcrm_by_proxied ipcrm_by_ns ipcrm_by_pid ipcrm_by_proctitle ipcrm_by_cmd ipcrm_by_uid ipcrm_by_module ipcrm_by_task ipcrm_by_stack ipcrm_by_user ipcrm_by_key ipcrm_by_pattern ipcrm_by_share ipcrm_by_exclusive ipcrm_by_proxied ipcrm_by_ns ipcrm_by_pid ipcrm_by_proctitle ipcrm_by_cmd ipcrm_by_uid ipcrm_by_module ipcrm_by_task ipcrm_by_stack ipcrm_by_user ipcrm_by_key ipcrm_by_pattern ipcrm_by_share ipcrm_by_exclusive ipcrm_by_proxied ipcrm_by_ns ipcrm_by_pid ipcrm_by_proctitle ipcrm_by_cmd ipcrm_by_uid ipcrm_by_module ipcrm_by_task ipcrm_by_stack ipcrm_by_user ipcrm_by_key ipcrm_by_pattern ipcrm_by_share ipcrm_by_exclusive ipcrm_by_proxied ipcrm_by_ns ipcrm_by_pid ipcrm_by_proctitle ipcrm_by_cmd ipcrm_by_uid ipcrm_by_module ipcrm_by_task ipcrm_by_stack ipcrm_by_user ipcrm_by_key ipcrm_by_pattern ipcrm_by_share ipcrm_by_exclusive ipcrm_by_proxied ipcrm_by_ns ipcrm_by_pid ipcrm_by_proctitle ipcrm_by_cmd ipcrm_by_uid ipcrm_by_module ipcrm_by_task ipcrm_by_stack ipcrm_by_user ipcrm_by_key ipcrm_by_pattern ipcrm_by_share ipcrm_by_exclusive ipcrm_by_proxied ipcrm_by_ns ipcrm_by_pid ipcrm_by_proctitle ipcrm_by_cmd ipcrm_by_uid ipcrm_by_module ipcrm_by_task ipcrm_by_stack ipcrm_by_user ipcrm_by_key ipcrm_by_pattern ipcrm_by_share ipcrm_by_exclusive ipcrm_by_proxied ipcrm_by_ns ipcrm_by_pid ipcrm_by_proctitle ipcrm_by_cmd ipcrm_by_uid ipcrm_by_module ipcrm_by_task ipcrm_by_stack ipcrm_by_user ipcrm_by key pattern share exclusive proxied ns pid proctitle cmd uid module task stack user key pattern share exclusive proxied ns pid proctitle cmd uid module task stack user key pattern share exclusive proxied ns pid proctitle cmd uid module task stack user key pattern share exclusive proxied ns pid proctitle cmd uid module task stack user key pattern share exclusive proxied ns pid proctitle cmd uid module task stack user key pattern share exclusive proxied ns pid proctitle cmd uid module task stack user key pattern share exclusive proxied ns pid proctitle cmd uid module task stack user key pattern share exclusive proxied ns pid proctitle cmd uid module task stack user key pattern share exclusive proxied ns pid proctitle cmd uid module task stack user key pattern share exclusive proxied ns pid proctitle cmd uid module task stack user key pattern share exclusive proxied ns pid proctitle cmd uid module task stack user key pattern share exclusive proxied ns pid proctitle cmd uid module task stack user key pattern share exclusive proxied ns pid proctitle cmd uid module task stack user key pattern share exclusive proxied ns pid proctitle cmd uid module task stack user key pattern share exclusive proxied ns pid proctitle cmd uid module task stack user key pattern share exclusive proxied ns pid proctitle cmd uid module task stack user key pattern share exclusive proxied ns pid proctitle cmd uid module task stack user key pattern share exclusive proxied ns pid proctitle cmd uid module task stack user key pattern share exclusive proxied ns pid proctitle cmd uid module task stack user key pattern share exclusive proxied ns pid proctitle cmd uid module task stack user key pattern share exclusive proxied ns pid