Oracle RAC Failove 之三:Server-Side TAF

Jujay發表於2011-11-15
1.定義
上一篇介紹的TAF是Client-Side,配置在客戶端的tnsname.ora檔案,如果有很多客戶端,將不利於維護,容易出錯,而這裡介紹的Server-Side TAF結合Service,把所有的TAF配置都儲存在資料字典中,這樣客戶端就無須再做配置了。
2.Service
1)建立一個新的service:
srvctl add service -d O01RCD0 -s taf_test -r O01RCD0A -a O01RCD0B  -P basic
2)檢視service是否建立成功:
srvctl config service -d O01RCD0 -s taf_test -a
3)啟動該服務:
srvctl start service -d O01RCD0 -s taf_test
4)在資料庫上修改Service的TAF配置
begin
 dbms_service.modify_service(
 service_name=>'taf_test',
 failover_method=>dbms_service.failover_method_basic,
 failover_type=>dbms_service.failover_type_select,
 failover_retries=>180,
 failover_delay=>5
 );
 end;
 /

PL/SQL procedure successfully completed.
5) 確認新Service已在資料字典裡存在
A105024@O01RCD0>select NAME,FAILOVER_METHOD,FAILOVER_TYPE,FAILOVER_DELAY from dba_services where NAME='taf_test';

NAME                 FAILOVER_METHOD FAILOVER_TYPE   FAILOVER_DELAY
-------------------- --------------- --------------- --------------
taf_test             BASIC           SELECT                       5

3.Listener的配置
我們需要新建一個listener監聽該service:
TNS_TAF_TEST =
  (DESCRIPTION_LIST =
    (DESCRIPTION =
      (ADDRESS = (PROTOCOL = TCP)(HOST = drcdd0ra)(PORT = 1521))
    )
  )

SID_LIST_TNS_TAF_TEST =
  (SID_LIST =
    (SID_DESC =
      (SID_NAME = taf_test)
      (ORACLE_HOME = /usr/local/oracle/10.2.0-64)
    )
  )


4.客戶端配置
客戶端配置很簡單,只要配置成通過service連線資料庫即可。
編輯tnsnames.ora檔案如下:
O01RCD0 =
  (DESCRIPTION =
    (failover = on)
        (enable = broken)
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(HOST = drcdd0ra)(PORT = 1521))
      (ADDRESS = (PROTOCOL = TCP)(HOST = drcdd0rb)(PORT = 1521))
      (LOAD_BALANCE = yes)
    )
    (CONNECT_DATA =
      (SERVICE_NAME = taf_test)
      )
    )
  )

4.測試
測試環境:兩節點的RAC (O01RCD0A,O01RCD0B)
連線資料庫,檢視連線到哪個例項:
A105024@O01RCD0>select INSTANCE_NAME,status from v$instance;

INSTANCE_NAME    STATUS
---------------- ------------
O01RCD0A         OPEN

3)在服務端kill掉相應的服務程式以擬例項故障
查出使用者對應的OS服務程式id:
A105024@O01RCD0>select PID,SPID from v$process where ADDR in (select PADDR from v$session where username='A105024');

       PID SPID
---------- ------------
        43 28563
在OS上殺掉該程式:
kill -9 28563
4)稍等幾秒,再次執行語句,發現已經自動切換到了B節點
A105024@O01RCD0>select INSTANCE_NAME,status from v$instance;

A105024@O01RCD0>select INSTANCE_NAME,status from v$instance;

INSTANCE_NAME    STATUS
---------------- ------------
O01RCD0B         OPEN






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

相關文章