-------------------------------------------------------------
Bond设置
[root@raca network-scripts]# more ifcfg-bond0
DEVICE=bond0
BOOTPROTO=static
BROADCAST=172.16.14.111
ONBOOT=yes
IPADDR=172.16.14.111
GATEWAY=172.16.14.254
NETMASK=255.255.255.0
TYPE=Ethernet
USERCTL=no
[root@raca network-scripts]# more ifcfg-eth0
# Intel Corporation 82545EM Gigabit Ethernet Controller (Copper)
DEVICE=eth0
#HWADDR=00:50:56:B0:00:26
ONBOOT=yes
SLAVE=yes
MASTER=bond0
USERCTL=no
[root@raca network-scripts]# more ifcfg-eth1
# Intel Corporation 82545EM Gigabit Ethernet Controller (Copper)
DEVICE=eth1
#HWADDR=00:50:56:B0:00:3E
ONBOOT=yes
SLAVE=yes
MASTER=bond0
USERCTL=no
设置
[root@raca etc]# more modprobe.conf
alias eth0 e1000
alias eth1 e1000
alias eth2 e1000
alias eth3 e1000
alias eth4 e1000
alias eth5 e1000
alias scsi_hostadapter mptbase
alias scsi_hostadapter1 mptspi
alias scsi_hostadapter2 ata_piix
alias bond0 bonding
options bond0 miimon=100 mode=1 max_bonds=2
alias bond1 bonding
options bond0 miimon=100 mode=1 max_bonds=2
先删除以前建立的一些资源
删除application vip
/oracle/app/grid/product/11.2.0/bin/appvipcfg delete -vipname=scantwo2
/oracle/app/grid/product/11.2.0/bin/appvipcfg delete -vipname=scantwo1
/oracle/app/grid/product/11.2.0/bin/appvipcfg delete -vipname=scantwo3
删除建立的VIP listener
/oracle/app/grid/product/11.2.0/bin/srvctl stop listener -l LISTENER2
/oracle/app/grid/product/11.2.0/bin/srvctl remove listener -l LISTENER2
删除第二套 VIP
[root@raca ~]# /oracle/app/grid/product/11.2.0/bin/srvctl stop vip -i rac1vip
[root@raca ~]# /oracle/app/grid/product/11.2.0/bin/srvctl stop vip -i rac2vip
[root@raca ~]# /oracle/app/grid/product/11.2.0/bin/srvctl stop vip -i rac3vip
[root@raca ~]# /oracle/app/grid/product/11.2.0/bin/srvctl remove vip -i rac3vip
Please confirm that you intend to remove the VIPs rac3vip (y/[n]) y
[root@raca ~]# /oracle/app/grid/product/11.2.0/bin/srvctl remove vip -i rac2vip
Please confirm that you intend to remove the VIPs rac2vip (y/[n]) y
[root@raca ~]# /oracle/app/grid/product/11.2.0/bin/srvctl remove vip -i rac1vip
Please confirm that you intend to remove the VIPs rac1vip (y/[n]) y
PRKO-2383 : Network 2 is not removed successfully:
PRCR-1025 : Resource ora.net2.network is still running
删除底层的NETWORK资源
[root@raca ~]# /oracle/app/grid/product/11.2.0/bin/crsctl stop res ora.net2.network
CRS-2673: Attempting to stop 'ora.net2.network' on 'raca'
CRS-2673: Attempting to stop 'ora.net2.network' on 'racc'
CRS-2673: Attempting to stop 'ora.net2.network' on 'racb'
CRS-2677: Stop of 'ora.net2.network' on 'racc' succeeded
CRS-2677: Stop of 'ora.net2.network' on 'raca' succeeded
CRS-2677: Stop of 'ora.net2.network' on 'racb' succeeded
[root@raca ~]# /oracle/app/grid/product/11.2.0/bin/srvctl remove network -k 2
这样就删除了我们建立的资源
------------------------------------------------------------------------------------------------------------
正文这里开始
目标完成双网段连接,我这里设置了bond0 为正常安装的172.16.14.0网段,完成后设置bond1为172.16.1.0,初步构想网段1通过DNS解析SCAN来完成连接,网段2通过VIP来完成,如果同时想设置两套SCAN在一个集群里面,官方也表明SCAN在一套RAC里面只能有一个,但是老熊也给出一些变通的解决方法,但是貌似没有官方文档支持,比较危险,但是最后还会进行测试
参考
How to Configure A Second Listener on a Separate Network in 11.2 Grid Infrastructure [ID 1063571.1]
http://www.laoxiong.net/add-new-public-network-on-11gr2-grid-infrastructure.html#more-938
----------------------------------------------------------------------------------------------------------------------
正常安装完rac后
1、 增加新的NETWORK
/oracle/app/grid/product/11.2.0/bin/srvctl add network -k 2 -S 172.16.1.0/255.255.255.0/bond1
启动network
[root@raca ~]# /oracle/app/grid/product/11.2.0/bin/crsctl start res ora.net2.network
CRS-2672: Attempting to start 'ora.net2.network' on 'racb'
CRS-2672: Attempting to start 'ora.net2.network' on 'raca'
CRS-2672: Attempting to start 'ora.net2.network' on 'racc'
CRS-2676: Start of 'ora.net2.network' on 'raca' succeeded
CRS-2676: Start of 'ora.net2.network' on 'racb' succeeded
CRS-2676: Start of 'ora.net2.network' on 'racc' succeeded
查看
[root@racc ~]# /oracle/app/grid/product/11.2.0/bin/srvctl config network
Network exists: 1/172.16.14.0/255.255.255.0/bond0, type static
Network exists: 2/172.16.1.0/255.255.255.0/bond1, type static
2、 增加VIP
为各个节点增加VIP
srvctl add vip -n raca -k 2 -A rac1vip/255.255.255.0/bond1
srvctl add vip –n racb –k 2 –A rac2vip/255.255.255.0/bond1
srvctl add vip –n racc –k 2 –A rac3vip/255.255.255.0/bond1
(我这里犯了一个错把实际IP的加入为虚拟IP不管怎么都remove不了,如
srvctl add vip -n raca -k 2 -A 172.16.1.111/255.255.255.0/bond1
stop也不行,修改也不行最后只有disable 掉这个VIP 然后再remove才成功了)
(修改VIP
关闭VIP后
# srvctl modify nodeapps -n -A //
eg:
# srvctl modify nodeapps -n racnode1 -A racnode1-nvip/255.255.255.0/eth2
srvctl modify nodeapps –n raca –A racavip/255.255.255.0/bond0
)
然后启动
/oracle/app/grid/product/11.2.0/bin/srvctl start vip –n raca
/oracle/app/grid/product/11.2.0/bin/srvctl start vip –n racb
/oracle/app/grid/product/11.2.0/bin/srvctl start vip –n racc
这里我们测试一下新加入的VIP是否能够漂移,我们手动down掉bond1
然后查看
ora.rac1vip.vip
1 ONLINE ONLINE raca
ora.rac2vip.vip
1 ONLINE ONLINE racb
ora.rac3vip.vip
1 ONLINE INTERMEDIATE racb FAILED OVER
明显已经FAILEDOVER
重新UP bond网卡发现VIP已经起来
ora.raca.vip
1 ONLINE ONLINE raca
ora.racb.vip
1 ONLINE ONLINE racb
ora.racc.vip
1 ONLINE ONLINE racc
3、增加VIP listener
/oracle/app/grid/product/11.2.0/bin/srvctl add listener -l LISTENER2 -s -p 1521 -k 2 这里应该使用GRID用户进行添加,我使用root导致LISTENR2的属主是ROOT用户
启动
[root@raca ~]# /oracle/app/grid/product/11.2.0/bin/crsctl start res ora.LISTENER2.lsnr
CRS-2672: Attempting to start 'ora.LISTENER2.lsnr' on 'racc'
CRS-2672: Attempting to start 'ora.LISTENER2.lsnr' on 'racb'
CRS-2672: Attempting to start 'ora.LISTENER2.lsnr' on 'raca'
CRS-2676: Start of 'ora.LISTENER2.lsnr' on 'racb' succeeded
CRS-2676: Start of 'ora.LISTENER2.lsnr' on 'racc' succeeded
CRS-2676: Start of 'ora.LISTENER2.lsnr' on 'raca' succeeded
4、 如果我们采用SCAN+VIP的方式,也就是网段172.16.14.0使用SCAN连接,而网段172.16.1.0使用VIP LISTENER连接如何设置?
设置每个节点TNSNAME.ORA
raca:
listener_net1 =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 172.16.14.114)(PORT = 1521))
)
listener_net2 =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 172.16.1.114)(PORT = 1521))
)
remote_net2 =
(DESCRIPTION_LIST =
(DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = 172.16.1.114)(PORT = 1521)))
(DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = 172.16.1.115)(PORT = 1521)))
(DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = 172.16.1.116)(PORT = 1521)))
)
racb:
listener_net1 =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 172.16.14.115)(PORT = 1521))
)
listener_net2 =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 172.16.1.115)(PORT = 1521))
)
remote_net2 =
(DESCRIPTION_LIST =
(DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = 172.16.1.114)(PORT = 1521)))
(DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = 172.16.1.115)(PORT = 1521)))
(DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = 172.16.1.116)(PORT = 1521)))
)
racc:
listener_net1 =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 172.16.14.116)(PORT = 1521))
)
listener_net2 =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 172.16.1.116)(PORT = 1521))
)
remote_net2 =
(DESCRIPTION_LIST =
(DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = 172.16.1.114)(PORT = 1521)))
(DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = 172.16.1.115)(PORT = 1521)))
(DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = 172.16.1.116)(PORT = 1521)))
)
然后
alter system set LISTENER_NETWORKS='((NAME=network1)(LOCAL_LISTENER=listener_net1)(REMOTE_LISTENER=scanone.gaopp.com:1521))','((NAME=network2)(LOCAL_LISTENER=listener_net2)(REMOTE_LISTENER=remote_net2))';
最后我们看到新建立的LISTENER2也有了相应的注册信息
LSNRCTL> set current_listener LISTENER2
Current Listener is LISTENER2
LSNRCTL> status
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=LISTENER2)))
STATUS of the LISTENER
------------------------
Alias LISTENER2
Version TNSLSNR for Linux: Version 11.2.0.3.0 - Production
Start Date 27-FEB-2013 21:25:54
Uptime 0 days 1 hr. 47 min. 31 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener Parameter File /oracle/app/grid/product/11.2.0/network/admin/listener.ora
Listener Log File /oracle/app/grid/product/11.2.0/log/diag/tnslsnr/racb/listener2/alert/log.xml
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=LISTENER2)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=172.16.1.115)(PORT=1521)))
Services Summary...
Service "racdb" has 3 instance(s).
Instance "racdb1", status READY, has 1 handler(s) for this service...
Instance "racdb2", status READY, has 2 handler(s) for this service...
Instance "racdb3", status READY, has 1 handler(s) for this service...
The command completed successfully
没有问题测试连接我们需要通过如下的方式设置
RACpub2 =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 172.16.1.114)(PORT = 1521))
(ADDRESS = (PROTOCOL = TCP)(HOST = 172.16.1.115)(PORT = 1521))
(ADDRESS = (PROTOCOL = TCP)(HOST = 172.16.1.116)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = racdb)
)
)
RACpub1 =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = scanone.gaopp.com)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = racdb)
)
)
这样不仅实现了双网段的问题,而且解决了服务端负载均衡的问题。
接下来测试下是否在RACA 关闭的情况下连接成功。
可以看到
ora.LISTENER.lsnr
ONLINE ONLINE racb
ONLINE ONLINE racc
ora.LISTENER2.lsnr
ONLINE ONLINE racb
ONLINE ONLINE racc
已经没有RACA了
ora.rac1vip.vip
1 ONLINE INTERMEDIATE racc FAILED OVER
ora.rac2vip.vip
1 ONLINE ONLINE racb
ora.rac3vip.vip
1 ONLINE ONLINE racc
ora.raca.vip
1 ONLINE INTERMEDIATE racc FAILED OVER
ora.racb.vip
1 ONLINE ONLINE racb
ora.racc.vip
1 ONLINE ONLINE racc
Vip都进行了漂移。
同时SCAN VIP也进行了漂移同时SCAN LISTENER也在另外的节点启动了。连接没有问题。个人觉得这种方式是RAC双网段设置最好的方式。
5、 其实需求已经满足了,接下来来完成一个并不推荐的做法,就是做第二套SCAN VIP LISTENER这里不建议直接用
crsctl add resource ora.n2_scan1.vip -type ora.scan_vip.type -file /tmp/1.txt 这样老熊说的第二种方法,因为我这样做了,安装集群数据库软件的时候报错
[grid@racb ~]$ srvctl config scan
SCAN name: scanone.gaopp.com, Network: 1/172.16.14.0/255.255.255.0/bond0
SCAN VIP name: scan1, IP: /scanone.gaopp.com/172.16.14.99
SCAN VIP name: scan2, IP: /scanone.gaopp.com/172.16.14.97
SCAN VIP name: scan3, IP: /scanone.gaopp.com/172.16.14.98
而且这里如果使用这种方式增加scan name会变为你新的SCAN NAME,下面会有6个IP。(我这里是DNS解析所有SCAN IP是3个)
而我们试着用application vip 试试。
因为我使用DNS 看了appvipcfg的语法并没有何DNS相关的语法,只有一个IP一个ip的加吧
我这里可以看看我的第2套解析的ip
[grid@racb ~]$ nslookup scantwo.gaopp.com
Server: 172.16.14.70
Address: 172.16.14.70#53
Name: scantwo.gaopp.com
Address: 172.16.1.98
Name: scantwo.gaopp.com
Address: 172.16.1.99
Name: scantwo.gaopp.com
Address: 172.16.1.97
使用的方法如下:
appvipcfg create -network=2 -ip=172.16.1.97 -vipname=scanapp1 -user=root -failback=1
appvipcfg create -network=2 -ip=172.16.1.98 -vipname=scanapp2 -user=root -failback=1
appvipcfg create -network=2 -ip=172.16.1.99 -vipname=scanapp3 -user=root -failback=1
这里为了均匀分布还需要设置
crsctl modify resource "scanapp1" -attr "PLACEMENT=favored"
crsctl modify resource "scanapp1" -attr "HOSTING_MEMBERS=raca"
crsctl modify resource "scanapp2" -attr "PLACEMENT=favored"
crsctl modify resource "scanapp2" -attr "HOSTING_MEMBERS=racb"
crsctl modify resource "scanapp3" -attr "PLACEMENT=favored"
crsctl modify resource "scanapp3" -attr "HOSTING_MEMBERS=racc"
然后启动
crsctl start res scanapp1
crsctl start res scanapp2
crsctl start res scanapp3
最后看到我们的新的所谓的SCAN2 VIP已经均匀分布
scanapp1
1 ONLINE ONLINE raca
scanapp2
1 ONLINE ONLINE racb
scanapp3
1 ONLINE ONLINE racc
可以看看新建立的application vip的切换行为,我们DOWN RACA。
ora.scan1.vip
1 ONLINE ONLINE racb
ora.scan2.vip
1 ONLINE ONLINE racc
ora.scan3.vip
1 ONLINE ONLINE racb
scanapp1
1 ONLINE ONLINE racc
scanapp2
1 ONLINE ONLINE racb
scanapp3
1 ONLINE ONLINE racc
可以看到真正的scan Vip 切换到了RACB,而我们建立的APP VIP,切换到了RACC为什么切换的服务器不同这里有一个原理因为我们设置的是favored,所以当HOST_MEMBERS没有设置多个服务器的时候主服务器DOWN掉的情况下会随意漂移。
favored: If values are assigned to either the SERVER_POOLS or HOSTING_
MEMBERS resource attribute, then Oracle Clusterware considers servers belonging
to the member list in either attribute first. If no servers are available, then Oracle
Clusterware places the resource on any other available server. If there are values
for both the SERVER_POOLS and HOSTING_MEMBERS attributes, then the
SERVER_POOLS attribute restricts the choices to the servers within the preference
indicated by the value of HOSTING_MEMBERS.
启动后
ora.scan1.vip ora....ip.type ONLINE ONLINE raca
ora.scan2.vip ora....ip.type ONLINE ONLINE racc
ora.scan3.vip ora....ip.type ONLINE ONLINE racb
scanapp1 app....t2.type ONLINE ONLINE raca
scanapp2 app....t2.type ONLINE ONLINE racb
scanapp3 app....t2.type ONLINE ONLINE racc
正常漂移回来了。所以这样的SCANAPP VIP是没有问题的。但是建立LISTENER是否有问题,继续吧。
然后我们使用老熊的方法建立3个SCAN listener 试试。
crsctl stat res ora.LISTENER_SCAN1.lsnr -p > /tmp/2.txt
然后修改必要的属性,这里每个配置都要修改
NAME=ora.LISTENER_SCANAPP1.lsnr ----修改
TYPE=ora.scan_listener.type
ACL=owner:grid:rwx,pgrp:oinstall:r-x,other::r--
ACTION_FAILURE_TEMPLATE=
ACTION_SCRIPT=
ACTIVE_PLACEMENT=1
AGENT_FILENAME=%CRS_HOME%/bin/oraagent%CRS_EXE_SUFFIX%
AUTO_START=restore
CARDINALITY=1
CHECK_INTERVAL=60
CHECK_TIMEOUT=30
DEFAULT_TEMPLATE=PROPERTY(RESOURCE_CLASS=scan_listener) PROPERTY(LISTENER_NAME=PARSE(%NAME%, ., 2))
DEGREE=1
DESCRIPTION=Oracle SCAN listener resource use appvip ---修改
ENABLED=1
ENDPOINTS=TCP:1521
FAILOVER_DELAY=0
FAILURE_INTERVAL=0
FAILURE_THRESHOLD=0
HOSTING_MEMBERS=
LOAD=1
LOGGING_LEVEL=1
NLS_LANG=
NOT_RESTARTING_TEMPLATE=
OFFLINE_CHECK_INTERVAL=0
PLACEMENT=balanced
PORT=1521
PROFILE_CHANGE_TEMPLATE=
RESTART_ATTEMPTS=5
SCRIPT_TIMEOUT=60
SERVER_POOLS=*
START_DEPENDENCIES=hard(scanapp1) dispersion:active(type:ora.scan_listener.type) pullup(scanapp1) ---修改
START_TIMEOUT=180
STATE_CHANGE_TEMPLATE=
STOP_DEPENDENCIES=hard(intermediate: scanapp1) ---修改
STOP_TIMEOUT=0
TYPE_VERSION=1.2
UPTIME_THRESHOLD=1d
USR_ORA_ENV=
USR_ORA_OPI=false
VERSION=11.2.0.3.0
然后依次增加
crsctl add resource ora.LISTENER_SCANAPP1.lsnr -type ora.scan_listener.type -file /tmp/1.txt
crsctl add resource ora.LISTENER_SCANAPP2.lsnr -type ora.scan_listener.type -file /tmp/2.txt
crsctl add resource ora.LISTENER_SCANAPP3.lsnr -type ora.scan_listener.type -file /tmp/3.txt
这里看到实际我们添加的LISTENER还是SCAN_LISTENER
[grid@racb ~]$ srvctl config scan_listener
SCAN Listener LISTENER_SCAN1 exists. Port: TCP:1521
SCAN Listener LISTENER_SCAN2 exists. Port: TCP:1521
SCAN Listener LISTENER_SCAN3 exists. Port: TCP:1521
SCAN Listener LISTENER_SCANAPP1 exists. Port: TCP:1521
SCAN Listener LISTENER_SCANAPP2 exists. Port: TCP:1521
SCAN Listener LISTENER_SCANAPP3 exists. Port: TCP:1521
但是app VIP是不会出现在SCAN VIP中的
[grid@racb ~]$ srvctl config scan
SCAN name: scanone.gaopp.com, Network: 1/172.16.14.0/255.255.255.0/bond0
SCAN VIP name: scan1, IP: /scanone.gaopp.com/172.16.14.99
SCAN VIP name: scan2, IP: /scanone.gaopp.com/172.16.14.97
SCAN VIP name: scan3, IP: /scanone.gaopp.com/172.16.14.98
接着我们启动listener
[grid@racb ~]$ crsctl start res ora.scan_listener.type
CRS-2613: Could not find resource 'ora.scan_listener.type'.
CRS-4000: Command Start failed, or completed with errors.
[grid@racb ~]$ crsctl start res ora.LISTENER_SCANAPP1.lsnr
CRS-2672: Attempting to start 'ora.LISTENER_SCANAPP1.lsnr' on 'raca'
CRS-2676: Start of 'ora.LISTENER_SCANAPP1.lsnr' on 'raca' succeeded
[grid@racb ~]$ crsctl start res ora.LISTENER_SCANAPP2.lsnr
CRS-2672: Attempting to start 'ora.LISTENER_SCANAPP2.lsnr' on 'racb'
CRS-2676: Start of 'ora.LISTENER_SCANAPP2.lsnr' on 'racb' succeeded
[grid@racb ~]$ crsctl start res ora.LISTENER_SCANAPP3.lsnr
CRS-2672: Attempting to start 'ora.LISTENER_SCANAPP3.lsnr' on 'racc'
CRS-2676: Start of 'ora.LISTENER_SCANAPP3.lsnr' on 'racc' succeeded
然后查看状态确实是均匀分布的,因为他们基于application vip。
ora.LISTENER_SCANAPP1.lsnr
1 ONLINE ONLINE raca
ora.LISTENER_SCANAPP2.lsnr
1 ONLINE ONLINE racb
ora.LISTENER_SCANAPP3.lsnr
1 ONLINE ONLINE racc
看起来一切还算顺利,接下来我们考虑如何注册我们服务上去。
在这里我发现不能动态注册我们的979899 当相应的APPLICATION vip LISTENER
为了解决这个问题,我在三节点的GRID用户下的LISTENER 文件都加入了如下,也可以通过NETMGR进行设置:
LISTENER_SCANAPP3 =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = IPC)(KEY = LISTENER_SCANAPP3))
)
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 172.16.1.99)(PORT = 1521))
)
)
LISTENER_SCANAPP2 =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = IPC)(KEY = LISTENER_SCANAPP2))
)
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 172.16.1.98)(PORT = 1521))
)
)
LISTENER_SCANAPP1 =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = IPC)(KEY = LISTENER_SCANAPP1))
)
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 172.16.1.97)(PORT = 1521))
)
)
同样考虑这样设置我们tnsnames.ora
raca
listener_net1 =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 172.16.14.114)(PORT = 1521))
)
listener_net2 =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 172.16.1.114)(PORT = 1521))
)
remote_net2 =
(DESCRIPTION_LIST =
(DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = 172.16.1.97)(PORT = 1521)))
(DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = 172.16.1.98)(PORT = 1521)))
(DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = 172.16.1.99)(PORT = 1521)))
)
Racb
listener_net1 =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 172.16.14.115)(PORT = 1521))
)
listener_net2 =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 172.16.1.115)(PORT = 1521))
)
remote_net2 =
(DESCRIPTION_LIST =
(DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = 172.16.1.97)(PORT = 1521)))
(DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = 172.16.1.98)(PORT = 1521)))
(DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = 172.16.1.99)(PORT = 1521)))
)
Racc
listener_net1 =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 172.16.14.116)(PORT = 1521))
)
listener_net2 =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 172.16.1.116)(PORT = 1521))
)
remote_net2 =
(DESCRIPTION_LIST =
(DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = 172.16.1.97)(PORT = 1521)))
(DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = 172.16.1.98)(PORT = 1521)))
(DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = 172.16.1.99)(PORT = 1521)))
)
设置
alter system set LISTENER_NETWORKS='((NAME=network1)(LOCAL_LISTENER=listener_net1)(REMOTE_LISTENER=scanone.gaopp.com:1521))','((NAME=network2)(LOCAL_LISTENER=listener_net2)(REMOTE_LISTENER=remote_net2))'
scope=both sid=’*’;
最终如下:
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=LISTENER_SCANAPP3)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=172.16.1.99)(PORT=1521)))
Services Summary...
Service "racdb" has 3 instance(s).
Instance "racdb1", status READY, has 1 handler(s) for this service...
Instance "racdb2", status READY, has 1 handler(s) for this service...
Instance "racdb3", status READY, has 1 handler(s) for this service...
The command completed successfully
测试连接,我们这里设置了DNS解析scantwo.gaopp.com,能解析为3个97 98 99的IP
最终实现了连接公有网络1 172.16.14.0网段通过SCAN,连接公有网段2 172.16.1.0使用SCAN(不是真的是APP VIP)和VIP(当然这里也就没有服务器端负载均衡了)的连接。
RACSCAN2 =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = scantwo.gaopp.com)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = racdb)
)
)
RACVIP2 =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 172.16.1.114)(PORT = 1521))
(ADDRESS = (PROTOCOL = TCP)(HOST = 172.16.1.115)(PORT = 1521))
(ADDRESS = (PROTOCOL = TCP)(HOST = 172.16.1.116)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = racdb)
)
)
RACSAN1 =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = scanone.gaopp.com)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = racdb)
)
)
没有问题。测试下关闭RACA节点,连接是否还正常。
关节节点后发现APPLICATION VIP 进行了漂移,同时承载的SCANAPP LISTENER也进行了漂移。连接没有问题。
ora.LISTENER_SCANAPP1.lsnr
1 ONLINE ONLINE racc
ora.LISTENER_SCANAPP2.lsnr
1 ONLINE ONLINE racb
ora.LISTENER_SCANAPP3.lsnr
1 ONLINE ONLINE racc
scanapp1
1 ONLINE ONLINE racc
scanapp2
1 ONLINE ONLINE racb
scanapp3
1 ONLINE ONLINE racc
最后说一下这样的设置实际没有官方文档的支持,可行是可行,但是其复杂的配置和未知的错误都是一个问题,配置过后资源极多,管理起来非常麻烦容易晕,所以连接第二个网段还是用VIP的方式实现更好,也很方便。
6、 最后有一个问题正常SCAN是通过SCAN 进行负载均衡然后进行LOCAL listener,也就是说一旦LOCAL listener出现问题。这个节点是进入不了的。这里我关闭了2个节点剩下了一个节点。我们来测试APP SCAN是否也是这样。
停止本地监听
[root@racc ~]# /oracle/app/grid/product/11.2.0/bin/srvctl stop listener -l LISTENER2
测试
C:\Users\Administrator>sqlplus sys/gelc123@ractest2 as sysdba
SQL*Plus: Release 11.2.0.3.0 Production on 星期四 2月 28 13:00:42 2013
Copyright (c) 1982, 2011, Oracle. All rights reserved.
ERROR:
ORA-12516: TNS: 监听程序找不到符合协议堆栈要求的可用处理程序
这里报错和真正的SCAN LISTENER是一致的
实际APPLICATION SCAN LISTENER,其实还在
ora.LISTENER_SCANAPP1.lsnr
1 ONLINE ONLINE racc
ora.LISTENER_SCANAPP2.lsnr
1 ONLINE ONLINE racc
ora.LISTENER_SCANAPP3.lsnr
1 ONLINE ONLINE racc
所以他的行为和真正的SCAN LISTENER是一致的,没有问题。
《这里说明一下,为什么SCAN LISTENER 能够在其他的服务器上启动,可能和
dispersion:active(type:ora.scan_listener.type)有关,同样SCAN VIP,APPLICATION VIP也有同样的设置。
相关描述:
Use the active modifier to configure the dispersion dependency so that
Oracle Clusterware attempts to relocate the dependent resource to another
server if it is co-located with another resource and another server comes
online. Oracle Clusterware does not relocate resources to newly available
servers unless you specify the active modifier.
》