更改 VIP 地址
步骤:
1. 确定用于支持 VIP 的接口:
$ ifconfig -a
2. 停止依赖 VIP 的所有资源:
$ srvctl stop instance -d DB -i DB1
$ srvctl stop asm -n node1
# srvctl stop nodeapps -n node1
3. 验证 VIP 不再处于运行状态:
$ ifconfig -a 或 $ crs_stat -t
4. 更改 /etc/hosts 中的 IP 和 DNS。
5. 使用 srvctl 修改 VIP 地址:
# srvctl modify nodeapps -n node1 -A 192.168.2.125/255.255.255.0/eth0
6. 启动 nodeapps 及依赖它的所有资源:
# srvctl start nodeapps -n node1
7. 对下一节点重复执行从步骤 1 开始的步骤。
示例:
RACDB1@rac1 /home/oracle$ crs_stat -t
Name Type Target State Host
------------------------------------------------------------
ora....B1.inst application ONLINE ONLINE rac1
ora....B2.inst application ONLINE ONLINE rac2
ora....DB1.srv application ONLINE ONLINE rac1
ora....DB2.srv application ONLINE ONLINE rac2
ora.....TAF.cs application ONLINE ONLINE rac1
ora.RACDB.db application ONLINE ONLINE rac1
ora....SM1.asm application ONLINE ONLINE rac1
ora....C1.lsnr application ONLINE ONLINE rac1
ora.rac1.gsd application ONLINE ONLINE rac1
ora.rac1.ons application ONLINE ONLINE rac1
ora.rac1.vip application ONLINE ONLINE rac1
ora....SM2.asm application ONLINE ONLINE rac2
ora....C2.lsnr application ONLINE ONLINE rac2
ora.rac2.gsd application ONLINE ONLINE rac2
ora.rac2.ons application ONLINE ONLINE rac2
ora.rac2.vip application ONLINE ONLINE rac2
--1. 确定用于支持 VIP 的接口
RACDB1@rac1 /home/oracle$ ifconfig -a
eth0 Link encap:Ethernet HWaddr 00:0C:29:2C:74:42
inet addr:192.168.1.101 Bcast:192.168.1.255 Mask:255.255.255.0
inet6 addr: fe80::20c:29ff:fe2c:7442/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:9033 errors:0 dropped:0 overruns:0 frame:0
TX packets:9590 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:1043771 (1019.3 KiB) TX bytes:1007598 (983.9 KiB)
Interrupt:185 Base address:0x1480
eth0:1 Link encap:Ethernet HWaddr 00:0C:29:2C:74:42
inet addr:192.168.1.201 Bcast:192.168.1.255 Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
Interrupt:185 Base address:0x1480 --rac1的vip信息
eth1 Link encap:Ethernet HWaddr 00:0C:29:2C:74:4C
inet addr:192.168.2.101 Bcast:192.168.2.255 Mask:255.255.255.0
inet6 addr: fe80::20c:29ff:fe2c:744c/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:93042 errors:0 dropped:0 overruns:0 frame:0
TX packets:141573 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:56393420 (53.7 MiB) TX bytes:125205647 (119.4 MiB)
Interrupt:193 Base address:0x1800
eth2 Link encap:Ethernet HWaddr 00:0C:29:2C:74:56
inet addr:192.168.246.128 Bcast:192.168.246.255 Mask:255.255.255.0
inet6 addr: fe80::20c:29ff:fe2c:7456/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:3887 errors:0 dropped:0 overruns:0 frame:0
TX packets:2442 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:359518 (351.0 KiB) TX bytes:353656 (345.3 KiB)
Interrupt:169 Base address:0x1880
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:35246 errors:0 dropped:0 overruns:0 frame:0
TX packets:35246 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:14195977 (13.5 MiB) TX bytes:14195977 (13.5 MiB)
sit0 Link encap:IPv6-in-IPv4
NOARP MTU:1480 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:0 (0.0 b) TX bytes:0 (0.0 b)
--2. 停止依赖 VIP 的所有资源
RACDB1@rac1 /home/oracle$ srvctl stop instance -d racdb -i racdb1
RACDB1@rac1 /home/oracle$ srvctl stop asm -n rac1
RACDB1@rac1 /home/oracle$ srvctl stop nodeapps -n rac1
--3. 验证 VIP 不再处于运行状态
RACDB1@rac1 /home/oracle$ crs_stat -t
Name Type Target State Host
------------------------------------------------------------
ora....B1.inst application OFFLINE OFFLINE
ora....B2.inst application ONLINE ONLINE rac2
ora....DB1.srv application ONLINE OFFLINE
ora....DB2.srv application ONLINE ONLINE rac2
ora.....TAF.cs application ONLINE ONLINE rac1
ora.RACDB.db application ONLINE ONLINE rac1
ora....SM1.asm application OFFLINE OFFLINE
ora....C1.lsnr application OFFLINE OFFLINE
ora.rac1.gsd application OFFLINE OFFLINE
ora.rac1.ons application OFFLINE OFFLINE
ora.rac1.vip application OFFLINE OFFLINE
ora....SM2.asm application ONLINE ONLINE rac2
ora....C2.lsnr application ONLINE ONLINE rac2
ora.rac2.gsd application ONLINE ONLINE rac2
ora.rac2.ons application ONLINE ONLINE rac2
ora.rac2.vip application ONLINE ONLINE rac2
RACDB1@rac1 /home/oracle$ ifconfig -a
eth0 Link encap:Ethernet HWaddr 00:0C:29:2C:74:42
inet addr:192.168.1.101 Bcast:192.168.1.255 Mask:255.255.255.0
inet6 addr: fe80::20c:29ff:fe2c:7442/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:10401 errors:0 dropped:0 overruns:0 frame:0
TX packets:10958 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:1190013 (1.1 MiB) TX bytes:1156506 (1.1 MiB)
Interrupt:185 Base address:0x1480
--没有了eth0:1,说明 VIP 不再处于运行状态
eth1 Link encap:Ethernet HWaddr 00:0C:29:2C:74:4C
inet addr:192.168.2.101 Bcast:192.168.2.255 Mask:255.255.255.0
inet6 addr: fe80::20c:29ff:fe2c:744c/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:96080 errors:0 dropped:0 overruns:0 frame:0
TX packets:144589 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:57752620 (55.0 MiB) TX bytes:126806811 (120.9 MiB)
Interrupt:193 Base address:0x1800
eth2 Link encap:Ethernet HWaddr 00:0C:29:2C:74:56
inet addr:192.168.246.128 Bcast:192.168.246.255 Mask:255.255.255.0
inet6 addr: fe80::20c:29ff:fe2c:7456/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:4214 errors:0 dropped:0 overruns:0 frame:0
TX packets:2685 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:389146 (380.0 KiB) TX bytes:383602 (374.6 KiB)
Interrupt:169 Base address:0x1880
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:37774 errors:0 dropped:0 overruns:0 frame:0
TX packets:37774 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:14921453 (14.2 MiB) TX bytes:14921453 (14.2 MiB)
sit0 Link encap:IPv6-in-IPv4
NOARP MTU:1480 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:0 (0.0 b) TX bytes:0 (0.0 b)
--4. 更改 /etc/hosts 中的 IP 和 DNS
RACDB1@rac1 /home/oracle$ more /etc/hosts
127.0.0.1 localhost.localdomain localhost
::1 localhost6.localdomain6 localhost6
##Public Network - (eth0)
##Private Interconnect - (eth1)
##Public Virtual IP (VIP) addresses - (eth0)
192.168.1.101 rac1
192.168.1.102 rac2
192.168.2.101 rac1-priv
192.168.2.102 rac2-priv
192.168.1.201 rac1-vip
192.168.1.202 rac2-vip
RACDB1@rac1 /home/oracle$ su - root
Password:
[root@rac1 ~]# vi /etc/hosts
[root@rac1 ~]# cat /etc/hosts
127.0.0.1 localhost.localdomain localhost
::1 localhost6.localdomain6 localhost6
##Public Network - (eth0)
##Private Interconnect - (eth1)
##Public Virtual IP (VIP) addresses - (eth0)
192.168.1.101 rac1
192.168.1.102 rac2
192.168.2.101 rac1-priv
192.168.2.102 rac2-priv
192.168.10.201 rac1-vip --新更改的vip
192.168.10.202 rac2-vip --新更改的vip
--5. 使用 srvctl 修改 VIP 地址 ,root用户操作
[root@rac1 ~]# srvctl modify nodeapps -n rac1 -A 192.168.10.201/255.255.255.0/eth0
--6. 启动 nodeapps 及依赖它的所有资源,并确认VIP的更改
[root@rac1 ~]# srvctl start nodeapps -n rac1
[root@rac1 ~]# srvctl start asm -n rac1
[root@rac1 ~]# srvctl start instance -d racdb -i racdb1
[root@rac1 ~]# crs_stat -t
Name Type Target State Host
------------------------------------------------------------
ora....B1.inst application ONLINE ONLINE rac1
ora....B2.inst application ONLINE ONLINE rac2
ora....DB1.srv application ONLINE ONLINE rac1
ora....DB2.srv application ONLINE ONLINE rac2
ora.....TAF.cs application ONLINE ONLINE rac1
ora.RACDB.db application ONLINE ONLINE rac1
ora....SM1.asm application ONLINE ONLINE rac1
ora....C1.lsnr application ONLINE ONLINE rac1
ora.rac1.gsd application ONLINE ONLINE rac1
ora.rac1.ons application ONLINE ONLINE rac1
ora.rac1.vip application ONLINE ONLINE rac1
ora....SM2.asm application ONLINE ONLINE rac2
ora....C2.lsnr application ONLINE ONLINE rac2
ora.rac2.gsd application ONLINE ONLINE rac2
ora.rac2.ons application ONLINE ONLINE rac2
ora.rac2.vip application ONLINE ONLINE rac2
[root@rac1 ~]# ifconfig -a
eth0 Link encap:Ethernet HWaddr 00:0C:29:2C:74:42
inet addr:192.168.1.101 Bcast:192.168.1.255 Mask:255.255.255.0
inet6 addr: fe80::20c:29ff:fe2c:7442/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:13376 errors:0 dropped:0 overruns:0 frame:0
TX packets:13887 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:1503831 (1.4 MiB) TX bytes:1470819 (1.4 MiB)
Interrupt:185 Base address:0x1480
eth0:1 Link encap:Ethernet HWaddr 00:0C:29:2C:74:42
inet addr:192.168.10.201 Bcast:192.168.10.255 Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
Interrupt:185 Base address:0x1480 --确认VIP已更改
eth1 Link encap:Ethernet HWaddr 00:0C:29:2C:74:4C
inet addr:192.168.2.101 Bcast:192.168.2.255 Mask:255.255.255.0
inet6 addr: fe80::20c:29ff:fe2c:744c/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:123430 errors:0 dropped:0 overruns:0 frame:0
TX packets:156239 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:83152785 (79.3 MiB) TX bytes:131127699 (125.0 MiB)
Interrupt:193 Base address:0x1800
eth2 Link encap:Ethernet HWaddr 00:0C:29:2C:74:56
inet addr:192.168.246.128 Bcast:192.168.246.255 Mask:255.255.255.0
inet6 addr: fe80::20c:29ff:fe2c:7456/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:4961 errors:0 dropped:0 overruns:0 frame:0
TX packets:3214 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:454337 (443.6 KiB) TX bytes:452528 (441.9 KiB)
Interrupt:169 Base address:0x1880
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:41946 errors:0 dropped:0 overruns:0 frame:0
TX packets:41946 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:17386653 (16.5 MiB) TX bytes:17386653 (16.5 MiB)
sit0 Link encap:IPv6-in-IPv4
NOARP MTU:1480 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:0 (0.0 b) TX bytes:0 (0.0 b)
--7. 对下一节点重复执行从步骤 1 开始的步骤。
注:
调整RAC环境中各节点VIP及虚拟主机名的步骤相对比较简单。但有一些需要重点注意的地方:
1)如果listener.ora、tnsnames.ora和初始化参数文件中使用的是VIP的地址而不是虚拟主机的名字,需要将其内容调整为新的VIP地址;
2)如果在调整VIP地址过程中同时修改了虚拟主机的名字,注意需要同时修改listener.ora、tnsnames.ora和初始化参数文件;
3)需要调整客户端tnsnames.ora文件中有关VIP的配置信息。
参考:
调整RAC虚拟IP地址(VIP)及虚拟主机名
http://space.itpub.net/519536/viewspace-678332
Administering System and Network Interfaces with OIFCFG
http://docs.oracle.com/cd/B19306_01/rac.102/b14197/adminopt.htm#RACAD922