生产系统中修改IP或者VIP是比较少有,但是也不是没有发生过,之前在维护移动系统的时候就有一次需要修改主机的IP和VIP,在生产环境中操作之前在虚拟机上做了一个测试,记录一下。
1、两边节点停止数据库,监听,asm,gsd,vip,ons服务
oracle用户
srvctl stop database -d devdb -o immediate
srvctl stop asm -n ty11r1a
srvctl stop asm -n ty11r1b
srvctl stop nodeapps -n ty11r1a
srvctl stop nodeapps -n ty11r1b
root
./crsctl stop crs
2、 修改hosts 文件(所有节点):
[root@ty11r1a etc]# vi hosts
192.168.189.161 ty11r1a
192.168.189.162 ty11r1b
#priv
10.10.30.61 ty11r1a-priv
10.10.30.62 ty11r1b-priv
#vip
192.168.189.61 ty11r1a-vip
192.168.189.62 ty11r1b-vip
3、修改所有节点的eth0 eth1 IP地址。
[root@ty11r1a etc]# vi /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=eth0
BOOTPROTO=static
BROADCAST=192.168.189.255
HWADDR=00:0C:29:F0:95:B3
IPADDR=192.168.189.161
NETMASK=255.255.255.0
NETWORK=192.168.189.0
ONBOOT=yes
TYPE=Ethernet
[root@ty11r1a etc]# vi /etc/sysconfig/network-scripts/ifcfg-eth1
DEVICE=eth1
BOOTPROTO=static
BROADCAST=10.10.30.255
HWADDR=00:0C:29:F0:95:BD
IPADDR=10.10.30.61
NETMASK=255.255.255.0
NETWORK=10.10.30.0
ONBOOT=yes
TYPE=Ethernet
4、 修改gateway
[root@ty11r1a etc]# vi /etc/sysconfig/network
NETWORKING=yes
HOSTNAME=ty11r1a
GATEWAY=192.168.189.1
5、重新启动network服务:
[root@ty11r1a etc]# services network restart
[root@ty11r1b etc]# services network restart
6、启动crs.
[root@ty11r1a ~]# /u01/app/oracle/product/11.1.0/crs_1/bin/crsctl start crs
Attempting to start CRS stack
The CRS stack will be started shortly
7、用oifcfg命令修改ip更新ocr盘
ty11r1a-> oifcfg getif --先查看ocr的 ip . 可以看到现在还是原先的192.168.1段地址,
eth0 192.168.1.0 global public
eth1 10.10.10.0 global cluster_interconnect
windows 系统使用下列命令可以查看现在各节点的有效网络接口名。
oifcfg iflist
删除eth0 的ip
ty11r1a-> oifcfg delif -global eth0
重新设置eth0 的ip的网段
ty11r1a-> oifcfg setif -global eth0/192.168.189.1:public
ty11r1a-> oifcfg setif -global eth1/10.10.30.0:cluster_interconnect
再次查看ocr的ip ,可以看到public 和 private 的ip都已经修改了。
ty11r1a-> oifcfg getif
eth0 192.168.189.1 global public
eth1 10.10.30.0 global cluster_interconnect
8、在节点2上启动crs服务,确认crs 的ip.
[root@ty11r1b ~]# /u01/app/oracle/product/11.1.0/crs_1/bin/crsctl start crs
Attempting to start CRS stack
The CRS stack will be started shortly
[root@ty11r1b ~]# su - oracle
ty11r1b-> oifcfg getif --可以看到ip 段已经修改了。
eth0 192.168.189.1 global public
eth1 10.10.30.0 global cluster_interconnect
9、查看虚拟ip,好像已经自动修改,(到这里还未修改过来,需要修改为eth0 的)
<1>查看虚拟ip
ty11r1a-> srvctl config nodeapps -n ty11r1a -a
VIP exists.: /ty11r1a-vip/192.168.189.61/255.255.255.0/eth0:eth1
ty11r1a-> srvctl config nodeapps -n ty11r1b -a
VIP exists.: /ty11r1b-vip/192.168.189.62/255.255.255.0/eth0:eth1
<2>如果没有修改,使用下面的命令。
用srvctl modify nodeapps 修改vip地址
oracle用户:
ty11r1a-> srvctl modify nodeapps -n ty11r1a -A 192.168.189.61/255.255.255.0/eth0
PRKO-2117 : This command should be executed as the system privilege user.
ty11r1a-> exit
<3>使用root用户修改
[root@ty11r1a ~]# cd /u01/app/oracle/product/11.1.0/crs_1/bin/
[root@ty11r1a bin]# ./srvctl modify nodeapps -n ty11r1a -A 192.168.189.61/255.255.255.0/eth0
<4>再查看vip的地址,注意后面只有1个eth0 了
[root@ty11r1a bin]# ./srvctl config nodeapps -n ty11r1a -a
VIP exists.: /ty11r1a-vip/192.168.189.61/255.255.255.0/eth0
[root@ty11r1a bin]#
<5>节点2修改
ty11r1b-> exit
[root@ty11r1b ~]# cd /u01/app/oracle/product/11.1.0/crs_1/bin/
[root@ty11r1b bin]# ./srvctl modify nodeapps -n ty11r1b -A 192.168.189.62/255.255.255.0/eth0
<6>查看vip ,
[root@ty11r1b bin]# ./srvctl config nodeapps -n ty11r1b -a
VIP exists.: /ty11r1b-vip/192.168.189.62/255.255.255.0/eth0
对于windows 的rac 修改vip信息后,要关闭并重新启动服务里的oraSID服务才可以。
10、启动nodeapps 前的ip信息,可以看到是没有vip信息的
[root@ty11r1a bin]# ifconfig
eth0 Link encap:Ethernet HWaddr 00:0C:29:F0:95:B3
inet addr:192.168.189.161 Bcast:192.168.189.255 Mask:255.255.255.0
inet6 addr: fe80::20c:29ff:fef0:95b3/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:45265 errors:0 dropped:0 overruns:0 frame:0
TX packets:2841 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:25106204 (23.9 MiB) TX bytes:357927 (349.5 KiB)
eth1 Link encap:Ethernet HWaddr 00:0C:29:F0:95:BD
inet addr:10.10.30.61 Bcast:10.10.30.255 Mask:255.255.255.0
inet6 addr: fe80::20c:29ff:fef0:95bd/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:5013 errors:0 dropped:0 overruns:0 frame:0
TX packets:66977 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:446170 (435.7 KiB) TX bytes:58115315 (55.4 MiB)
启动nodeapps后的效果。
[root@ty11r1a bin]# ifconfig eth0
eth0 Link encap:Ethernet HWaddr 00:0C:29:F0:95:B3
inet addr:192.168.189.161 Bcast:192.168.189.255 Mask:255.255.255.0
inet6 addr: fe80::20c:29ff:fef0:95b3/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:45915 errors:0 dropped:0 overruns:0 frame:0
TX packets:2868 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:25378045 (24.2 MiB) TX bytes:362707 (354.2 KiB)
[root@ty11r1a bin]# ifconfig eth0:1
eth0:1 Link encap:Ethernet HWaddr 00:0C:29:F0:95:B3
inet addr:192.168.189.61 Bcast:192.168.189.255 Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
11、启动服务。
ty11r1a-> srvctl start nodeapps -n ty11r1a
ty11r1a-> srvctl start nodeapps -n ty11r1b
ty11r1a-> srvctl start asm -n ty11r1b
ty11r1a-> srvctl start asm -n ty11r1a
ty11r1a-> srvctl start database -d devdb
12、查看服务是否已经全部启动
ty11r1a-> crs_stat -t
Name Type Target State Host
------------------------------------------------------------
ora.tydb.db application ONLINE ONLINE ty11r1a
ora....b1.inst application ONLINE ONLINE ty11r1a
ora....b2.inst application ONLINE ONLINE ty11r1b
ora....SM1.asm application ONLINE ONLINE ty11r1a
ora....X1.lsnr application ONLINE ONLINE ty11r1a
ora.ty11r1a.gsd application ONLINE ONLINE ty11r1a
ora.ty11r1a.ons application ONLINE ONLINE ty11r1a
ora.ty11r1a.vip application ONLINE ONLINE ty11r1a
ora....SM2.asm application ONLINE ONLINE ty11r1b
ora....X2.lsnr application ONLINE ONLINE ty11r1b
ora.ty11r1b.gsd application ONLINE ONLINE ty11r1b
ora.ty11r1b.ons application ONLINE ONLINE ty11r1b
ora.ty11r1b.vip application ONLINE ONLINE ty11r1b
13、查看实例,2个节点的实例已经全部启动,数据库已经在打开状态。
ty11r1a-> sqlplus / as sysdba
SQL*Plus: Release 11.1.0.1.0 - Production on Sun Mar 27 08:55:18 2011
Copyright (c) 1982, 2005, Oracle. All rights reserved.
Connected to:
Oracle Database 10g Enterprise Edition Release 11.1.0.1.0 - 64bit Production
With the Partitioning, Real Application Clusters, OLAP and Data Mining options
SQL> select instance_name from gv$instance;
INSTANCE_NAME
----------------
tydb1
tydb2
SQL> select open_mode from gv$database;
OPEN_MODE
----------
READ WRITE
READ WRITE
===============End======================================
[root@ty11r1a network-scripts]# oifcfg getif
-bash: oifcfg: command not found
[root@ty11r1a network-scripts]# cd /u01/app/oracle/product/11.1.0/crs/bin
[root@ty11r1a bin]# ./oifcfg getif
eth0 192.168.227.0 global public
eth1 192.168.101.0 global cluster_interconnect
[root@ty11r1a bin]# ./oifcfg iflist
eth0 192.168.64.0
eth0 192.168.227.0
eth1 192.168.101.0
[root@ty11r1a bin]# ./oifcfg delif -global eth0
[root@ty11r1a bin]# ./oifcfg setif -global eth0/192.168.64.1:public
[root@ty11r1a bin]# ./oifcfg getif
eth0 192.168.64.1 global public
eth1 192.168.101.0 global cluster_interconnect
[root@ty11r1a bin]# pwd
/u01/app/oracle/product/11.1.0/crs/bin
[root@ty11r1a bin]# cd /opt
[root@ty11r1a opt]# ls
ORCLfmap
[root@ty11r1a opt]# ifconfig -a
eth0 Link encap:Ethernet HWaddr 00:0C:29:43:1F:5F
inet addr:192.168.64.71 Bcast:192.168.64.255 Mask:255.255.255.0
inet6 addr: fe80::20c:29ff:fe43:1f5f/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:2847 errors:0 dropped:0 overruns:0 frame:0
TX packets:7495 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:350924 (342.6 KiB) TX bytes:3220456 (3.0 MiB)
Base address:0x2400 Memory:d8960000-d8980000
eth0:1 Link encap:Ethernet HWaddr 00:0C:29:43:1F:5F
inet addr:192.168.227.21 Bcast:192.168.227.255 Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
Base address:0x2400 Memory:d8960000-d8980000
eth1 Link encap:Ethernet HWaddr 00:0C:29:43:1F:69
inet addr:192.168.101.11 Bcast:192.168.101.255 Mask:255.255.255.0
inet6 addr: fe80::20c:29ff:fe43:1f69/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:222978 errors:0 dropped:0 overruns:0 frame:0
TX packets:179282 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:154892279 (147.7 MiB) TX bytes:98788726 (94.2 MiB)
Base address:0x2440 Memory:d8980000-d89a0000
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:86503 errors:0 dropped:0 overruns:0 frame:0
TX packets:86503 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:42301969 (40.3 MiB) TX bytes:42301969 (40.3 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)
[root@ty11r1a opt]# srvctl modify nodeapps -n ty11r1ga -A 192.168.64.21/255.255.255.0/eth0
-bash: srvctl: command not found
[root@ty11r1a opt]# cd /u01/app/oracle/product/11.1.0/crs/bin/
[root@ty11r1a bin]# ./srvctl modify nodeapps -n ty11r1ga -A 192.168.64.21/255.255.255.0/eth0
PRKO-2006 : Invalid node name: ty11r1ga
[root@ty11r1a bin]# ./srvctl modify nodeapps -n ty11r1a -A 192.168.64.21/255.255.255.0/eth0
[root@ty11r1a bin]# ifconfig -a
eth0 Link encap:Ethernet HWaddr 00:0C:29:43:1F:5F
inet addr:192.168.64.71 Bcast:192.168.64.255 Mask:255.255.255.0
inet6 addr: fe80::20c:29ff:fe43:1f5f/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:3040 errors:0 dropped:0 overruns:0 frame:0
TX packets:7830 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:369818 (361.1 KiB) TX bytes:3256713 (3.1 MiB)
Base address:0x2400 Memory:d8960000-d8980000
eth0:1 Link encap:Ethernet HWaddr 00:0C:29:43:1F:5F
inet addr:192.168.227.21 Bcast:192.168.227.255 Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
Base address:0x2400 Memory:d8960000-d8980000
eth1 Link encap:Ethernet HWaddr 00:0C:29:43:1F:69
inet addr:192.168.101.11 Bcast:192.168.101.255 Mask:255.255.255.0
inet6 addr: fe80::20c:29ff:fe43:1f69/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:266006 errors:0 dropped:0 overruns:0 frame:0
TX packets:218685 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:184923504 (176.3 MiB) TX bytes:124178080 (118.4 MiB)
Base address:0x2440 Memory:d8980000-d89a0000
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:98936 errors:0 dropped:0 overruns:0 frame:0
TX packets:98936 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:47411744 (45.2 MiB) TX bytes:47411744 (45.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)
[root@ty11r1a bin]# ./srvctl config nodeapps -n ty11r1a -a
VIP exists.: /ty11r1a-vip/192.168.64.21/255.255.255.0/eth0
[root@ty11r1a bin]#
============End===================================
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/24930246/viewspace-1065299/
,如需转载,请注明出处,否则将追究法律责任。