RAC修改IP地址

xychong123發表於2018-03-29
*****************************
*****************************


oracle release 11.2.0.4.0
本次實驗模式netmask:255.255.255.0


一:修改主機ip,vip,scan(網路卡名稱不變)
二:修改Private IP
三:修改公網網路卡名稱,ip地址不變
四:修改Private網路卡名稱,ip地址不變
五:修改公網網路卡名稱,ip 
六:修改Private網路卡名稱,ip
附錄:子網掩碼地址計算




*****************************
*****************************
備份:2臺主機:


私有網路配置不僅僅存在ocr中,還存在gpnp profile中,所以首先需要備份profile.xml:
[grid@host01 peer]$ pwd
/u01/11.2.0/grid/gpnp/host01/profiles/peer
[grid@host01 peer]$ ls
pending.xml  profile.old  profile_orig.xml  profile.xml
[grid@host01 peer]$ cp profile.xml profile.xml.bak


[root@host02 ~]# 
[root@host02 ~]# cd /u01/11.2.0/grid/gpnp/host02/profiles/peer/
[root@host02 peer]# ls
profile_orig.xml  profile.xml
[root@host02 peer]# cp profile.xml profile.xml.bak


Ocr備份:
[root@host01 ~]# /u01/11.2.0/grid/bin/ocrconfig -manualbackup


host02     2018/03/29 08:48:19     /u01/11.2.0/grid/cdata/host-cluster/backup_20180329_084819.ocr
[root@host01 ~]# /u01/11.2.0/grid/bin/ocrconfig -showbackup


host02     2018/03/29 06:08:55     /u01/11.2.0/grid/cdata/host-cluster/backup00.ocr


host02     2018/03/29 02:08:55     /u01/11.2.0/grid/cdata/host-cluster/backup01.ocr


host02     2018/03/28 22:08:54     /u01/11.2.0/grid/cdata/host-cluster/backup02.ocr


host02     2018/03/28 22:08:54     /u01/11.2.0/grid/cdata/host-cluster/day.ocr


host02     2018/03/28 22:08:54     /u01/11.2.0/grid/cdata/host-cluster/week.ocr


host02     2018/03/29 08:48:19     /u01/11.2.0/grid/cdata/host-cluster/backup_20180329_084819.ocr


hosts配置檔案備份:


cp /etc/hosts /tmp/hosts.bak0329


*****************************
情景一
*****************************
修改主機ip,vip,scan(網路卡名稱不變)
修改之前:
#192.168.0.35 host01
#192.168.0.36 host01-vip
#192.168.0.38 host02
#192.168.0.39 host02-vip
#192.168.0.40 scan
修改之後:
172.16.0.135 host01
172.16.0.136 host01-vip
172.16.0.138 host02
172.16.0.139 host02-vip
172.16.0.140 scan




1.正常關庫、監聽和CRS
######/u01/11.2.0/grid/bin/crsctl stop crs
2.修改/etc/hosts配置檔案
172.16.0.135 host01
172.16.0.136 host01-vip
172.16.0.138 host02
172.16.0.139 host02-vip
172.16.0.140 scan
3.OS層修改公有網路卡地址


4.啟動crs
######/u01/11.2.0/grid/bin/crsctl start crs
5.修改Public IP


[grid@host01 ~]$ oifcfg iflist
eth3  172.16.0.0
eth4  10.168.0.0
eth4  169.254.0.0


[grid@host01 ~]$ oifcfg getif
eth3  192.168.0.0  global  public
eth4  10.168.0.0  global  cluster_interconnect
[grid@host01 ~]$ oifcfg delif -global eth3
[grid@host01 ~]$ oifcfg setif -global eth3/172.16.0.0:public
[grid@host01 ~]$ oifcfg getif
eth4  10.168.0.0  global  cluster_interconnect
eth3  172.16.0.0  global  public




6.修改VIP--停止資料庫和監聽
srvctl stop vip -n host01
srvctl stop vip -n host02


#root使用者修改:
srvctl modify nodeapps -n host01 -A 172.16.0.136/255.255.255.0/eth3
srvctl modify nodeapps -n host02 -A 172.16.0.139/255.255.255.0/eth3


