oracle 11g rac TAF 測試方案

sky_dizzy001發表於2014-02-11

1 系統環境描述
主機環境:
主機名 IP地址
SCDB1 192.168.1.100
SCDB2 192.168.1.102
作業系統版本 AIX 6100-04

2 資料庫資訊
資料庫庫版本 Oracle11.2.0.1 RAC
資料庫名 SCDB
例項名 SCDB1 SCDB2
監聽埠 1521

3 RAC節點配置資訊
主機名    CPU     記憶體              IP                       IP別名 
SCDB1     4        16384 MB     192.168.1.100      public 
                                           192.168.1.101     virtual 
                                           172.16.18.1         private
SCDB2     4        16384 MB     192.168.1.102     public 
                                           192.168.1.103    virtual 
                                           172.16.18.2        private
SCAN                                   192.168.1.104      SCDB-cluster-scan

4 測試目的
    Oracle RAC 透過它的故障切換機制提供了一個卓越的解決方案,當叢集中的某個節點出現故障時,使用者將被自動移植到其他可用節點,透明應用程式故障切換 (TAF) 是 Oracle RAC 一個負責處理故障切換的主要功能。所有斷開的資料庫連線(和程式)將被重新連線到叢集的其他節點上,故障切換對使用者是完全透明的。為驗證該功能,在納服整合平臺使用情況,現做出如下測試。

5 測試過程
需要新增如下資訊到客戶端機器:
修改C:\WINDOWS\system32\drivers\etc\hosts ,新增地址解析 
192.168.1.101 SCDB1-vip
192.168.1.103 SCDB2-vip
192.168.1.104 SCDB-cluster-scan

6 測試
6.1使用scanip連線方式
SCDB =
(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.1.104)(PORT=1521))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=SCDB)))

6.2使用VIP連線
例項shutdown時,連線會中斷 
SCDB_VIP =
(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.1.101)(PORT=1521))(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.1.103)(PORT=1521))(LOAD_BALANCE=yes)(CONNET_DATA=(SERVER = DEDICATED)(SERVICE_NAME = SCDB) ) )

6.3使用TAF方式連線
例項shutdown時,連線會自動轉到另一個例項 
SCDB_TAF =
(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.1.101)(PORT=1521))(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.1.103)(PORT=1521))(LOAD_BALANCE=yes)(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=SCDB)(FAILOVER_MODE=(TYPE=SELECT)(METHOD = BASIC)(RETRIES = 180)(DELAY = 5)
) ) )

6.4 使用首選例項方式連線
預設情況下連線到首選例項,當首選例項shutdown時,連線會自動轉到另一個例項
SCDB1 =
(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.1.101)(PORT=1521))(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.1.103)(PORT=1521))(LOAD_BALANC=YES)(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=SCDB1)(FAILOVER_MODE=(TYPE=SELECT)(METHOD= BASIC)(RETRIES = 180)(DELAY = 5) ) ) )
注:服務 SCDB1 的首選例項是 SCDB1

6.5 應用伺服器JDBC Data Sources配置資訊 
jdbc:oracle:thin:@(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.1.101)(PORT=1521))(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.1.103)(PORT=1521))(LOAD_BALANCE=YES)(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=SCDB)(FAILOVER_MODE=(TYPE=SELECT)(METHOD=BASIC)(RETRIES=180)(DELAY=5))))
注意:如果你準備shutdown 某一個instance,那麼必須要先停止該例項的service,然後再shutdown instance,否則service的首選例項會漂移至另一個節點,這種情況下即使instance重新startup,service也不會自動漂移回原先設定的首選例項,需要手工回切service的首選例項。注:重啟database也可以使service恢復成預設狀態。 
假設服務SCDB的首選例項漂移到SCDB2,回切到SCDB1的方法如下 :
srvctl relocate service -d SCDB -s SCDB -i SCDB2 -t SCDB1
Oracle的RAC的高可用功能除了負載均衡還包括TAF,是指會話連線到一個例項上,如果這個例項出現了故障,Oracle會自動將會話遷移到另一個例項上。

