RAC 11GR3雙網段設定兩套VIP SCAN IP以及LISTENER

gaopengtttt發表於2013-02-27
-------------------------------------------------------------
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]

----------------------------------------------------------------------------------------------------------------------
正常安裝完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  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.

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

相關文章