Linux平臺上Oracle Rac中的TAF配置

發表於2015-08-14

簡介

    TAF是Transparent Application Failover的英文縮寫,即為透明應用失敗切換,也就是說應用在透過以TAF方式配置的客戶端連資料庫後,當前所連線的資料庫例項發生異常中斷後,應 用會自動連線到其他可用例項上去繼續前面的查詢,而不需要應用重新發起連線或是重啟應用來恢復會話連線。此文結合多人經驗,特此感謝曾經一起戰鬥在DBA 崗位上的夥伴兒們。

1、實驗環境平臺資訊
--系統:
Oracle Linux 5.7
Linux 2.6.32-200.13.1.el5uek <wbr> x86_64 x86_64 x86_64 GNU/Linux

--11g R2 RAC 11.2.0.3

2、tnsnames檔案配置(node1,node2都要設定)

cd $ORACLE_HOME/network/admin
cat tnsnames.ora

# tnsnames.ora Network Configuration File: /space/sys_software/oracle/app/product/11.2.0/db_1/network/admin/tnsnames.ora
# Generated by Oracle configuration tools.

TX9AB =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = node1-vip)(PORT = 1521))
    (ADDRESS = (PROTOCOL = TCP)(HOST = node2-vip)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = tx9ab)
      (FAILOVER_MODE=
        (TYPE=session)
        (METHOD=preconnect)
        (RETRIES=180)
        (DELAY=5))
    )
  )

3、修改Linux平臺上的的tcp延時協議

--修改引數 net.ipv4.tcp_retries2

對該引數的解釋

    TCP失敗重傳次數,預設值15,意味著重傳15次才徹底放棄.可減少到5,以儘早釋放核心資源。實際設定為1,如果使用預設引數,通常要等待30分鐘左右,這樣對於TAF的配置顯然就失去了義。

  net.ipv4.tcp_retries2=1;

--sysctl -p                                      啟用設定;


4、TAF效果測試

[oracle@node1 admin]$ sqlplus sys/oracle@tx9ab as sysdba

SQL*Plus: Release 11.2.0.3.0 Production on Fri Aug 14 01:24:52 2015

Copyright (c) 1982, 2011, Oracle.  All rights reserved.


Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
With the Partitioning, Real Application Clusters, Automatic Storage Management, OLAP,
Data Mining and Real Application Testing options

SQL> select count(*) from v$datafile;

  COUNT(*)
----------
         7

....換個視窗切換到grid使用者

[grid@node1 ~]$ srvctl stop instance -d tx9ab -i tx9ab1 -o abort

.....換回原來視窗,在相同session中查詢

SQL> show parameter name

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
db_file_name_convert                 string
db_name                              string      tx9ab
db_unique_name                       string      tx9ab
global_names                      <wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr>

相關文章