基於RedHat的RAC環境下修改ip及vip

tangyunoracle發表於2013-12-28
生產系統中修改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部落格 ” ,連結:http://blog.itpub.net/24930246/viewspace-1065299/,如需轉載,請註明出處,否則將追究法律責任。

相關文章