[root@host01 ~]# /u01/11.2.0/grid/bin/srvctl config vip -n host01
VIP exists: /172.16.0.136/172.16.0.136/172.16.0.0/255.255.255.0/eth3, hosting node host01
[root@host01 ~]# /u01/11.2.0/grid/bin/srvctl config vip -n host02
VIP exists: /host02-vip/172.16.0.139/172.16.0.0/255.255.255.0/eth3, hosting node host02




/u01/11.2.0/grid/bin/srvctl start vip -n host01
/u01/11.2.0/grid/bin/srvctl start vip -n host02




確認local_listener資訊:
檢查local_listener資訊,如果不正確需要修改,我這裡查詢是正確的。


--兩個節點分別確認:
show parameter local_listener
--修改:
alter system set local_listener='(ADDRESS=(PROTOCOL=TCP)(HOST=172.16.0.136)(PORT=1521))' sid='orcl1';
alter system set local_listener='(ADDRESS=(PROTOCOL=TCP)(HOST=172.16.0.139)(PORT=1521))' sid='orcl2';


7.修改SCAN VIP


 srvctl stop scan_listener
 srvctl stop scan
 srvctl status scan_listener
 srvctl status scan
#root
/u01/11.2.0/grid/bin/srvctl modify scan -n scan
/u01/11.2.0/grid/bin/srvctl  config scan
SCAN name: scan, Network: 1/172.16.0.0/255.255.255.0/eth3
SCAN VIP name: scan1, IP: /scan/172.16.0.140


/u01/11.2.0/grid/bin/srvctl  start scan
/u01/11.2.0/grid/bin/srvctl  start scan_listener




*****************************
情景二
*****************************
修改Private IP


修改前:
10.168.0.123/24--eth4
10.168.0.124/24--eth4
修改後地址
100.16.0.23/24--eth4
100.16.0.24/24--eth4




1,新增新的網路資訊
[grid@host01 ~]$ oifcfg getif
eth4  10.168.0.0  global  cluster_interconnect
eth3  192.168.0.0  global  public
[grid@host01 ~]$ 
##新的子網具有相同網路卡的名稱但不同的子網:
[grid@host01 ~]$ oifcfg setif -global eth4/100.16.0.0:cluster_interconnect
[grid@host01 ~]$ oifcfg getif
eth4  10.168.0.0  global  cluster_interconnect
eth4  100.16.0.0  global  cluster_interconnect
eth3  172.16.0.0  global  public


2,關閉crs
#root執行
/u01/11.2.0/grid/bin/crsctl stop crs


3,修改主機ip地址


4,啟動crs
/u01/11.2.0/grid/bin/crsctl start crs


5,刪除舊的網路資訊
[grid@host01 ~]$ oifcfg delif -global eth4/10.168.0.0
[grid@host01 ~]$ oifcfg getif
eth4  100.16.0.0  global  cluster_interconnect
eth5  172.16.0.0  global  public






*****************************
情景三
*****************************
公網網路卡名稱 eth3===>eth5


1,修改網路卡資訊
[grid@host01 ~]$ oifcfg getif
eth4  10.168.0.0  global  cluster_interconnect
eth4  100.16.0.0  global  cluster_interconnect
eth3  172.16.0.0  global  public
[grid@host01 ~]$ oifcfg iflist
eth5  172.16.0.0
eth4  100.16.0.0
eth4  169.254.0.0
[grid@host01 ~]$ oifcfg setif -global eth5/172.16.0.0:public
[grid@host01 ~]$ oifcfg getif
eth4  10.168.0.0  global  cluster_interconnect
eth4  100.16.0.0  global  cluster_interconnect
eth3  172.16.0.0  global  public
eth5  172.16.0.0  global  public
[grid@host01 ~]$ oifcfg delif -global eth3/172.16.0.0:public
[grid@host01 ~]$ oifcfg getif
eth4  10.168.0.0  global  cluster_interconnect
eth4  100.16.0.0  global  cluster_interconnect
eth5  172.16.0.0  global  public


2,停止crs
3,修改作業系統網路卡名稱
4,啟動crs
5,修改vip,scan
#root執行
srvctl stop vip -n host01
srvctl stop vip -n host02
srvctl modify nodeapps -n host01 -A 172.16.0.136/255.255.255.0/eth5
srvctl modify nodeapps -n host02 -A 172.16.0.139/255.255.255.0/eth5


