服务热线:13616026886

技术文档 欢迎使用技术文档,我们为你提供从新手到专业开发者的所有资源,你也可以通过它日益精进

位置:首页 > 技术文档 > 数据库技术 > Oracle技术 > Oracle开发 > 查看文档

如何更改rac的vip地址和集群互联地址 (1)

在实际的工作和学习中,许多人在debian下的oracle 10gr2做java测试时, 忘记了上次关机以来的网络以及vmware已经做了调整, 出现无法直接访问的情况。 本文中我们将把debian虚拟机使用的ip地址更改, 以此来解决该问题。

主机名及修改前后的ip地址:

主机名      修改前的ip地址      修改后的ip地址      作用
rac1       192.168.0.181      192.168.1.181     rac1 eth0 native ip
rac2       192.168.0.182      192.168.1.182     rac2 eth0 native ip
rac1-vip   192.168.0.191      192.168.1.191     rac1 vip
rac2-vip   192.168.0.192      192.168.1.192     rac2 vip
rac1-priv  10.10.10.181       10.1.0.181        rac1 eth1 ip interconn
rac2-priv  10.10.10.182       10.1.0.182        rac2 eth1 ip interconn

注释:停止所有oracle相关的进程, 然后修改操作系统的ip设置, 修改与oracle相关的ip地址的设定, 启动crs及相关服务。

具体操作步骤如下:

1.停止oracle相关的所有进程, 包括数据库, asm, node application, crs本身

1.1 查看当前系统上crs运行的状态

oracle@rac2:/u01/app/oracle/product/10.2.0/crs/bin$ ./crs_stat
name=ora.orcl.db
type=application
target=online
state=online on rac2

name=ora.orcl.orcl1.inst
type=application
target=online
state=online on rac1

name=ora.orcl.orcl2.inst
type=application
target=online
state=online on rac2

name=ora.rac1.asm1.asm
type=application
target=online
state=online on rac1

name=ora.rac1.listener_rac1.lsnr
type=application
target=online
state=online on rac1

name=ora.rac1.gsd
type=application
target=online
state=online on rac1

name=ora.rac1.ons
type=application
target=online
state=online on rac1

name=ora.rac1.vip
type=application
target=online
state=online on rac1

name=ora.rac2.asm2.asm
type=application
target=online
state=online on rac2

name=ora.rac2.listener_rac2.lsnr
type=application
target=online
state=online on rac2

name=ora.rac2.gsd
type=application
target=online
state=online on rac2

name=ora.rac2.ons
type=application
target=online
state=online on rac2

name=ora.rac2.vip
type=application
target=online
state=online on rac2

1.2 关闭数据库

oracle@rac2:/u01/app/oracle/product/10.2.0/crs/bin$ srvctl stop database -d orcl

1.3 关闭asm实例

oracle@rac2:/u01/app/oracle/product/10.2.0/crs/bin$ srvctl stop asm -n rac1
oracle@rac2:/u01/app/oracle/product/10.2.0/crs/bin$ srvctl stop asm -n rac2

1.4 关闭其他应用程序

rac2:/u01/app/oracle/product/10.2.0/crs/bin# ./srvctl stop nodeapps -n rac1
rac2:/u01/app/oracle/product/10.2.0/crs/bin# ./srvctl stop nodeapps -n rac2

1.5 关闭crs后台进程, 这一操作会在操作系统一级中止运行的crs后台进程, 必须在所有节点上运行

rac1:/u01/app/oracle/product/10.2.0/crs/bin# /etc/init.d/init.crs stop
shutting down oracle cluster ready services (crs):
stopping resources.
successfully stopped crs resources
stopping cssd.
shutting down css daemon.
shutdown request successfully issued.
shutdown has begun. the daemons should exit soon.

2.修改操作系统的ip设置

debian的网络配置文件为/etc/network/interfaces和/etc/hosts, 其他linux发行版及unix网络配置文件位置可能并不一样. 以节点rac1为例, 修改前/etc/network/interfaces文件内容为:

