ORACLE RAC TAF 配置(透明故障轉移)

startay發表於2015-12-15
--ORACLE RAC TAF 配置(透明故障轉移)

TAF(Transparent Application Failover)即透明應用程式故障轉移技術。當初始化連線出現問題無法連線時,該功能可以保證應用程式重新連線到可用服務。在重新連線過程中,之前的活動事務將會被回滾,但在“具體條件”下TAF可以保證SELECT語句不被終止。這也是RAC亮點之一。

所謂的“具體條件”指的就是FAILOVER_MODE中METHOD選擇“BASIC”、TYPE選擇“SELECT”


TAF的特性:

1:TAF是ORACLE客戶端提供的一項特性,使用TAF,對客戶端的環境有一定的要求,比如JAVA的JDBC驅動、Oracle客戶端的版本等(8i開始支援TAF);
2:大致上TAF可以分為2種,連線時的TAF和會話建立後TAF;
3:TAF本身與是否RAC環境無關,但一般都用在RAC環境,最小程度的減少最應用的影響,單例項環境下也可以使用TAF,這樣使用PL/SQL developer連線資料庫,即使資料庫例項重啟,也不需要重新連線;
4:RAC環境下,還可以把TAF配置在伺服器端;
5:配置listener.ora檔案的GLOBAL_DBNAME引數後將會禁用TAF


檢視當前service

  1. col name format a24
  2. col failover_method format a11 heading 'METHOD'
  3. col failover_type format a10 heading 'TYPE'
  4. col failover_retries format 9999999 heading 'RETRIES'
  5. col goal format a10
  6. col clb_goal format a8
  7. col AQ_HA_NOTIFICATIONS format a5 heading 'AQNOT'
  8. select name, failover_method,failover_type, failover_retries,goal, clb_goal,aq_ha_notifications from dba_services;ORACLE RAC TAF 配置(透明故障轉移)


1. 客戶端TAF配置

  1. vi tnsnames.ora
  2. NODE =
  3.   (DESCRIPTION =
  4.     (ADDRESS_LIST =
  5.       (ADDRESS = (PROTOCOL = TCP)(HOST = rac-scan.yang.com)(PORT = 1521))
  6.     )
  7.     (CONNECT_DATA =
  8.       (SERVICE_NAME = rac.yang.com)
  9.       (FAILOVER_MODE =
  10.        (TYPE = SELECT)
  11.        (METHOD = BASIC)
  12.        (RETRIES = 180)
  13.        (DELAY = 5))
  14.     )
  15.   )

  16. SELECT MACHINE, FAILOVER_TYPE, FAILOVER_METHOD, FAILED_OVER FROM V$SESSION WHERE SID=141; 
  17. MACHINE TYPE METHOD FAI 
    -------------------- ---------- ----------- --- 
    tay SELECT BASIC NO

2. 伺服器端TAF配置



2.1新增taf服務
srvctl add service -d cnposqa -s cnposqa_taf -r "cnposqa1,cnposqa2" -P BASIC

    -e        Failover type (NONE, SESSION, or SELECT)
    -m      Failover method (NONE or BASIC)
    srvctl add service -d cnposqa -s cnposqa_taftt -r "cnposqa1,cnposqa2" -e select -m basic -P BASIC


2.2啟動服務

srvctl start service -d cnposqa -s cnposqa_taf

2.3檢查服務情況
> srvctl config service -d cnposqa -s cnposqa_taf
Service name: cnposqa_taf
Service is enabled
Server pool: cnposqa_cnposqa_taf
Cardinality: 2
Disconnect: false
Service role: PRIMARY
Management policy: AUTOMATIC
DTP transaction: false
AQ HA notifications: false
Failover type: NONE
Failover method: NONE
TAF failover retries: 0
TAF failover delay: 0
Connection Load Balancing Goal: LONG
Runtime Load Balancing Goal: NONE
TAF policy specification: BASIC
Edition:
Preferred instances: cnposqa1,cnposqa2
Available instances:

2.3 給service新增引數(basic,select):

execute dbms_service.modify_service (service_name => 'cnposqa_taf' -
, aq_ha_notifications => true -
, failover_method => dbms_service.failover_method_basic -
, failover_type => dbms_service.failover_type_select -
, failover_retries => 180 -
, failover_delay => 5 -
, clb_goal => dbms_service.clb_goal_long);

 

++單邊服務新增

--cnposqa_taf2單邊服務,主節點cnposqa2, 副節點cnposqa1   (-r Preferred  , -a Available )
srvctl add service -d cnposqa -s cnposqa_taf2 -r "cnposqa2" -a "cnposqa1" -P BASIC

config service -d cnposqa -s cnposqa_taf2
Service name: cnposqa_taf2
Service is enabled
Server pool: cnposqa_cnposqa_taf2
Cardinality: 1
Disconnect: false
Service role: PRIMARY
Management policy: AUTOMATIC
DTP transaction: false
AQ HA notifications: false
Failover type: NONE
Failover method: NONE
TAF failover retries: 0
TAF failover delay: 0
Connection Load Balancing Goal: LONG
Runtime Load Balancing Goal: NONE
TAF policy specification: BASIC
Edition:
Preferred instances: cnposqa2
Available instances: cnposqa1

切換測試

--停服務
stop service -d cnposqa -s cnposqa_taf2 
--服務啟動到instance 1
start service -d cnposqa -s cnposqa_taf2 -i cnposqa1

 

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

相關文章