[root@host01 host01]# /u01/11.2.0/grid/bin/srvctl config vip -n host01
VIP exists: /172.16.0.136/172.16.0.136/172.16.0.0/255.255.255.0/eth5, hosting node host01
[root@host01 host01]# /u01/11.2.0/grid/bin/srvctl config vip -n host02
VIP exists: /host02-vip/172.16.0.139/172.16.0.0/255.255.255.0/eth5, hosting node host02


/u01/11.2.0/grid/bin/srvctl start vip -n host01
/u01/11.2.0/grid/bin/srvctl start vip -n host02


*****************************
情景四
*****************************


修改Private網路卡名稱 eth4===>eth3


1,新增新的網路資訊
[grid@host01 ~]$ 
[grid@host01 ~]$ oifcfg setif -global eth3/100.16.0.0:cluster_interconnect
[grid@host01 ~]$ oifcfg getif
eth4  100.16.0.0  global  cluster_interconnect
eth5  172.16.0.0  global  public
eth3  100.16.0.0  global  cluster_interconnect


2,停止crs
3,修改主機網路卡資訊
4,啟動crs
5,刪除多餘網路資訊
[grid@host01 ~]$ oifcfg getif
eth4  100.16.0.0  global  cluster_interconnect
eth5  172.16.0.0  global  public
eth3  100.16.0.0  global  cluster_interconnect
[grid@host01 ~]$ oifcfg delif -global eth4/100.16.0.0
[grid@host01 ~]$ oifcfg getif
eth5  172.16.0.0  global  public
eth3  100.16.0.0  global  cluster_interconnect






===========
修改之前:
[root@host02 network-scripts]# ip a s
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN 
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host 
       valid_lft forever preferred_lft forever
2: eth5: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
    link/ether 00:50:56:8e:06:87 brd ff:ff:ff:ff:ff:ff
    inet 172.16.0.138/24 brd 172.16.0.255 scope global eth5
       valid_lft forever preferred_lft forever
    inet6 fe80::250:56ff:fe8e:687/64 scope link 
       valid_lft forever preferred_lft forever
3: eth3: <BROADCAST,MULTICAST> mtu 1500 qdisc pfifo_fast state DOWN qlen 1000
    link/ether 00:50:56:8e:8c:39 brd ff:ff:ff:ff:ff:ff
4: eth4: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
    link/ether 00:50:56:8e:2d:83 brd ff:ff:ff:ff:ff:ff
    inet 100.16.0.24/24 brd 100.16.0.255 scope global eth4
       valid_lft forever preferred_lft forever
    inet6 fe80::250:56ff:fe8e:2d83/64 scope link 
       valid_lft forever preferred_lft forever


=============
修改之後
[root@host02 network-scripts]# ip a s
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN 
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host 
       valid_lft forever preferred_lft forever
2: eth5: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
    link/ether 00:50:56:8e:06:87 brd ff:ff:ff:ff:ff:ff
    inet 172.16.0.138/24 brd 172.16.0.255 scope global eth5
       valid_lft forever preferred_lft forever
    inet6 fe80::250:56ff:fe8e:687/64 scope link 
       valid_lft forever preferred_lft forever
3: eth3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
    link/ether 00:50:56:8e:8c:39 brd ff:ff:ff:ff:ff:ff
    inet 100.16.0.24/24 brd 100.16.0.255 scope global eth3
       valid_lft forever preferred_lft forever
    inet6 fe80::250:56ff:fe8e:8c39/64 scope link 
       valid_lft forever preferred_lft forever
4: eth4: <BROADCAST,MULTICAST> mtu 1500 qdisc pfifo_fast state DOWN qlen 1000
    link/ether 00:50:56:8e:2d:83 brd ff:ff:ff:ff:ff:ff
=========




***************************
五:修改公網網路卡名稱,ip 
***************************
修改之前:<<<==========eth5


172.16.0.135 host01
172.16.0.136 host01-vip
172.16.0.138 host02
172.16.0.139 host02-vip
172.16.0.140 scan


