Oracle RAC 客戶端故障轉移(failover) TAF
Oracle RAC
客戶端故障轉移(failover),當採用TAF方式時,對於已經建立連線的客戶端,在連線的例項或節點出現故障時,客戶端無需再次發出連線請求,仍然
可以繼續之前的資料庫操作,此稱之為透明故障轉移。本文描述基於Oracle 10g rac,客戶端TAF方式的故障轉移並給出示例。
下面是一些關於這方面的基礎參考連結:
有關負監聽配置,載均衡(load balance)以及Oracle service請參考
ORACLE RAC 監聽配置 (listener.ora tnsnames.ora)
ORACLE RAC 下非預設埠監聽配置(listener.ora tnsnames.ora)
Oracle RAC 客戶端連線負載均衡(Load Balance)
Oracle RAC 伺服器端連線負載均衡(Load Balance)
Oracle RAC 負載均衡測試(結合伺服器端與客戶端)
有關Oracle RAC failover 連線時故障轉移請參考
Oracle RAC failover 測試(連線時故障轉移)
Oracle RAC failover 測試(Server TAF方式)
- 1、TAF描述
- #下面關於TAF來自Oracle 的官方描述 ID 453293.1
- Transparent Application Failover (TAF) is a feature of the Oracle Call Interface (OCI) driver at client side.
- It enables the application to automatically reconnect to a database, if the database instance to which the connection is
- made fails. In this case, the active transactions roll back.
- Tnsnames Parameter: FAILOVER_MODE
- When an instance to which a connection is established fails or is shutdown, the connection on the client side becomes
- stale and would throw exceptions to the caller trying to use it. TAF enables the application to transparently reconnect
- to a preconfigured secondary instance creating a fresh connection, but identical to the connection that was established
- on the first original instance.
- #簡單一點來說,就是說對於那些已經成功連線到特定例項的客戶端,如果該例項或節點異常當機,客戶端會自動重新發出到剩餘例項的連
- #接請求。使得客戶端感覺不到它所連線的例項或節點已經出現故障,這個就稱之為透明轉移。但其間的活動事務將被回滾。
- #透過在客戶端的tnsnames.ora中配置FAILOVER_MODE項實現TAF
- 2、伺服器端、客戶端的環境
- #伺服器端環境,host資訊
- oracle@bo2dbp:~> cat /etc/hosts |grep vip
- 192.168.7.61 bo2dbp-vip.2gotrade.com bo2dbp-vip
- 192.168.7.62 bo2dbs-vip.2gotrade.com bo2dbs-vip
- #伺服器端環境,叢集資訊
- oracle@bo2dbp:~> ./crs_stat.sh
- Resource name Target State
- -------------- ------ -----
- ora.GOBO4.GOBO4A.inst OFFLINE OFFLINE on bo2dbp #此時節點1上的例項被關閉
- ora.GOBO4.GOBO4B.inst ONLINE ONLINE on bo2dbs
- ora.GOBO4.db ONLINE ONLINE on bo2dbp
- ora.bo2dbp.ASM1.asm ONLINE ONLINE on bo2dbp
- ora.bo2dbp.LISTENER_BO2DBP.lsnr ONLINE ONLINE on bo2dbp
- ora.bo2dbp.LISTENER_ORA10G_BO2DBP.lsnr ONLINE ONLINE on bo2dbp
- ora.bo2dbp.gsd ONLINE ONLINE on bo2dbp
- ora.bo2dbp.ons ONLINE ONLINE on bo2dbp
- ora.bo2dbp.vip ONLINE ONLINE on bo2dbp
- ora.bo2dbs.ASM2.asm ONLINE ONLINE on bo2dbs
- ora.bo2dbs.LISTENER_BO2DBS.lsnr ONLINE ONLINE on bo2dbs
- ora.bo2dbs.LISTENER_ORA10G_BO2DBS.lsnr ONLINE ONLINE on bo2dbs
- ora.bo2dbs.gsd ONLINE ONLINE on bo2dbs
- ora.bo2dbs.ons ONLINE ONLINE on bo2dbs
- ora.bo2dbs.vip ONLINE ONLINE on bo2dbs
- ora.ora10g.db ONLINE ONLINE on bo2dbp
- #客戶端環境
- robin@SZDB:~> cat /etc/issue
- Welcome to SUSE Linux Enterprise Server 10 SP3 (x86_64) - Kernel \r (\l).
- robin@SZDB:~> sqlplus -v
- SQL*Plus: Release 10.2.0.3.0 - Production
- #客戶端tnsnames配置
- GOBO4_TAF =
- (DESCRIPTION =
- (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.7.61)(PORT = 1521))
- (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.7.62)(PORT = 1521))
- (LOAD_BALANCE = yes)
- (CONNECT_DATA =
- (SERVER = DEDICATED)
- (SERVICE_NAME = GOBO4)
- (FAILOVER_MODE = #FAILOVER_MODE項引數
- (TYPE = session)
- (METHOD = basic)
- (RETRIES = 180
- (DELAY = 5)
- )
- )
- )
- 3、FAILOVER_MODE項分析
- FAILOVER_MODE項是實現TAF的主要配置內容,下面對其進行描述.
- METHOD: 使用者定義何時建立到其例項的連線,有BASIC 和 PRECONNECT 兩種可選值
- BASIC: 客戶端透過地址列表成功建立連線後,即僅當客戶端感知到節點故障時才建立到其他例項的連線
- PRECONNECT: 預連線模式,是在最初建立連線時就同時建立到所有例項的連線,當發生故障時,立刻就可以切換到其他鏈路上
- 上述兩種方式各有優劣,前者建立連線的開銷相對較小,但failover時會產生延遲,而後者正好與前者相反
- TYPE: 用於定義發生故障時對完成的SQL 語句如何處理,其中有2種型別:session 和select
- select:使用select方式,Oracle net會跟蹤事務期間的所有select語句,並跟蹤每一個與當前select相關的遊標已返回多少行給客戶
- 端。此時,假定select查詢已返回500行,客戶端當前連線的節點出現故障,Oracle Net自動建立連線到倖存的例項上並繼續返回
- 剩餘的行數給客戶端。假定總行數為1500,行,則1000行從剩餘節點返回。
-
session: 使用session方式,所有select查詢相關的結果在重新建立新的連線後將全部丟失,需要重新發布select命令。
-
Failover Type Events
The following are possible failover types in the OracleOCI Failover interface:
-
FO_SESSION
Is equivalent to FAILOVER_MODE=SESSION in the tnsnames.ora file CONNECT_DATA flags. This means that only the user session is re-authenticated on the server-side while open cursors in the OCI application need to be re-executed.
-
FO_SELECT
Is equivalent to FAILOVER_MODE=SELECT in tnsnames.ora file CONNECT_DATA flags. This means that not only the user session is re-authenticated on the server-side, but open cursors in the OCI can continue fetching. This implies that the client-side logic maintains fetch-state of each open cursor.
-
FO_NONE
Is equivalent to FAILOVER_MODE=NONE in the tnsnames.ora file CONNECT_DATA flags. This is the default, in which no failover functionality is used. This can also be explicitly specified to prevent failover from happening. Additionally, FO_TYPE_UNKNOWN implies that a bad failover type was returned from the OCI driver
-
FO_SESSION
- 上述兩種方式適用於不同的情形,對於select方式,通常使用與OLAP資料庫,而對於session方式則使用與OLTP資料庫。因為select
- 方式,Oracle 必須為每個session儲存更多的內容,包括遊標,使用者上下文等,需要更多的資源。
- 其次,兩種方式期間所有未提交的DML事務將自動回滾且必須重啟啟動。alter session語句不會failover。
- 臨時物件不會failover也不能被重新啟動。
- RETRIES: 表示重試的次數
- DELAY:表示重試的間隔時間
- 4、測試TAF
- #首次建立連線,此時客戶端從tnsnames配置的第一個IP建立連線,由於第一個VIP所在的例項已經關閉,故連線到192.168.7.62
- #VIP 192.168.7.62對應的hostname以及instance_name分別為bo2dbs,GOBO4B,所以我們獲得如下返回結果
- #其次我們可以看到當前session failover的相關引數
- robin@SZDB:~> sqlplus <a href="mailto:fail_over/fail@gobo4_taf">fail_over/fail@gobo4_taf
- fail_over@GOBO4> get verify.sql
- 1 REM the following query is for TAF connection verification
- 2 col sid format 99999
- 3 col serial# format 9999999
- 4 col failover_type format a13
- 5 col failover_method format a15
- 6 col failed_over format a11
- 7 Prompt
- 8 Prompt Failover status for current user
- 9 Prompt ============================================
- 10 SELECT sid,
- 11 serial#,
- 12 failover_type,
- 13 failover_method,
- 14 failed_over
- 15 FROM v$session
- 16 WHERE username = 'FAIL_OVER';
- 17 REM the following query is for load balancing verification
- 18 col host_name format a20
- 19 Prompt
- 20 Prompt Current instance name and host name
- 21 Prompt ========================================
- 22* SELECT instance_name,host_name FROM v$instance;
- 23
- fail_over@GOBO4> @verify
- Failover status for current user
- ============================================
- SID SERIAL# FAILOVER_TYPE FAILOVER_METHOD FAILED_OVER
- ------ -------- ------------- --------------- -----------
- 1063 1175 SESSION BASIC NO
- Current instance name and host name
- ========================================
- INSTANCE_NAME HOST_NAME
- ---------------- --------------------
- GOBO4B bo2dbs
- #此時啟動第一個例項GOBO4A,並停止第二個例項
- oracle@bo2dbp:~> srvctl start instance -d GOBO4 -i GOBO4A
- oracle@bo2dbp:~> srvctl stop instance -d GOBO4 -i GOBO4B
- #檢視兩個例項的狀態
- oracle@bo2dbp:~> ./crs_stat.sh | grep inst
- ora.GOBO4.GOBO4A.inst ONLINE ONLINE on bo2dbp
- ora.GOBO4.GOBO4B.inst OFFLINE OFFLINE
- #在客戶端的session再次檢查連線狀態,即執行查詢,結果如下,我們收到了ORA-25408
- fail_over@GOBO4> @verify
- Failover status for current user
- ============================================
- SELECT sid,
- *
- ERROR at line 1:
- ORA-25408: can not safely replay call
- Current instance name and host name
- ========================================
- INSTANCE_NAME HOST_NAME
- ---------------- --------------------
- GOBO4A bo2dbp
- #再次執行查詢,此時客戶端已經自動實現了重新連線,從查詢返回得到的INSTANCE_NAME與HOST_NAME可知。
- #最重要的一個FAILED_OVER值為YES,表明當前的session是一個failover來的session。
- #關於METHOD使用PRECONNECT與TYPE使用SELECT的方式在此不作演示
- fail_over@GOBO4> @verify
- Failover status for current user
- ============================================
- SID SERIAL# FAILOVER_TYPE FAILOVER_METHOD FAILED_OVER
- ------ -------- ------------- --------------- -----------
- 1073 29 SESSION BASIC YES
- Current instance name and host name
- ========================================
- INSTANCE_NAME HOST_NAME
- ---------------- --------------------
- GOBO4A bo2dbp
- #Author : Robinson
- #Blog : http://blog.csdn.net/robinson_0612
- 5、小結:
- a、客戶端TAF方式實現了Oracle客戶端到伺服器透明故障轉移
- b、主要在客戶端tnsnames.ora配置FAILOVER_MODE來實現基於客戶端的TAF
- c、FAILOVER_MODE中基於連線方式(METHOD)可以分為BASIC與PRECONNECT兩種方式,後者開銷更大,延遲小,與前者相反
- d、FAILOVER_MODE中TYPE可以分為select與session兩種方式,兩者所有未提交的事務全部回滾,select方式會failover查詢,
- session方式不會。select方式多用在OLAP型別資料庫,而session多用在OLTP型別資料庫
- e、一旦所在的例項發生故障,會自動failover,無需手動重新連線,這就是與連線時故障轉移所不同的。
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/29446986/viewspace-1815944/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- ORACLE RAC TAF 配置(透明故障轉移)Oracle
- Oracle RAC TAF 無縫failoverOracleAI
- Oracle RAC 客戶端FAILOVER LOADBALANCE特性的配置方法Oracle客戶端AI
- Oracle Dataguard故障轉移(failover)操作OracleAI
- 物理DataGuard客戶端無縫切換--客戶端TAF 配置客戶端
- 4.2.14 啟用客戶端快速連線故障轉移客戶端
- 4.2.14.3 為Oracle呼叫介面客戶端啟用快速連線故障轉移Oracle客戶端
- 4.2.14.1 關於啟用客戶端快速連線故障轉移客戶端
- TNSNAMES TAF TEMPLATE , LOCAL_LISTENER RAC FAILOVERAI
- Oracle RAC 客戶端負載均衡配置Oracle客戶端負載
- oracle RAC的客戶端HA配置薦Oracle客戶端
- 【DATAGUARD】物理dg配置客戶端無縫切換 (八.3)--客戶端TAF 配置客戶端
- 理解透明應用程式故障轉移 (TAF) 和快速連線故障轉移 (FCF)
- 關於11G 客戶端連線資料庫 SCAN 和 Transparent Application Failover(TAF)客戶端資料庫APPAI
- [WK-T]ORACLE 10G 配置故障轉移(Failover)Oracle 10gAI
- Oracle RAC TAF [zt]Oracle
- 轉:Oracle RAC Failover 詳解OracleAI
- Oracle 10g RAC客戶端配置監聽Oracle 10g客戶端
- Oracle Failover - TAF 透明應用切換OracleAI
- Oracle RAC Failover 詳解[轉帖]OracleAI
- 11g DataGuard實現故障轉移(Failover)AI
- [轉載]Oracle 10g RAC TAF介紹Oracle 10g
- Oracle 10g RAC TAFOracle 10g
- 【RAC】RAC中的負載均衡和故障切換--TAF配置負載
- 理解透明應用程式故障轉移 (TAF) 和快速連線故障轉移 (FCF) (文件 ID 1602113.1)
- Oracle 客戶端安裝Oracle客戶端
- oracle客戶端升級Oracle客戶端
- oracle客戶端安裝Oracle客戶端
- 為oracle客戶端瘦身:Oracle客戶端
- 4.2.14.2 為JDBC客戶機啟用快速連線故障轉移JDBC
- 客戶端連線故障檢查流程手段客戶端
- Oracle RAC Failove 之二:TAFOracleAI
- 【轉帖】Oracle客戶端NLS_LANG設定Oracle客戶端
- 【TAF】使用Oracle RAC的TAF技術之SESSION型別OracleSession型別
- 配置 RAC 負載均衡與故障轉移負載
- Oracle RAC Failover 詳解OracleAI
- oracle rac failover 詳解OracleAI
- oracle rac failover的疑惑OracleAI