此文转载自“架构君” ,地址:安全注册
此文说明较为详细,所以留作参考,详细内容如下。
Oracle 11g RAC 修改各类IP地址
首先,我们都知道Oracle 11g RAC中的IP主要有:Public IP、VIP、SCAN VIP、Private IP这几种。
一般这类改IP地址或者网卡名称的需求主要场景有:
机房搬迁网络变更、系统上线由测试IP更改为生产IP、系统层面双网卡绑定或者解绑等。
我这里实验环境的需求是:
之前在Virtual Box虚拟化环境建设的Oracle 11g RAC,最初选择的公有网络网卡类型是“仅主机(host-only)适配器”模式的,这种模式不会受到外界网络影响。但是现在有局域网络其他机器访问这个环境的需求,所以需要将公有网络网卡的类型修改为“桥接网卡”模式,并修改对应的IP地址为局域网网段的。实际上private IP并没有必要去修改,但为了演示修改private IP的过程,也做了修改。
原Oracle 11g RAC IP信息如下:
#public ip
192.168.56.150 jyrac1
192.168.56.152 jyrac2
#private ip
10.10.10.11 jyrac1-priv
10.10.10.12 jyrac2-priv
#virtual ip
192.168.56.151 jyrac1-vip
192.168.56.153 jyrac2-vip
#scan ip
192.168.56.160 jyrac-scan
只听到从架构师办公室传来架构君的声音:
有恨岂因燕凤去,无言宁为息侯亡?合欢不验丁香结,只得凄凉对烛房。有谁来对上联或下联?
现在根据需求,最终需要修改为:
#public ip
192.168.1.50 jyrac1
192.168.1.52 jyrac2
#private ip
20.20.20.11 jyrac1-priv
20.20.20.12 jyrac2-priv
#virtual ip
192.168.1.51 jyrac1-vip
192.168.1.53 jyrac2-vip
#scan ip
192.168.1.60 jyrac-scan
主要实施步骤如下:
1.正常关库、监听和CRS
2.修改/etc/hosts配置文件
3.OS层修改公有网卡地址
4.启动crs
5.修改Public IP,VIP,SCAN VIP
6.修改Private IP
这里先正常immediate关闭数据库,然后关闭监听,最后关闭两个节点的crs:
[grid@jyrac1 ~]$ srvctl stop database -d jyzhao -o immediate
[grid@jyrac1 ~]$ srvctl stop listener
[grid@jyrac1 ~]$ which crsctl
/opt/app/11.2.0/grid/bin/crsctl
[root@jyrac1 ~]# /opt/app/11.2.0/grid/bin/crsctl stop crs
[root@jyrac2 ~]# /opt/app/11.2.0/grid/bin/crsctl stop crs
注意:这样再次启动crs时,就不会自动启动监听和数据库了。
根据需求,先备份原来的/etc/hosts文件为/etc/hosts.bak
此代码由Java架构师必看网-架构君整理
[root@jyrac1 ~]# cp /etc/hosts /etc/hosts.bak
[root@jyrac2 ~]# cp /etc/hosts /etc/hosts.bak
然后再vi修改/etc/hosts文件:
将public ip、vip、scan vip修改为如下值:
#public ip
192.168.1.50 jyrac1
192.168.1.52 jyrac2
#virtual ip
192.168.1.51 jyrac1-vip
192.168.1.53 jyrac2-vip
#scan ip
192.168.1.60 jyrac-scan
注意:其他内容不变。关于private ip,等后面修改private ip的时候再一起改。
这部分正常实施应由SA来做,我这里是自己的实验环境,所以此步骤过程仅供参考:
3.1 确认之前的公网网卡信息(这里省略了无关网卡信息输出):
[root@jyrac1 ~]# ifconfig -a
eth2 Link encap:Ethernet HWaddr 08:00:27:95:22:E3
inet addr:192.168.56.150 Bcast:192.168.56.255 Mask:255.255.255.0
inet6 addr: fe80::a00:27ff:fe95:22e3/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:3549 errors:0 dropped:0 overruns:0 frame:0
TX packets:3378 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:396404 (387.1 KiB) TX bytes:824575 (805.2 KiB)
[root@jyrac2 etc]# ifconfig -a
eth2 Link encap:Ethernet HWaddr 08:00:27:1A:5A:7A
inet addr:192.168.56.152 Bcast:192.168.56.255 Mask:255.255.255.0
inet6 addr: fe80::a00:27ff:fe1a:5a7a/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:2353 errors:0 dropped:0 overruns:0 frame:0
TX packets:2188 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:292753 (285.8 KiB) TX bytes:306602 (299.4 KiB)
3.2 修改虚拟环境的网卡连接方式
按照本次需求,需要在virtual box虚拟机那里将连接方式由“仅主机(host-only)适配器”修改为“桥接网卡”。
3.3 修改Public IP地址
由于已经无法连接,需要到virt box虚拟机管理界面进行主机的对应网卡IP地址修改,之后重新启动对应的网卡。
主要命令如下:
vi /etc/sysconfig/network-scripts/ifcfg-eth2
ifdown eth2
ifup eth2
ifconfig eth2
ping 192.168.1.50
ping 192.168.1.52
以节点1为例,修改后的网卡信息:
[root@jyrac1 ~]# cat /etc/sysconfig/network-scripts/ifcfg-eth2
DEVICE=eth2
TYPE=Ethernet
ONBOOT=yes
BOOTPROTO=static
IPADDR=192.168.1.50
NETMASK=255.255.255.0
[root@jyrac1 ~]# ifconfig eth2
eth2 Link encap:Ethernet HWaddr 08:00:27:95:22:E3
inet addr:192.168.1.50 Bcast:192.168.1.255 Mask:255.255.255.0
inet6 addr: fe80::a00:27ff:fe95:22e3/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:3998 errors:0 dropped:0 overruns:0 frame:0
TX packets:3594 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:440406 (430.0 KiB) TX bytes:861230 (841.0 KiB)
最终使用局域网其他机器配置CRT连接到新修改的IP地址,结果可以正常连接,确认到此主机的Public IP地址在主机层面已经修改完毕。
crsctl start crs
[root@jyrac1 ~]# /opt/app/11.2.0/grid/bin/crsctl start crs
[root@jyrac2 ~]# /opt/app/11.2.0/grid/bin/crsctl start crs
注意:这里如果是按照我上面关闭crs的操作,正常数据库和监听是没有启动的,对应target和state都应该是offline:
ora.LISTENER.lsnr
OFFLINE OFFLINE jyrac1
OFFLINE OFFLINE jyrac2
ora.jyzhao.db
1 OFFLINE OFFLINE Instance Shutdown
2 OFFLINE OFFLINE Instance Shutdown
5.1 修改Public IP
–查看当前设定:
[root@jyrac1 ~]# /opt/app/11.2.0/grid/bin/oifcfg getif
eth2 192.168.56.0 global public
eth3 10.10.10.0 global cluster_interconnect
–删除旧值并设定新值
[root@jyrac1 ~]# /opt/app/11.2.0/grid/bin/oifcfg delif -global eth2
[root@jyrac1 ~]# /opt/app/11.2.0/grid/bin/oifcfg setif -global eth2/192.168.1.0:public
–查看验证修改成功:
[root@jyrac1 ~]# /opt/app/11.2.0/grid/bin/oifcfg getif
eth3 10.10.10.0 global cluster_interconnect
eth2 192.168.1.0 global public
[root@jyrac2 ~]# /opt/app/11.2.0/grid/bin/oifcfg getif
eth3 10.10.10.0 global cluster_interconnect
eth2 192.168.1.0 global public
5.2 修改VIP
需要停止数据库、监听和VIP,如果按照之前操作,目前数据库和监听已经是停止状态。
[grid@jyrac1 ~]$ srvctl stop vip -n jyrac1
[grid@jyrac1 ~]$ srvctl stop vip -n jyrac2
查看VIP当前设置:
[grid@jyrac1 ~]$ olsnodes -s
jyrac1 Active
jyrac2 Active
[grid@jyrac1 ~]$ srvctl config vip -n jyrac1
VIP exists: /jyrac1-vip/192.168.1.51/192.168.56.0/255.255.255.0/eth2, hosting node jyrac1
[grid@jyrac1 ~]$ srvctl config vip -n jyrac2
VIP exists: /jyrac2-vip/192.168.1.53/192.168.56.0/255.255.255.0/eth2, hosting node jyrac2
修改VIP设置:
[root@jyrac1 ~]# /opt/app/11.2.0/grid/bin/srvctl modify nodeapps -n jyrac1 -A 192.168.1.51/255.255.255.0/eth2
[root@jyrac1 ~]# /opt/app/11.2.0/grid/bin/srvctl modify nodeapps -n jyrac2 -A 192.168.1.53/255.255.255.0/eth2
再次验证VIP修改完成:
[root@jyrac1 ~]# /opt/app/11.2.0/grid/bin/srvctl config vip -n jyrac1
VIP exists: /jyrac1-vip/192.168.1.51/192.168.1.0/255.255.255.0/eth2, hosting node jyrac1
[root@jyrac1 ~]# /opt/app/11.2.0/grid/bin/srvctl config vip -n jyrac2
VIP exists: /jyrac2-vip/192.168.1.53/192.168.1.0/255.255.255.0/eth2, hosting node jyrac2
启动vip
[grid@jyrac1 ~]$ srvctl start vip -n jyrac1
[grid@jyrac1 ~]$ srvctl start vip -n jyrac2
启动监听:
[grid@jyrac1 ~]$ srvctl start listener
启动数据库:
[grid@jyrac1 ~]$ srvctl start database -d jyzhao
确认local_listener信息:
检查local_listener信息,如果不正确需要修改,我这里查询是正确的。
–两个节点分别确认:
show parameter local_listener
–修改:
alter system set local_listener='(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.1.51)(PORT=1521))' sid='jyzhao1';
alter system set local_listener='(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.1.53)(PORT=1521))' sid='jyzhao2';
5.3 修改SCAN VIP
查看SCAN VIP当前设置:
[grid@jyrac1 ~]$ srvctl config scan
SCAN name: jyrac-scan, Network: 1/192.168.1.0/255.255.255.0/eth2
SCAN VIP name: scan1, IP: /jyrac-scan/192.168.56.160
停止scan_listener和scan资源
[grid@jyrac1 ~]$ srvctl stop scan_listener
[grid@jyrac1 ~]$ srvctl stop scan
–确认已停止
[grid@jyrac1 ~]$ srvctl status scan_listener
SCAN Listener LISTENER_SCAN1 is enabled
SCAN listener LISTENER_SCAN1 is not running
[grid@jyrac1 ~]$ srvctl status scan
SCAN VIP scan1 is enabled
SCAN VIP scan1 is not running
使用root用户修改SCAN VIP
[root@jyrac1 ~]# /opt/app/11.2.0/grid/bin/srvctl modify scan -n jyrac-scan
注意:root用户执行修改,且确认/etc/hosts映射关系已修改为新的scan VIP。
修改并启动资源
[grid@jyrac1 ~]$ srvctl modify scan_listener -u
[grid@jyrac1 ~]$ srvctl start scan_listener
注意:执行后确认scan_listener和scan都已经启动。
确认修改成功
[grid@jyrac1 ~]$ srvctl config scan
SCAN name: jyrac-scan, Network: 1/192.168.1.0/255.255.255.0/eth2
SCAN VIP name: scan1, IP: /jyrac-scan/192.168.1.60
[grid@jyrac1 ~]$ srvctl config scan_listener
SCAN Listener LISTENER_SCAN1 exists. Port: TCP:1521
查看整个集群状态正常:
[grid@jyrac1 ~]$ crsctl stat res -t
--------------------------------------------------------------------------------
NAME TARGET STATE SERVER STATE_DETAILS
--------------------------------------------------------------------------------
Local Resources
--------------------------------------------------------------------------------
ora.DATA1.dg
ONLINE ONLINE jyrac1
ONLINE ONLINE jyrac2
ora.FRA1.dg
ONLINE ONLINE jyrac1
ONLINE ONLINE jyrac2
ora.LISTENER.lsnr
ONLINE ONLINE jyrac1
ONLINE ONLINE jyrac2
ora.OCR1.dg
ONLINE ONLINE jyrac1
ONLINE ONLINE jyrac2
ora.asm
ONLINE ONLINE jyrac1 Started
ONLINE ONLINE jyrac2 Started
ora.gsd
OFFLINE OFFLINE jyrac1
OFFLINE OFFLINE jyrac2
ora.net1.network
ONLINE ONLINE jyrac1
ONLINE ONLINE jyrac2
ora.ons
ONLINE ONLINE jyrac1
ONLINE ONLINE jyrac2
ora.registry.acfs
ONLINE ONLINE jyrac1
ONLINE ONLINE jyrac2
--------------------------------------------------------------------------------
Cluster Resources
--------------------------------------------------------------------------------
ora.LISTENER_SCAN1.lsnr
1 ONLINE ONLINE jyrac1
ora.cvu
1 ONLINE ONLINE jyrac2
ora.jyrac1.vip
1 ONLINE ONLINE jyrac1
ora.jyrac2.vip
1 ONLINE ONLINE jyrac2
ora.jyzhao.db
1 ONLINE ONLINE jyrac1 Open
2 ONLINE ONLINE jyrac2 Open
ora.oc4j
1 ONLINE ONLINE jyrac1
ora.scan1.vip
1 ONLINE ONLINE jyrac1
至此,修改Oracle 11g RAC的public IP、VIP、SCAN VIP就算完成了。
因为私网一般是两节点服务器之间通信,独立网络,所以一般不用修改。如需修改参考如下。
6.1 备份并确认CRS集群正常
从Oracle 11.2 GI开始,私有网络配置不仅仅存在ocr中,还存在gpnp profile中,所以首先需要备份profile.xml
–MOS上的说明:
Please take a backup of profile.xml on all cluster nodes before proceeding, as grid user:
$ cd $GRID_HOME/gpnp/
/profiles/peer/
$ cp -p profile.xml profile.xml.bk
–节点1备份:
[grid@jyrac1 ~]$ cd /opt/app/11.2.0/grid/gpnp/jyrac1/profiles/peer/
[grid@jyrac1 peer]$ cp -p profile.xml profile.xml.bk
–节点2备份:
[grid@jyrac2 ~]$ cd /opt/app/11.2.0/grid/gpnp/jyrac2/profiles/peer/
[grid@jyrac2 peer]$ cp -p profile.xml profile.xml.bk
确认CRS集群在各节点启动:
[grid@jyrac1 ~]$ olsnodes -s
jyrac1 Active
jyrac2 Active
6.2 设定新的私网信息
[root@jyrac1 ~]# /opt/app/11.2.0/grid/bin/oifcfg getif
eth3 10.10.10.0 global cluster_interconnect
eth2 192.168.1.0 global public
[root@jyrac1 ~]# /opt/app/11.2.0/grid/bin/oifcfg setif -global eth3/20.20.20.0:cluster_interconnect
[root@jyrac1 ~]# /opt/app/11.2.0/grid/bin/oifcfg getif
eth3 10.10.10.0 global cluster_interconnect
eth2 192.168.1.0 global public
eth3 20.20.20.0 global cluster_interconnect
这里私网网段没有变化,不用修改。
6.3 root用户在所有节点关闭并禁用集群
crsctl stop crs
crsctl disable crs
[root@jyrac1 ~]# /opt/app/11.2.0/grid/bin/crsctl stop crs
[root@jyrac2 ~]# /opt/app/11.2.0/grid/bin/crsctl stop crs
[root@jyrac1 ~]# /opt/app/11.2.0/grid/bin/crsctl disable crs
[root@jyrac2 ~]# /opt/app/11.2.0/grid/bin/crsctl disable crs
6.4 OS层修改私有网卡地址
ifconfig -a
ping
修改私有网卡IP并重启:
[root@jyrac1 ~]# vi /etc/sysconfig/network-scripts/ifcfg-eth3
[root@jyrac1 ~]# ifdown eth3
[root@jyrac1 ~]# ifup eth3
vi /etc/hosts 修改private ip部分为:
#private ip
20.20.20.11 jyrac1-priv
20.20.20.12 jyrac2-priv
6.5 root用户在所有节点启用并启动集群
crsctl enable crs
crsctl start crs
root用户在所有节点启用并启动集群:
[root@jyrac1 ~]# /opt/app/11.2.0/grid/bin/crsctl enable crs
[root@jyrac2 ~]# /opt/app/11.2.0/grid/bin/crsctl enable crs
[root@jyrac1 ~]# /opt/app/11.2.0/grid/bin/crsctl start crs
[root@jyrac2 ~]# /opt/app/11.2.0/grid/bin/crsctl start crs
6.6 删除旧值
[root@jyrac1 ~]# /opt/app/11.2.0/grid/bin/oifcfg delif -global eth1/10.10.10.0
[root@jyrac1 ~]# /opt/app/11.2.0/grid/bin/oifcfg getif
eth2 192.168.56.0 global public
eth3 20.20.20.0 global cluster_interconnect
检查集群状态,测试应用连接,一切正常。
Reference
How to Modify Public Network Information including VIP in Oracle Clusterware (Doc ID 276434.1)
How to Modify Private Network Information in Oracle Clusterware (文档 ID 283684.1)
How to Modify SCAN Setting or SCAN Listener Port after Installation (文档 ID 972500.1)
How to update the IP address of the SCAN VIP resources (ora.scan{n}.vip) (文档 ID 952903.1)
此文转载自“架构君” ,地址:安全注册