[root@host01 network-scripts]# ip a s
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN 
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host 
       valid_lft forever preferred_lft forever
2: eth5: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
    link/ether 00:50:56:8e:71:9f brd ff:ff:ff:ff:ff:ff
    inet 172.16.0.135/24 brd 172.16.0.255 scope global eth5
       valid_lft forever preferred_lft forever
    inet 172.16.0.136/24 brd 172.16.0.255 scope global secondary eth5:3
       valid_lft forever preferred_lft forever
    inet 172.16.0.140/24 brd 172.16.0.255 scope global secondary eth5:2
       valid_lft forever preferred_lft forever
    inet6 fe80::250:56ff:fe8e:719f/64 scope link 
       valid_lft forever preferred_lft forever
3: eth3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
    link/ether 00:50:56:8e:48:2b brd ff:ff:ff:ff:ff:ff
    inet 100.16.0.23/24 brd 100.16.0.255 scope global eth3
       valid_lft forever preferred_lft forever
    inet 169.254.199.73/16 brd 169.254.255.255 scope global eth3:1
       valid_lft forever preferred_lft forever
    inet6 fe80::250:56ff:fe8e:482b/64 scope link 
       valid_lft forever preferred_lft forever
4: eth4: <BROADCAST,MULTICAST> mtu 1500 qdisc pfifo_fast state DOWN qlen 1000
    link/ether 00:50:56:8e:a3:f9 brd ff:ff:ff:ff:ff:ff


修改之後:<<<==========eth4
192.168.0.35 host01
192.168.0.36 host01-vip
192.168.0.38 host02
192.168.0.39 host02-vip
192.168.0.40 scan


1,停止crs
2,修改hosts
3,修改主機ip地址到新網路卡
4,啟動crs
5,修改網路卡資訊
[grid@host01 ~]$ oifcfg iflist
eth3  100.16.0.0
eth3  169.254.0.0
eth4  192.168.0.0


[grid@host01 ~]$ oifcfg getif
eth5  172.16.0.0  global  public
eth3  100.16.0.0  global  cluster_interconnec
[grid@host01 ~]$ oifcfg delif -global eth5
[grid@host01 ~]$ oifcfg setif -global eth4/192.168.0.0:public
[grid@host01 ~]$ oifcfg setif -global eth4/192.168.0.0:public
[grid@host01 ~]$ oifcfg getif
eth3  100.16.0.0  global  cluster_interconnect
eth4  192.168.0.0  global  public




6,修改vip,scan地址
#root使用者修改:
srvctl stop vip -n host01
srvctl stop vip -n host02


#root使用者修改:
srvctl modify nodeapps -n host01 -A 192.168.0.36/255.255.255.0/eth4
srvctl modify nodeapps -n host02 -A 192.168.0.39/255.255.255.0/eth4


/u01/11.2.0/grid/bin/srvctl start vip -n host01
/u01/11.2.0/grid/bin/srvctl start vip -n host02




確認local_listener資訊:
檢查local_listener資訊,如果不正確需要修改,我這裡查詢是正確的。


--兩個節點分別確認:
show parameter local_listener
--修改:
alter system set local_listener='(ADDRESS=(PROTOCOL=TCP)(HOST= host01-vip)(PORT=1521))' sid='orcl1';
alter system set local_listener='(ADDRESS=(PROTOCOL=TCP)(HOST= host02-vip)(PORT=1521))' sid='orcl2';




#修改scan
 srvctl stop scan_listener
 srvctl stop scan
 srvctl status scan_listener
 srvctl status scan
#root
/u01/11.2.0/grid/bin/srvctl modify scan -n scan
/u01/11.2.0/grid/bin/srvctl  config scan
SCAN name: scan, Network: 1/192.168.0.0/255.255.255.0/eth4
SCAN VIP name: scan1, IP: /scan/192.168.0.40


/u01/11.2.0/grid/bin/srvctl  start scan
/u01/11.2.0/grid/bin/srvctl  start scan_listener


修改之後ip地址資訊:
[root@host01 network-scripts]# ip a s
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN 
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host 
       valid_lft forever preferred_lft forever
2: eth5: <BROADCAST,MULTICAST> mtu 1500 qdisc pfifo_fast state DOWN qlen 1000
    link/ether 00:50:56:8e:71:9f brd ff:ff:ff:ff:ff:ff
