由于种种原因,可能会遇到需要改服务器IP的情况,完全属于吃饱了撑着的事情,DBA就惨了,单实例如果有用dbconsole,还得重新删掉重建才能使用,rac环境就更悲催了!想想任某人对IT行业的评价,笑而不语…
修改前:这里用DNS解析就改DNS,没用DNS就改各个节点的hosts文件
[root@rac1 ~]# cat /etc/hosts
127.0.0.1 localhost.localdomain localhost
192.168.1.41 rac1.yang.com rac1
192.168.122.41 rac1-priv.yang.com rac1-priv
192.168.1.141 rac1-vip.yang.com rac1-vip
192.168.1.42 rac2.yang.com rac2
192.168.122.42 rac2-priv.yang.com rac2-priv
192.168.1.142 rac2-vip.yang.com rac2-vip
修改后:
[root@rac1 ~]# cat /etc/hosts
127.0.0.1 localhost.localdomain localhost
192.168.2.41 rac1.yang.com rac1
192.168.123.41 rac1-priv.yang.com rac1-priv
192.168.2.141 rac1-vip.yang.com rac1-vip
192.168.2.42 rac2.yang.com rac2
192.168.123.42 rac2-priv.yang.com rac2-priv
192.168.2.142 rac2-vip.yang.com rac2-vip
1:关闭数据库实例,asm实例,nodeapps
[oracle@rac2 ~]$ crs_stat -t -v
Name Type R/RA F/FT Target State Host
----------------------------------------------------------------------
ora.rac.db application 0/0 0/1 ONLINE ONLINE rac1
ora....c1.inst application 0/5 0/0 ONLINE ONLINE rac1
ora....c2.inst application 0/5 0/0 ONLINE ONLINE rac2
ora....SM1.asm application 0/5 0/0 ONLINE ONLINE rac1
ora....C1.lsnr application 0/5 0/0 ONLINE ONLINE rac1
ora.rac1.gsd application 0/5 0/0 ONLINE ONLINE rac1
ora.rac1.ons application 0/3 0/0 ONLINE ONLINE rac1
ora.rac1.vip application 0/0 0/0 ONLINE ONLINE rac1
ora....SM2.asm application 0/5 0/0 ONLINE ONLINE rac2
ora....C2.lsnr application 0/5 0/0 ONLINE ONLINE rac2
ora.rac2.gsd application 0/5 0/0 ONLINE ONLINE rac2
ora.rac2.ons application 0/3 0/0 ONLINE ONLINE rac2
ora.rac2.vip application 0/0 0/0 ONLINE ONLINE rac2
[oracle@rac2 ~]$ srvctl stop database -d rac -o immediate
[oracle@rac2 ~]$ crs_stop -all
2:操作系统级别修改ip地址,重启2个节点,发现VIP和listener不正常
[oracle@rac1 ~]$ ip a |grep inet |grep -v 'inet6'
inet 127.0.0.1/8 scope host lo
inet 192.168.2.41/24 brd 192.168.2.255 scope global eth0
inet 192.168.123.41/24 brd 192.168.123.255 scope global eth1
[oracle@rac2 ~]$ ip a |grep inet |grep -v 'inet6'
inet 127.0.0.1/8 scope host lo
inet 192.168.2.42/24 brd 192.168.2.255 scope global eth0
inet 192.168.123.42/24 brd 192.168.123.255 scope global eth1
[oracle@rac1 ~]$ crs_stat -t -v
Name Type R/RA F/FT Target State Host
----------------------------------------------------------------------
ora.rac.db application 0/0 0/1 ONLINE ONLINE rac1
ora....c1.inst application 0/5 0/0 ONLINE ONLINE rac1
ora....c2.inst application 0/5 0/0 ONLINE ONLINE rac2
ora....SM1.asm application 0/5 0/0 ONLINE ONLINE rac1
ora....C1.lsnr application 0/5 0/0 ONLINE OFFLINE
ora.rac1.gsd application 0/5 0/0 ONLINE ONLINE rac1
ora.rac1.ons application 0/3 0/0 ONLINE ONLINE rac1
ora.rac1.vip application 0/0 0/0 ONLINE OFFLINE
ora....SM2.asm application 0/5 0/0 ONLINE ONLINE rac2
ora....C2.lsnr application 0/5 0/0 ONLINE OFFLINE
ora.rac2.gsd application 0/5 0/0 ONLINE ONLINE rac2
ora.rac2.ons application 0/3 0/0 ONLINE ONLINE rac2
ora.rac2.vip application 0/0 0/0 ONLINE OFFLINE
3:修改2个节点的listener.ora文件,重启监听器,发现一切正常,难道这样就ok了?
[oracle@rac1 ~]$ cd $ORACLE_HOME/network/admin
[oracle@rac1 admin]$ grep -v '^#' listener.ora
LISTENER_RAC1 =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = rac1-vip.yang.com)(PORT = 1521)(IP = FIRST))
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.2.41)(PORT = 1521)(IP = FIRST))
)
)
SID_LIST_LISTENER_RAC1 =
(SID_LIST =
(SID_DESC =
(ORACLE_HOME = /u01/app/oracle/product/10.2.0/db_1)
(SID_NAME = rac1)
)
(SID_DESC =
(SID_NAME = PLSExtProc)
(ORACLE_HOME = /u01/app/oracle/product/10.2.0/db_1)
(PROGRAM = extproc)
)
)
[oracle@rac1 ~]$ srvctl stop listener -n rac1
[oracle@rac1 ~]$ srvctl stop listener -n rac2
[oracle@rac1 ~]$ srvctl start listener -n rac1
[oracle@rac1 ~]$ srvctl start listener -n rac2
[oracle@rac1 ~]$ crs_stat -t -v
Name Type R/RA F/FT Target State Host
----------------------------------------------------------------------
ora.rac.db application 0/0 0/1 ONLINE ONLINE rac1
ora....c1.inst application 0/5 0/0 ONLINE ONLINE rac1
ora....c2.inst application 0/5 0/0 ONLINE ONLINE rac2
ora....SM1.asm application 0/5 0/0 ONLINE ONLINE rac1
ora....C1.lsnr application 0/5 0/0 ONLINE ONLINE rac1
ora.rac1.gsd application 0/5 0/0 ONLINE ONLINE rac1
ora.rac1.ons application 0/3 0/0 ONLINE ONLINE rac1
ora.rac1.vip application 0/0 0/0 ONLINE ONLINE rac1
ora....SM2.asm application 0/5 0/0 ONLINE ONLINE rac2
ora....C2.lsnr application 0/5 0/0 ONLINE ONLINE rac2
ora.rac2.gsd application 0/5 0/0 ONLINE ONLINE rac2
ora.rac2.ons application 0/3 0/0 ONLINE ONLINE rac2
ora.rac2.vip application 0/0 0/0 ONLINE ONLINE rac2
4:查看下VIP,发现依然是旧的,在2个节点上使用oifcfg改(使用root用户),这里估计也可以使用vipca工具改
[oracle@rac1 ~]$ ip a |grep inet |grep -v 'inet6'
inet 127.0.0.1/8 scope host lo
inet 192.168.2.41/24 brd 192.168.2.255 scope global eth0
inet 192.168.1.141/24 brd 192.168.1.255 scope global eth0:1
inet 192.168.123.41/24 brd 192.168.123.255 scope global eth1
[root@rac1 ~]# cd /u01/app/oracle/product/10.2.0/crs_1/bin/
[root@rac1 bin]# ./oifcfg iflist
eth0 192.168.2.0
eth0 192.168.1.0
eth1 192.168.123.0
[root@rac1 bin]# ./oifcfg getif
[root@rac1 bin]# ./oifcfg setif -global eth0/192.168.2.0:public
[root@rac1 bin]# ./oifcfg setif -global eth1/192.168.123.0:cluster_interconnect
[root@rac1 bin]# ./oifcfg getif
eth0 192.168.2.0 global public
eth1 192.168.123.0 global cluster_interconnect
[root@rac2 bin]# ./oifcfg iflist
eth0 192.168.2.0
eth0 192.168.1.0
eth1 192.168.123.0
[root@rac2 bin]# ./oifcfg getif
eth0 192.168.2.0 global public
eth1 192.168.123.0 global cluster_interconnect
[oracle@rac1 ~]$ srvctl stop database -d rac -o immediate
[oracle@rac1 ~]$ srvctl stop listener -n rac1
[oracle@rac1 ~]$ srvctl stop listener -n rac2
[root@rac1 bin]# ./srvctl modify nodeapps -n rac1 -A 192.168.2.141/255.255.255.0/eth0
[root@rac2 bin]# ./srvctl modify nodeapps -n rac2 -A 192.168.2.142/255.255.255.0/eth0
5:修改完,发现新的VIP和旧的VIP都绑定在网卡上,于是重启2个节点,重启后只绑定了新的VIP,nodeapps,asm和数据库实例都随着crs的启动而自动online!(这里忘记使用service network restart命令测试,失败!)
[oracle@rac1 ~]$ crs_start -all
[oracle@rac1 ~]$ ip a |grep 'inet' |grep -v 'inet6'
inet 127.0.0.1/8 scope host lo
inet 192.168.2.41/24 brd 192.168.2.255 scope global eth0
inet 192.168.1.141/24 brd 192.168.1.255 scope global eth0:1
inet 192.168.2.141/24 brd 192.168.2.255 scope global secondary eth0:2
inet 192.168.123.41/24 brd 192.168.123.255 scope global eth1
[root@rac1 ~]# uptime
20:24:25 up 6 min, 1 user, load average: 2.80, 3.15, 1.50
[root@rac1 ~]# ip a |grep inet |grep -v inet6
inet 127.0.0.1/8 scope host lo
inet 192.168.2.41/24 brd 192.168.2.255 scope global eth0
inet 192.168.2.141/24 brd 192.168.2.255 scope global secondary eth0:1
inet 192.168.123.41/24 brd 192.168.123.255 scope global eth1
[root@rac1 ~]# cd /u01/app/oracle/product/10.2.0/crs_1/bin/
[root@rac1 bin]# ./oifcfg iflist
eth0 192.168.2.0
eth1 192.168.123.0
[root@rac1 bin]# ./oifcfg getif
eth0 192.168.2.0 global public
eth1 192.168.123.0 global cluster_interconnect
[root@rac1 bin]# su - oracle
[oracle@rac1 ~]$ crs_stat -t -v
Name Type R/RA F/FT Target State Host
----------------------------------------------------------------------
ora.rac.db application 0/0 0/1 ONLINE ONLINE rac2
ora....c1.inst application 0/5 0/0 ONLINE ONLINE rac1
ora....c2.inst application 0/5 0/0 ONLINE ONLINE rac2
ora....SM1.asm application 0/5 0/0 ONLINE ONLINE rac1
ora....C1.lsnr application 0/5 0/0 ONLINE ONLINE rac1
ora.rac1.gsd application 0/5 0/0 ONLINE ONLINE rac1
ora.rac1.ons application 0/3 0/0 ONLINE ONLINE rac1
ora.rac1.vip application 0/0 0/0 ONLINE ONLINE rac1
ora....SM2.asm application 0/5 0/0 ONLINE ONLINE rac2
ora....C2.lsnr application 0/5 0/0 ONLINE ONLINE rac2
ora.rac2.gsd application 0/5 0/0 ONLINE ONLINE rac2
ora.rac2.ons application 0/3 0/0 ONLINE ONLINE rac2
ora.rac2.vip application 0/0 0/0 ONLINE ONLINE rac2
6:测试下,发现正常!
[oracle@rhel6 admin]$ tail -17 tnsnames.ora
RAC =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.2.141)(PORT = 1521))
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.2.142)(PORT = 1521))
)
(LOAD_BALANCE=YES)
(FAILOVER=YES)
(CONNECT_DATA =
(SERVICE_NAME = rac.yang.com)
(FAILOVER_MODE =
(TYPE = SELECT)
(METHOD = BASIC)
(RETRIES = 180)
(DELAY = 5))
)
)
[oracle@rhel6 admin]$ sqlplus sys/123456@rac as sysdba
SQL*Plus: Release 10.2.0.1.0 - Production on Mon Mar 26 20:28:02 2012
Copyright (c) 1982, 2005, Oracle. All rights reserved.
Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.5.0 - 64bit Production
With the Partitioning, Real Application Clusters, OLAP, Data Mining
and Real Application Testing options
SQL> select instance_name from v$instance;
INSTANCE_NAME
----------------
rac1
备注:这里rac未使用网格控制器管理,后期可以研究下,修改完IP后,如何向网格控制器重新注册!数据库版本是10.2.0.5,稍后也将测试下11g的rac,另外修改前还是备份下OCR比较保险点,有闲功夫的话,数据库也备份一次吧!
©著作权归作者所有:来自51CTO博客作者ylw6006的原创作品,谢绝转载,否则将追究法律责任
ipvipracRAC
共同学习,写下你的评论
评论加载中...
作者其他优质文章