REMOTE_LISTENER對靜態FAILOVER的影響

yangtingkun發表於2010-11-11

前一篇介紹了靜態FAILOVER的特性,這裡介紹REMOTE_LISTENER引數對於靜態FAILOVER的影響。

靜態FAILOVERhttp://yangtingkun.itpub.net/post/468/508327

 

 

上一篇中測試是在REMOTE_LISTENER引數為空的情況下進行的,這一篇設定REMOTE_LISTENER引數。

測試環境為10.2.0.4 Rac for Solaris for sparc 64

SQL> SELECT * FROM V$VERSION;

BANNER
----------------------------------------------------------------
Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bi
PL/SQL Release 10.2.0.4.0 - Production
CORE    10.2.0.4.0      Production
TNS for Solaris: Version 10.2.0.4.0 - Production
NLSRTL Version 10.2.0.4.0 - Production

SQL> SELECT NAME FROM V$DATABASE;

NAME
---------
TESTRAC

SQL> SELECT INSTANCE_NUMBER, INSTANCE_NAME FROM GV$INSTANCE;

INSTANCE_NUMBER INSTANCE_NAME
--------------- ----------------
              1 testrac1
              2 testrac2

設定REMOTE_LISTENER引數:

SQL> ALTER SYSTEM SET REMOTE_LISTENER = 'LISTENERS_TESTRAC' SCOPE = BOTH;

系統已更改。

SQL> SELECT INSTANCE_NAME FROM V$INSTANCE;

INSTANCE_NAME
----------------
testrac1

SQL> SHOW PARAMETER REMOTE_LISTENER

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
remote_listener                      string      LISTENERS_TESTRAC

檢查例項2

SQL> SELECT INSTANCE_NAME FROM V$INSTANCE;

INSTANCE_NAME
----------------
testrac2

SQL> SHOW PARAMETER REMOTE_LISTENER

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
remote_listener                      string      LISTENERS_TESTRAC

資料庫伺服器上兩個節點的TNSNAMESLISTENERS_TESTRAC的配置均為:

LISTENERS_TESTRAC =
  (ADDRESS_LIST =
    (ADDRESS = (PROTOCOL = TCP)(HOST = racnode1-vip)(PORT = 1521))
    (ADDRESS = (PROTOCOL = TCP)(HOST = racnode2-vip)(PORT = 1521))
  )

下面測試一下靜態FAILOVER,本地服務名配置如下:

TESTRAC =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(HOST = 172.25.198.224)(PORT = 1521))
      (ADDRESS = (PROTOCOL = TCP)(HOST = 172.25.198.225)(PORT = 1521))
      (FAILOVER = ON)
    )
    (CONNECT_DATA =
      (SERVICE_NAME = TESTRAC)
    )
  )

測試連線:

SQL> CONN YANGTK/YANGTK@TESTRAC
已連線。
SQL> SELECT INSTANCE_NAME FROM V$INSTANCE;

INSTANCE_NAME
----------------
testrac1

SQL> DISC
Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bit Production
With the Partitioning, Real Application Clusters, OLAP, Data Mining
and Real Application Testing options
斷開

下面關閉例項1

bash-2.03$ srvctl stop inst -d testrac -i testrac1

測試連線:

SQL> CONN YANGTK/YANGTK@TESTRAC
已連線。
SQL> SELECT INSTANCE_NAME FROM V$INSTANCE;

INSTANCE_NAME
----------------
testrac2

SQL> CONN YANGTK/YANGTK@TESTRAC
已連線。
SQL> SELECT INSTANCE_NAME FROM V$INSTANCE;

INSTANCE_NAME
----------------
testrac2

下面將本地服務名中配置的FAILOVER引數設定為OFF

TESTRAC =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(HOST = 172.25.198.224)(PORT = 1521))
      (ADDRESS = (PROTOCOL = TCP)(HOST = 172.25.198.225)(PORT = 1521))
      (FAILOVER = OFF)
    )
    (CONNECT_DATA =
      (SERVICE_NAME = TESTRAC)
    )
  )

再次測試連線:

SQL> CONN YANGTK/YANGTK@TESTRAC
已連線。
SQL> SELECT INSTANCE_NAME FROM V$INSTANCE;

INSTANCE_NAME
----------------
testrac2

SQL> CONN YANGTK/YANGTK@TESTRAC
已連線。
SQL> SELECT INSTANCE_NAME FROM V$INSTANCE;

INSTANCE_NAME
----------------
testrac2

靜態FAILOVER仍然有效,下面去掉服務名中配置的例項2的地址:

TESTRAC =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(HOST = 172.25.198.224)(PORT = 1521))
      (FAILOVER = OFF)
    )
    (CONNECT_DATA =
      (SERVICE_NAME = TESTRAC)
    )
  )

測試連線:

SQL> CONN YANGTK/YANGTK@TESTRAC
已連線。
SQL> SELECT INSTANCE_NAME FROM V$INSTANCE;

INSTANCE_NAME
----------------
testrac2

SQL> CONN YANGTK/YANGTK@TESTRAC
已連線。
SQL> SELECT INSTANCE_NAME FROM V$INSTANCE;

INSTANCE_NAME
----------------
testrac2

顯然REMOTE_LISTENER引數設定後,覆蓋了本地TNSNAMES.ORA的配置,靜態FAILOVER自動生效。

 

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

相關文章