3: eth3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
    link/ether 00:50:56:8e:48:2b brd ff:ff:ff:ff:ff:ff
    inet 100.16.0.23/24 brd 100.16.0.255 scope global eth3
       valid_lft forever preferred_lft forever
    inet 169.254.199.73/16 brd 169.254.255.255 scope global eth3:1
       valid_lft forever preferred_lft forever
    inet6 fe80::250:56ff:fe8e:482b/64 scope link 
       valid_lft forever preferred_lft forever
4: eth4: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
    link/ether 00:50:56:8e:a3:f9 brd ff:ff:ff:ff:ff:ff
    inet 192.168.0.35/24 brd 192.168.0.255 scope global eth4
       valid_lft forever preferred_lft forever
    inet 192.168.0.40/24 brd 192.168.0.255 scope global secondary eth4:1
       valid_lft forever preferred_lft forever
    inet 192.168.0.36/24 brd 192.168.0.255 scope global secondary eth4:3
       valid_lft forever preferred_lft forever
    inet6 fe80::250:56ff:fe8e:a3f9/64 scope link 
       valid_lft forever preferred_lft forever


***************************
六:修改Private網路卡名稱,ip
***************************
修改之前網路資訊:《============eth3
100.16.0.23 
100.16.0.24


2: eth5: <BROADCAST,MULTICAST> mtu 1500 qdisc pfifo_fast state DOWN qlen 1000
    link/ether 00:50:56:8e:71:9f brd ff:ff:ff:ff:ff:ff
3: eth3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
    link/ether 00:50:56:8e:48:2b brd ff:ff:ff:ff:ff:ff
    inet 100.16.0.23/24 brd 100.16.0.255 scope global eth3
       valid_lft forever preferred_lft forever
    inet 169.254.199.73/16 brd 169.254.255.255 scope global eth3:1
       valid_lft forever preferred_lft forever
    inet6 fe80::250:56ff:fe8e:482b/64 scope link 
       valid_lft forever preferred_lft forever


修改之後網路資訊:《============eth5
10.10.10.123 
10.10.10.124


1,修改網路介面資訊
[grid@host01 ~]$ oifcfg setif -global eth5/10.10.10.0:cluster_interconnect
[grid@host01 ~]$ oifcfg getif
eth3  100.16.0.0  global  cluster_interconnect
eth4  192.168.0.0  global  public
eth5  10.10.10.0  global  cluster_interconnect


2,關閉crs
3,修改主機網路卡IP資訊
4,啟動crs
5,刪除多餘網路介面資訊
[grid@host01 ~]$ oifcfg getif
eth3  100.16.0.0  global  cluster_interconnect
eth4  192.168.0.0  global  public
eth5  10.10.10.0  global  cluster_interconnect
[grid@host01 ~]$ oifcfg delif -global eth3
[grid@host01 ~]$ oifcfg getif
eth4  192.168.0.0  global  public
eth5  10.10.10.0  global  cluster_interconnect






附錄:


子網掩碼地址,在使用oifcfg 需要計算subnet。
Name:
oifcfg - Oracle Interface Configuration Tool.


Usage:  oifcfg iflist [-p [-n]]
oifcfg setif {-node <nodename> | -global} {<if_name>/<subnet>:<if_type>}...


IP地址 192.168.0.1
子網掩碼 255.255.255.0
AND運算(AND運演算法則:1 與1 = 1 ,1 與0 = 0 ,0 與1 = 0 ,0 與0 = 0 ,即當對應位均為1時結果為1,其餘為0。)
轉化為二進位制進行運算:
I P 地址 11000000.10101000.00000000.00000001
子網掩碼 11111111.11111111.11111111.00000000
AND運算
11000000.10101000.00000000.00000000
轉化為十進位制後為:
192.168.0.0  <==========該地址為oifcfg需要的地址。



參考文章:
如何修改叢集的公網資訊(包括 VIP) (文件 ID 1674442.1)
如何在 oracle 叢集環境下修改私網資訊 (文件 ID 2103317.1)




















來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/20747382/viewspace-2152399/,如需轉載,請註明出處,否則將追究法律責任。

相關文章