# this file describes the network interfaces available on your system
# and how to activate them. for more information, see interfaces(5).

# the loopback network interface
auto lo
iface lo inet loopback

# the primary network interface
auto eth0 eth1
iface eth0 inet static
address 192.168.0.181
netmask 255.255.255.0
network 192.168.0.0
broadcast 192.168.0.255
gateway 192.168.0.1
# dns-* options are implemented by the resolvconf package, if installed
dns-nameservers 202.106.0.20

iface eth1 inet static
address 10.10.10.181
netmask 255.255.255.0
network 10.10.10.0
broadcast 10.10.10.255

修改后内容为:

# this file describes the network interfaces available on your system
# and how to activate them. for more information, see interfaces(5).

# the loopback network interface
auto lo
iface lo inet loopback

# the primary network interface
auto eth0 eth1
iface eth0 inet static
address 192.168.1.181
netmask 255.255.255.0
network 192.168.1.0
broadcast 192.168.1.255
gateway 192.168.1.1
# dns-* options are implemented by the resolvconf package, if installed
dns-nameservers 202.106.0.20

iface eth1 inet static
address 10.1.0.181
netmask 255.255.255.0
network 10.1.0.0
broadcast 10.1.0.255

/etc/hosts文件内容为:

127.0.0.1       localhost.localdomain   localhost
192.168.0.181   rac1
192.168.0.182   rac2

192.168.0.191   rac1-vip
192.168.0.192   rac2-vip

10.10.10.181    rac1-priv
10.10.10.182    rac2-priv

# the following lines are desirable for ipv6 capable hosts
::1     ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
ff02::3 ip6-allhosts

修改后:

127.0.0.1       localhost.localdomain   localhost
192.168.1.181   rac1
192.168.1.182   rac2

192.168.1.191   rac1-vip
192.168.1.192   rac2-vip

10.1.0.181      rac1-priv
10.1.0.182      rac2-priv

# the following lines are desirable for ipv6 capable hosts
::1     ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
ff02::3 ip6-allhosts

集群中所有节点的hosts文件应该保持一致.

/etc/network/interfaces和/etc/hosts文件修改后可使用

/etc/init.d/networking restart

或者重启操作系统使设置生效.

3.启动crs, 设置oracle中ip地址相关的设置

3.1 启动crs, 并关闭随crs启动的应用程序

rac1:/u01/app/oracle/product/10.2.0/db_1/network/admin# /etc/init.d/init.crs start
startup will be queued to init within 90 seconds.

由于oracle所有应用设置为自动启动, 所以在crs启动时会试图启动所有的服务, 但是在对oracle相关的ip地址进行设置时需要crs处于运行状态而数据库, asm和node application处于停止状态, 所以需要我们参考1.2, 1.3, 1.4的内容关闭数据库, asm和node application.

3.2 使用oifcfg修改网卡设置, oifconfig可以被用来设置和查看网卡被oracle使用的方式

rac2:/u01/app/oracle/product/10.2.0/crs/bin#
 
./oifcfg getif -global

eth0  192.168.0.0  global  public

eth1  10.10.10.0  global  cluster_interconnect

rac2:/u01/app/oracle/product/10.2.0/crs/bin# 

./oifcfg setif -global eth0/192.168.1.0:public

rac2:/u01/app/oracle/product/10.2.0/crs/bin# ./oifcfg iflist

eth0  192.168.1.0

eth0  192.168.0.0

eth1  10.1.0.0

rac2:/u01/app/oracle/product/10.2.0/crs/bin#
 
./oifcfg delif -global eth0/192.168.0.0

rac2:/u01/app/oracle/product/10.2.0/crs/bin# ./oifcfg iflist

eth0  192.168.1.0
eth1  10.1.0.0
rac2:/u01/app/oracle/product/10.2.0/crs/bin# ./oifcfg getif -global

eth0  192.168.1.0  global  public

eth1  10.10.10.0  global  cluster_interconnect

rac2:/u01/app/oracle/product/10.2.0/crs/bin# ./lifcfg setif -global

