【TAF】使用Oracle RAC的TAF技術實現不間斷查詢
TAF(Transparent Application Failover)即透明應用程式故障轉移技術。當初始化連線出現問題無法連線時,該功能可以保證應用程式重新連線到可用服務。在重新連線過程中,之前的活動事務將會被回滾,但在“具體條件”下TAF可以保證SELECT語句不被終止。這也是RAC亮點之一。
本文給出使用Oracle RAC的TAF技術實現不間斷查詢。
1.在tnsnames.ora檔案中新增測試連線串
RACDB1@rac1 /home/oracle$ vi $ORACLE_HOME/network/admin/tnsnames.ora
testractaf =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = rac1-vip)(PORT = 1521))
(ADDRESS = (PROTOCOL = TCP)(HOST = rac2-vip)(PORT = 1521))
(LOAD_BALANCE = yes)
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = RACDB)
(FAILOVER_MODE =
(TYPE = SELECT)
(METHOD = BASIC)
(RETRIES = 180)
(DELAY = 5)
)
)
)
所謂的“具體條件”指的就是FAILOVER_MODE中METHOD選擇“BASIC”、TYPE選擇“SELECT”。
2.使用testractaf連線串連線到資料庫
RACDB1@rac1 /home/oracle$ sqlplus sec/sec@testractaf
SQL*Plus: Release 10.2.0.1.0 - Production on Sun Oct 24 19:21:35 2010
Copyright (c) 1982, 2005, Oracle. All rights reserved.
Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, Real Application Clusters, OLAP and Data Mining options
SQL> select instance_name from v$instance;
INSTANCE_NAME
----------------
RACDB1
可見,此時sqlplus連線到了RAC的第一個例項RACDB1上。
3.手工停止RACDB1例項
[root@rac2 ~]# srvctl stop instance -d RACDB -i RACDB1
4.重新確認查詢語句所在例項
SQL> select instance_name from v$instance;
INSTANCE_NAME
----------------
RACDB2
注意觀察,此時的查詢語句沒有報出任何錯誤。結果表明,此時sqlplus已經順利的連線到了RAC的第二個例項RACDB2上。
5.恢復例項RACDB1,繼續
[root@rac2 ~]# srvctl start instance -d RACDB -i RACDB1
SQL> select instance_name from v$instance;
INSTANCE_NAME
----------------
RACDB2
6.此處我們模擬一個長時間無法返回全部資訊的查詢語句
SQL> select * from all_objects a,all_objects b,all_objects c where a.object_id=b.object_id and a.object_id=c.object_id;
…… 此處省略輸出資訊 ……
7.手工停止RACDB2例項
[root@rac2 ~]# crs_stat -t
Name Type Target State Host
------------------------------------------------------------
ora....B1.inst application ONLINE ONLINE rac1
ora....B2.inst application ONLINE ONLINE rac2
ora.RACDB.db application ONLINE ONLINE rac2
ora....DB1.srv application ONLINE ONLINE rac1
ora....DB2.srv application ONLINE ONLINE rac2
ora.....taf.cs application ONLINE ONLINE rac1
ora....SM1.asm application ONLINE ONLINE rac1
ora....C1.lsnr application ONLINE ONLINE rac1
ora.rac1.gsd application ONLINE ONLINE rac1
ora.rac1.ons application ONLINE ONLINE rac1
ora.rac1.vip application ONLINE ONLINE rac1
ora....SM2.asm application ONLINE ONLINE rac2
ora....C2.lsnr application ONLINE ONLINE rac2
ora.rac2.gsd application ONLINE ONLINE rac2
ora.rac2.ons application ONLINE ONLINE rac2
ora.rac2.vip application ONLINE ONLINE rac2
[root@rac2 ~]# srvctl stop instance -d RACDB -i RACDB2
[root@rac2 ~]# crs_stat -t
Name Type Target State Host
------------------------------------------------------------
ora....B1.inst application ONLINE ONLINE rac1
ora....B2.inst application OFFLINE OFFLINE
ora.RACDB.db application ONLINE ONLINE rac2
ora....DB1.srv application ONLINE ONLINE rac1
ora....DB2.srv application ONLINE OFFLINE
ora.....taf.cs application ONLINE ONLINE rac1
ora....SM1.asm application ONLINE ONLINE rac1
ora....C1.lsnr application ONLINE ONLINE rac1
ora.rac1.gsd application ONLINE ONLINE rac1
ora.rac1.ons application ONLINE ONLINE rac1
ora.rac1.vip application ONLINE ONLINE rac1
ora....SM2.asm application ONLINE ONLINE rac2
ora....C2.lsnr application ONLINE ONLINE rac2
ora.rac2.gsd application ONLINE ONLINE rac2
ora.rac2.ons application ONLINE ONLINE rac2
ora.rac2.vip application ONLINE ONLINE rac2
8.結論
注意觀察sqlplus視窗中不間斷的結果輸出,在RACDB2例項中斷過程中,可以看到輸出結果在短暫的停頓後重新恢復輸出,沒有報錯。這便是TAF帶給我們的技術特性。
在手工“Ctrl + C”取消螢幕輸出後可以觀察到此時sqlplus已經連線到RACDB1例項。
SQL> select instance_name from v$instance;
INSTANCE_NAME
----------------
RACDB1
9.小結
本文給出了在FAILOVER_MODE中METHOD選擇“BASIC”、TYPE選擇“SELECT”時,使用Oracle的TAF技術在RAC環境下實現SELECT語句不間斷輸出的例子。在實際應用中可以考慮使用該技術,保證查詢語句不因例項故障而中斷。
Good luck.
secooler
10.10.24
-- The End --
本文給出使用Oracle RAC的TAF技術實現不間斷查詢。
1.在tnsnames.ora檔案中新增測試連線串
RACDB1@rac1 /home/oracle$ vi $ORACLE_HOME/network/admin/tnsnames.ora
testractaf =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = rac1-vip)(PORT = 1521))
(ADDRESS = (PROTOCOL = TCP)(HOST = rac2-vip)(PORT = 1521))
(LOAD_BALANCE = yes)
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = RACDB)
(FAILOVER_MODE =
(TYPE = SELECT)
(METHOD = BASIC)
(RETRIES = 180)
(DELAY = 5)
)
)
)
所謂的“具體條件”指的就是FAILOVER_MODE中METHOD選擇“BASIC”、TYPE選擇“SELECT”。
2.使用testractaf連線串連線到資料庫
RACDB1@rac1 /home/oracle$ sqlplus sec/sec@testractaf
SQL*Plus: Release 10.2.0.1.0 - Production on Sun Oct 24 19:21:35 2010
Copyright (c) 1982, 2005, Oracle. All rights reserved.
Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, Real Application Clusters, OLAP and Data Mining options
SQL> select instance_name from v$instance;
INSTANCE_NAME
----------------
RACDB1
可見,此時sqlplus連線到了RAC的第一個例項RACDB1上。
3.手工停止RACDB1例項
[root@rac2 ~]# srvctl stop instance -d RACDB -i RACDB1
4.重新確認查詢語句所在例項
SQL> select instance_name from v$instance;
INSTANCE_NAME
----------------
RACDB2
注意觀察,此時的查詢語句沒有報出任何錯誤。結果表明,此時sqlplus已經順利的連線到了RAC的第二個例項RACDB2上。
5.恢復例項RACDB1,繼續
[root@rac2 ~]# srvctl start instance -d RACDB -i RACDB1
SQL> select instance_name from v$instance;
INSTANCE_NAME
----------------
RACDB2
6.此處我們模擬一個長時間無法返回全部資訊的查詢語句
SQL> select * from all_objects a,all_objects b,all_objects c where a.object_id=b.object_id and a.object_id=c.object_id;
…… 此處省略輸出資訊 ……
7.手工停止RACDB2例項
[root@rac2 ~]# crs_stat -t
Name Type Target State Host
------------------------------------------------------------
ora....B1.inst application ONLINE ONLINE rac1
ora....B2.inst application ONLINE ONLINE rac2
ora.RACDB.db application ONLINE ONLINE rac2
ora....DB1.srv application ONLINE ONLINE rac1
ora....DB2.srv application ONLINE ONLINE rac2
ora.....taf.cs application ONLINE ONLINE rac1
ora....SM1.asm application ONLINE ONLINE rac1
ora....C1.lsnr application ONLINE ONLINE rac1
ora.rac1.gsd application ONLINE ONLINE rac1
ora.rac1.ons application ONLINE ONLINE rac1
ora.rac1.vip application ONLINE ONLINE rac1
ora....SM2.asm application ONLINE ONLINE rac2
ora....C2.lsnr application ONLINE ONLINE rac2
ora.rac2.gsd application ONLINE ONLINE rac2
ora.rac2.ons application ONLINE ONLINE rac2
ora.rac2.vip application ONLINE ONLINE rac2
[root@rac2 ~]# srvctl stop instance -d RACDB -i RACDB2
[root@rac2 ~]# crs_stat -t
Name Type Target State Host
------------------------------------------------------------
ora....B1.inst application ONLINE ONLINE rac1
ora....B2.inst application OFFLINE OFFLINE
ora.RACDB.db application ONLINE ONLINE rac2
ora....DB1.srv application ONLINE ONLINE rac1
ora....DB2.srv application ONLINE OFFLINE
ora.....taf.cs application ONLINE ONLINE rac1
ora....SM1.asm application ONLINE ONLINE rac1
ora....C1.lsnr application ONLINE ONLINE rac1
ora.rac1.gsd application ONLINE ONLINE rac1
ora.rac1.ons application ONLINE ONLINE rac1
ora.rac1.vip application ONLINE ONLINE rac1
ora....SM2.asm application ONLINE ONLINE rac2
ora....C2.lsnr application ONLINE ONLINE rac2
ora.rac2.gsd application ONLINE ONLINE rac2
ora.rac2.ons application ONLINE ONLINE rac2
ora.rac2.vip application ONLINE ONLINE rac2
8.結論
注意觀察sqlplus視窗中不間斷的結果輸出,在RACDB2例項中斷過程中,可以看到輸出結果在短暫的停頓後重新恢復輸出,沒有報錯。這便是TAF帶給我們的技術特性。
在手工“Ctrl + C”取消螢幕輸出後可以觀察到此時sqlplus已經連線到RACDB1例項。
SQL> select instance_name from v$instance;
INSTANCE_NAME
----------------
RACDB1
9.小結
本文給出了在FAILOVER_MODE中METHOD選擇“BASIC”、TYPE選擇“SELECT”時,使用Oracle的TAF技術在RAC環境下實現SELECT語句不間斷輸出的例子。在實際應用中可以考慮使用該技術,保證查詢語句不因例項故障而中斷。
Good luck.
secooler
10.10.24
-- The End --
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/28389881/viewspace-1251071/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- 【TAF】使用Oracle RAC的TAF技術之SESSION型別OracleSession型別
- Oracle RAC TAF [zt]Oracle
- Oracle 10g RAC TAFOracle 10g
- Oracle RAC的TAF簡單測試Oracle
- Oracle RAC TAF 無縫failoverOracleAI
- Oracle RAC Failove 之二:TAFOracleAI
- ORACLE RAC TAF 配置(透明故障轉移)Oracle
- Oracle 10g RAC TAF介紹Oracle 10g
- Jdbc thin not suppot Rac TAFJDBC
- oracle 11g rac TAF 測試方案Oracle
- oracle的TAF淺析Oracle
- Linux平臺上Oracle Rac中的TAF配置LinuxOracle
- 在JDBC連線池中啟動Oracle RAC的TAFJDBCOracle
- [轉載]Oracle 10g RAC TAF介紹Oracle 10g
- rac 的Client-side TAF配置clientIDE
- RAC TAF 連線 (tnsnames.ora)
- Oracle RAC Failove 之三:Server-Side TAFOracleAIServerIDE
- Oracle RAC 客戶端故障轉移(failover) TAFOracle客戶端AI
- 靈活實現RAC三節點的負載均衡及TAF配置(五)負載
- 靈活實現RAC三節點的負載均衡及TAF配置(二)負載
- 靈活實現RAC三節點的負載均衡及TAF配置(一)負載
- 靈活實現RAC三節點的負載均衡及TAF配置(四)負載
- 靈活實現RAC三節點的負載均衡及TAF配置(三)負載
- TNSNAMES TAF TEMPLATE , LOCAL_LISTENER RAC FAILOVERAI
- Oracle 11gR2 RAC Service-Side TAF 配置示例OracleIDE
- 【RAC】RAC中的負載均衡和故障切換--TAF配置負載
- Oracle LOAD_BALANCE&TAF總結Oracle
- oracle10g rac(rhel4)_load balancing_taf(一)Oracle
- oracle10g rac(rhel4)_load balancing_taf(二)Oracle
- oracle10g rac(rhel4)_load balancing_taf(三)Oracle
- oracle10g rac(rhel4)_load balancing_taf(四)Oracle
- 11gr2 RAC配置Service-Side TAFIDE
- Oracle Failover - TAF 透明應用切換OracleAI
- Service-side TAFIDE
- Android AlarmManager實現不間斷輪詢服務Android
- oracle taf unknown 問題處理過程Oracle
- excel查詢資料的技術實現選擇Excel
- oracle taf type型別為session和select的區別Oracle型別Session