作者介绍:老苏,10余年DBA工作运维经验,擅长Oracle、MySQL、PG、Mongodb数据库运维(如安装迁移,性能优化、故障应急处理等)
公众号:老苏畅谈运维
欢迎关注本人公众号,更多精彩与您分享。
对于RAC集群,需要更换服务器时,我们使用了ADG将数据迁移到其他设备后,一个经常需要的操作,就是将新RAC的IP(包含public ip、VIP、scan ip)改成原RAC相关的IP,这样应用连接数据的信息不变,对应用来说,不需要变动。以下是针对11g RAC 集群的更改IP详细步骤:
1、备份hosts文件
cp /etc/hosts /etc/hosts`date "+%F"`.bak
2、停止集群
–登录其中一台,关闭数据库
$ srvctl config database
ora11g
$ srvctl stop database -d ora11g
–在两台RAC主机上,使用root用户分别执行:
# /u01/app/11.2.0/grid/bin/crsctl stop crs -f
3、修改hosts文件
–原hosts:
# cat /etc/hosts
## RAC1 Public IP
10.10.10.50 rac11g01
## RAC2 Public IP
10.10.10.52 rac11g02
## RAC1 Virtual IP
10.10.10.51 rac11g01-vip
## RAC2 Virtual IP
10.10.10.53 rac11g02-vip
## RAC1 Private IP
10.10.20.50 rac11g01-priv
10.10.20.51 rac11g01-priv1
## RAC2 Private IP
10.10.20.52 rac11g02-priv
10.10.20.53 rac11g02-priv1
## SCAN IP
10.10.10.54 rac11g-scan
–修改后的hosts
修改hosts文件,原有的RAC相关全部注释掉,新增如下:
#########new-address##############
## RAC1 Public IP
10.10.10.55 rac11g01
## RAC2 Public IP
10.10.10.57 rac11g02
## RAC1 Virtual IP
10.10.10.56 rac11g01-vip
## RAC2 Virtual IP
10.10.10.58 rac11g02-vip
## RAC1 Private IP
10.10.20.50 rac11g01-priv
10.10.20.51 rac11g01-priv1
## RAC2 Private IP
10.10.20.52 rac11g02-priv
10.10.20.53 rac11g02-priv1
## SCAN IP
10.10.10.59 rac11g-scan
PS:注意两个节点都要修改!!!
4、修改两台机器的物理IP
修改如下:
10.10.10.50 --> 10.10.10.55
10.10.10.52 --> 10.10.10.57
# cat /etc/sysconfig/network-scripts/ifcfg-ens33
TYPE=Ethernet
NAME=ens33
DEVICE=ens33
ONBOOT=yes
#IPADDR=10.10.10.50
IPADDR=10.10.10.55
NETMASK=255.255.255.0
GATEWAY=10.10.10.2
# systemctl restart network &
# cat /etc/sysconfig/network-scripts/ifcfg-ens33
TYPE=Ethernet
NAME=ens33
DEVICE=ens33
ONBOOT=yes
#IPADDR=10.10.10.52
IPADDR=10.10.10.57
NETMASK=255.255.255.0
GATEWAY=10.10.10.2
# systemctl restart network &
5、启动集群
–分别在2个节点启动crs
# /u01/app/11.2.0/grid/bin/crsctl start crs
–启动之后检查,VIP己经自动更换
# /u01/app/11.2.0/grid/bin/srvctl config nodeapps -a
Network exists: 1/10.10.10.0/255.255.255.0/ens33, type static
VIP exists: /rac11g01-vip/10.10.10.56/10.10.10.0/255.255.255.0/ens33, hosting node rac11g01
VIP exists: /rac11g02-vip/10.10.10.58/10.10.10.0/255.255.255.0/ens33, hosting node rac11g02
–SCAN没有更换,还是原来的 10.10.10.54
# /u01/app/11.2.0/grid/bin/srvctl config scan
SCAN name: rac11g-scan, Network: 1/10.10.10.0/255.255.255.0/ens33
SCAN VIP name: scan1, IP: /rac11g-scan/10.10.10.54
6、修改scan ip
–关闭scan监听
# /u01/app/11.2.0/grid/bin/srvctl status scan_listener
SCAN Listener LISTENER_SCAN1 is enabled
SCAN listener LISTENER_SCAN1 is running on node rac11g02
# /u01/app/11.2.0/grid/bin/srvctl stop scan_listener
# /u01/app/11.2.0/grid/bin/srvctl stop scan
# /u01/app/11.2.0/grid/bin/srvctl status scan_listener
SCAN Listener LISTENER_SCAN1 is enabled
SCAN listener LISTENER_SCAN1 is not running
–更改scan配置
# /u01/app/11.2.0/grid/bin/srvctl modify scan -n 10.10.10.59
# /u01/app/11.2.0/grid/bin/srvctl config scan
SCAN name: 10.10.10.59, Network: 1/10.10.10.0/255.255.255.0/ens33
SCAN VIP name: scan1, IP: /10.10.10.59/10.10.10.59
–启动scan监听
# /u01/app/11.2.0/grid/bin/srvctl start scan_listener
# /u01/app/11.2.0/grid/bin/srvctl status scan_listener
SCAN Listener LISTENER_SCAN1 is enabled
SCAN listener LISTENER_SCAN1 is running on node rac11g02
–上面的监听跑在节点2上,如果想让它跑在节点1,执行如下命令:
[root@rac11g01:~]# /u01/app/11.2.0/grid/bin/srvctl relocate scan -i 1 -n rac11g01
[root@rac11g01:~]# /u01/app/11.2.0/grid/bin/srvctl status scan_listener
SCAN Listener LISTENER_SCAN1 is enabled
SCAN listener LISTENER_SCAN1 is running on node rac11g01
7、启动数据库
$ srvctl start database -d ora11g
$ sqlplus / as sysdba
SQL> select open_mode from gv$database;
OPEN_MODE
--------------------
READ WRITE
READ WRITE
8、检查local_listener
–去两个数据库实例里检查local_listener,我这里检查结果是正确的,写的都是新的VIP,如果不正确修改一下:
> show parameter local;
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
local_listener string (ADDRESS=(PROTOCOL=TCP)(HOST=
10.10.10.56)(PORT=1521))
log_archive_local_first boolean TRUE
parallel_force_local boolean FALSE
> show parameter local;
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
local_listener string (ADDRESS=(PROTOCOL=TCP)(HOST=
10.10.10.58)(PORT=1521))
log_archive_local_first boolean TRUE
parallel_force_local boolean FALSE
–如果要修改,如下:
alter system set local_listener='(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=10.10.10.56)(PORT=1521))))' scope=both sid='ora11g1';
alter system set local_listener='(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=10.10.10.58)(PORT=1521))))' scope=both sid='ora11g2';
–检查无误后,找主机连接一下VIP、SCAN分别进行测试,没问题,那么IP修改成功。
sqlplus system/oracleora@10.10.10.56/ora11g
sqlplus system/oracleora@10.10.10.58/ora11g
sqlplus system/oracleora@10.10.10.59/ora11g
9、修改 tnsnames.ora 文件
–修改这套RAC里的tnsnames.ora文件,两个节点都要改,本步骤略,根据实际情况进行更改
好了,需要了解更多数据库知识,欢迎关注我