eth1:/10.1.0.0:cluster_interconnect

-bash: ./lifcfg: no such file or directory

rac2:/u01/app/oracle/product/10.2.0/crs/bin# ./oifcfg setif -global 

eth1:/10.1.0.0:cluster_interconnect

rac2:/u01/app/oracle/product/10.2.0/crs/bin# ./oifcfg getif -global

eth0  192.168.1.0  global  public

eth1  10.10.10.0  global  cluster_interconnect

eth1:  10.1.0.0  global  cluster_interconnect

rac2:/u01/app/oracle/product/10.2.0/crs/bin# ./oifcfg setif -global

eth1/10.1.0.0:cluster_interconnect

rac2:/u01/app/oracle/product/10.2.0/crs/bin# ./oifcfg getif -global

eth0  192.168.1.0  global  public

eth1  10.10.10.0  global  cluster_interconnect

eth1  10.1.0.0  global  cluster_interconnect

eth1:  10.1.0.0  global  cluster_interconnect

rac2:/u01/app/oracle/product/10.2.0/crs/bin#
 
./oifcfg delif -global eth1:

rac2:/u01/app/oracle/product/10.2.0/crs/bin# 

./oifcfg delif -global eth1/10.10.10.0

rac2:/u01/app/oracle/product/10.2.0/crs/bin#
 
./oifcfg getif -global

eth0  192.168.1.0  global  public

eth1  10.1.0.0  global  cluster_interconnect

oifcfg iflist会显示当前使用的网卡及其子网设置, 而oifcfg getif -global 则会显示配置文件中的信息。

3.3 修改vip地址

rac2:/u01/app/oracle/product/10.2.0/crs/bin# 
./srvctl modify nodeapps -n rac1 -a

192.168.1.191/255.255.255.0/eth0

rac2:/u01/app/oracle/product/10.2.0/crs/bin# 
./srvctl modify nodeapps -n rac2 -a 

192.168.1.192/255.255.255.0/eth0

3.4 设置listener.ora和tnsnames.ora, 检查这些文件中是否有指定原来ip的地方, 修改为更改后的ip地址, 在rac1的配置文件中listener.ora包含了 192.168.0.181我修改成了192.168.1.181, rac2上的listener.ora也做了相应的修改。

3.5 启动node applications, asm, 数据库

rac2:/u01/app/oracle/product/10.2.0/crs/bin# ./srvctl start nodeapps -n rac1
rac2:/u01/app/oracle/product/10.2.0/crs/bin# ./srvctl start nodeapps -n rac2
rac2:/u01/app/oracle/product/10.2.0/crs/bin# ./srvctl start asm -n rac2
rac2:/u01/app/oracle/product/10.2.0/crs/bin# ./srvctl start asm -n rac1
rac2:/u01/app/oracle/product/10.2.0/crs/bin#
rac2:/u01/app/oracle/product/10.2.0/crs/bin# ./srvctl start database -d orcl

3.6 来看看我们的成果:

rac2:/u01/app/oracle/product/10.2.0/crs/bin# ifconfig -a
eth0      link encap:ethernet  hwaddr 00:0c:29:0d:fe:0f
inet addr:192.168.1.182  bcast:192.168.1.255  mask:255.255.255.0
up broadcast running multicast  mtu:1500  metric:1
rx packets:142242 errors:0 dropped:0 overruns:0 frame:0
tx packets:140057 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
rx bytes:83167889 (79.3 mib)  tx bytes:87987399 (83.9 mib)
interrupt:19 base address:0x1480

eth0:1    link encap:ethernet  hwaddr 00:0c:29:0d:fe:0f
inet addr:192.168.1.192  bcast:192.168.1.255  mask:255.255.255.0
up broadcast running multicast  mtu:1500  metric:1
interrupt:19 base address:0x1480

