Oracle RAC(Real Application Clusters)是一种高可用性和高性能的数据库解决方案,通过在多个节点上运行数据库实例来实现负载均衡和故障切换。以下是搭建Oracle RAC的详细步骤解析:
内核参数调整:
编辑/etc/sysctl.conf
文件,添加以下内容:
fs.aio-max-nr = 1048576
fs.file-max = 6815744
kernel.shmall = 2097152
kernel.shmmax = 4294967296
kernel.shmmni = 4096
kernel.sem = 250 32000 100 128
net.ipv4.ip_local_port_range = 9000 65500
net.core.rmem_default = 262144
net.core.wmem_default = 262144
net.core.rmem_max = 4194304
net.core.wmem_max = 1048576
执行sysctl -p
使配置生效。
用户和组创建:
创建oracle
用户和oinstall
、dba
组:
groupadd oinstall
groupadd dba
useradd -g oinstall -G dba oracle
passwd oracle
目录权限设置: 创建Oracle安装目录并设置权限:
mkdir -p /u01/app/oracle/product/19c/dbhome_1
chown -R oracle:oinstall /u01
chmod -R 775 /u01
/etc/hosts
文件,添加所有节点的公网IP、私网IP和VIP信息。例如:
192.168.1.10 node1.example.com node1
192.168.1.11 node2.example.com node2
192.168.1.12 node1-vip.example.com node1-vip
192.168.1.13 node2-vip.example.com node2-vip
192.168.2.10 node1-priv.example.com node1-priv
192.168.2.11 node2-priv.example.com node2-priv
将Oracle Grid Infrastructure安装包解压到指定目录:
unzip grid.zip
以oracle
用户身份运行安装程序:
./runInstaller
unzip database.zip
./runInstaller
使用crsctl
命令检查集群状态:
crsctl check cluster
登录到任意节点,使用sqlplus
连接数据库:
sqlplus / as sysdba
select instance_name, status from v$instance;
关闭一个节点的数据库实例,验证另一个节点是否接管服务。
asmcmd md_backup /backup/asm_metadata.bkp
GRID_HOME/bin/srvctl
管理服务。