7 首先不配置TAF,進行例項級的故障測試
在客戶端TNSNAMES.ORA中進行如下的配置進行測試
TESTRAC = 
(DESCRIPTION = 
(ADDRESS = (PROTOCOL = TCP)(HOST =192.168.1.101)(PORT = 1521)) 
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.103)(PORT = 1521))(CONNECT_DATA = 
(SERVER = DEDICATED) 
(SERVICE_NAME = SCDB) 

)
例項級故障轉移測試:
conn / as sysdba
select instance_name from v$instance;
關閉SCDB1例項
Srvctl stop instance –d SCDB –i SCDB1
conn / as sysdba
select instance_name from v$instance;---檢視連線例項
ORA-03114: 未連線到 ORALCE
Srvctl start instance –d SCDB –i SCDB1

8 配置TAF進行測試
在客戶端TNSNAMES.ORA中進行如下的測試:
TESTRAC = 
(DESCRIPTION = 
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.101)(PORT = 1521))
 (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.103)(PORT = 1521))
 (CONNECT_DATA =
 (SERVER = DEDICATED)
(SERVICE_NAME = SCDB) 
FAILOVER_MODE =
(TYPE = SELECT) 
(METHOD = BASIC)
(RETRIES=180)
(DELAY=5)
)



TESTRAC = 
(DESCRIPTION = 
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.101)(PORT = 1521))
 (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.103)(PORT = 1521))
 (CONNECT_DATA =
 (SERVER = DEDICATED)
(SERVICE_NAME = SCDB) 
(FAILOVER_MODE =
 (TYPE = SESSION) 
(METHOD = BASIC)
(RETRIES=180)
(DELAY=5)
)


注:SESSION和SELECT的區別,配置了SELECT選項的FAILOVER在資料庫例項失敗時,會將會話切換到另一個例項,且將例項失敗時執行的SELECT語句繼續執行,並返回正確的結果。而SESSION則不具備這個功能。
檢查例項資訊,進行例項級測試
Select instance_name,status from gv$instance;
再次分別停掉例項SCDB1或SCDB2進行驗證:
Srvctl stop instance –d SCDB –i SCDB1
Select instance_name from v$instance;
Srvctl start instance –d SCDB –i SCDB1
Srvctl stop instance –d SCDB –i SCDB2
Select instance_name from v$instance;
至此,資料庫例項級的FAILOVER測試完成。

8.1下一步進行session級的FAILOVER測試過程
TESTRAC = 
(DESCRIPTION = 
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.101)(PORT = 1521)) 
 (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.103)(PORT = 1521)) 
 (CONNECT_DATA = 
 (SERVER = DEDICATED) 
 (SERVICE_NAME = SCDB) 
(FAILOVER_MODE = 
 (TYPE = SESSION) 
(METHOD = BASIC)
(RETRIES=180)
(DELAY=5) 
)
)
)
先看看FAILOVER設定為SESSION的情況:
SELECT INSTANCE_NAME FROM V$INSTANCE;
任意查詢一個表
SET PAUSE ON  -----開啟暫停
SELECT TRIGGER_NAME FROM DBA_TRIGGERS;
關閉當前會話連線的例項
Srvctl stop instance –d SCDB –i SCDB1
返回剛才執行SQL視窗,按回車繼續
Error:ORA-25401:無法繼續讀取
下面測試一下FAILOVER設定為SELECT的情況
TESTRAC = 
(DESCRIPTION = 
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.101)(PORT = 1521)) 
 (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.103)(PORT = 1521)) 
 (CONNECT_DATA = 
 (SERVER = DEDICATED) 
 (SERVICE_NAME = SCDB) 
(FAILOVER_MODE = 
 (TYPE = SELECT) 
(METHOD = BASIC)
(RETRIES=180)
(DELAY=5) 
)


Srvctl start instance –d SCDB –i SCDB1
SET PAUSE ON -----開啟暫停
SELECT INSTANCE_NAME FROM V$INSTANCE;
SELECT TRIGGER_NAME FROM DBA_TRIGGERS;
關閉當前會話連線的例項
Srvctl stop instance –d SCDB –i SCDB1
返回剛才執行SQL視窗,按回車繼續
-----能繼續執行當前的select並顯示結果
SELECT INSTANCE_NAME FROM V$INSTANCE;
不但將會話切換到了正常的例項上,而且SELECT也得到了完整的結果,沒有因例項故障而出現錯誤。這就是FAILOVER的SESSION和SELECT設定的區別。

至此,TAF測試完畢。

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

相關文章