eth1      link encap:ethernet  hwaddr 00:0c:29:0d:fe:19
inet addr:10.1.0.182  bcast:10.1.0.255  mask:255.255.255.0
up broadcast running multicast  mtu:1500  metric:1
rx packets:29781 errors:0 dropped:0 overruns:0 frame:0
tx packets:26710 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
rx bytes:19667330 (18.7 mib)  tx bytes:11573375 (11.0 mib)
interrupt:16 base address:0x1800

lo        link encap:local loopback
inet addr:127.0.0.1  mask:255.0.0.0
up loopback running  mtu:16436  metric:1
rx packets:21796 errors:0 dropped:0 overruns:0 frame:0
tx packets:21796 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
rx bytes:6238339 (5.9 mib)  tx bytes:6238339 (5.9 mib)

rac2:/u01/app/oracle/product/10.2.0/crs/bin# ./crs_stat
name=ora.orcl.db
type=application
target=online
state=online on rac1

name=ora.orcl.orcl1.inst
type=application
target=online
state=online on rac1

name=ora.orcl.orcl2.inst
type=application
target=online
state=online on rac2

name=ora.rac1.asm1.asm
type=application
target=online
state=online on rac1

name=ora.rac1.listener_rac1.lsnr
type=application
target=online
state=online on rac1

name=ora.rac1.gsd
type=application
target=online
state=online on rac1

name=ora.rac1.ons
type=application
target=online
state=online on rac1

name=ora.rac1.vip
type=application
target=online
state=online on rac1

name=ora.rac2.asm2.asm
type=application
target=online
state=online on rac2

name=ora.rac2.listener_rac2.lsnr
type=application
target=online
state=online on rac2

name=ora.rac2.gsd
type=application
target=online
state=online on rac2

name=ora.rac2.ons
type=application
target=online
state=online on rac2

name=ora.rac2.vip
type=application
target=online
state=online on rac2

rac2:/u01/app/oracle/product/10.2.0/crs/bin# su - oracle
oracle@rac2:~$ lsnrctl stat

lsnrctl for linux: version 10.2.0.1.0 - production on 23-aug-2006 23:23:47

copyright (c) 1991, 2005, oracle.  all rights reserved.

connecting to (address=(protocol=tcp)(host=)(port=1521))
status of the listener
------------------------
alias                     listener_rac2
version                   tnslsnr for linux: version 10.2.0.1.0 - production
start date                23-aug-2006 22:24:44
uptime                    0 days 0 hr. 59 min. 3 sec
trace level               off
security                  on: local os authentication
snmp                      off
listener parameter file   
/u01/app/oracle/product/10.2.0/db_1/network/admin/listener.ora
listener log file  
/u01/app/oracle/product/10.2.0/db_1/network/log/listener_rac2.log
listening endpoints summary...
  (description=(address=(protocol=tcp)(host=192.168.1.192)(port=1521)))
  (description=(address=(protocol=tcp)(host=192.168.1.182)(port=1521)))
services summary...
service "+asm" has 1 instance(s).
  instance "+asm2", status blocked, has 1 handler(s) for this service...
service "+asm_xpt" has 1 instance(s).
  instance "+asm2", status blocked, has 1 handler(s) for this service...
service "plsextproc" has 1 instance(s).
  instance "plsextproc", status unknown, has 1 handler(s) for this service...
service "orcl" has 2 instance(s).
  instance "orcl1", status ready, has 1 handler(s) for this service...
  instance "orcl2", status ready, has 2 handler(s) for this service...
service "orclxdb" has 2 instance(s).
  instance "orcl1", status ready, has 1 handler(s) for this service...
  instance "orcl2", status ready, has 1 handler(s) for this service...
service "orcl_xpt" has 2 instance(s).
  instance "orcl1", status ready, has 1 handler(s) for this service...
  instance "orcl2", status ready, has 2 handler(s) for this service...
the command completed successfully

上面的操作大部分使用root进行, 实时上, 使用svrctl进行的操作也可以使用root用户完,当然也可以使用oracle用户完成, 而修改vip则必须使用root用户完成,最后我们可以使用crs_stat -ls查看各个资源的所有者, 属组, 以及相关的权限。

扫描关注微信公众号