Oracle Transparent Application Failover(TAF) 说明

zz/2024/4/19 23:54:40

前几天和一个朋友讨论到Oracle Net Services的高级特性的问题,就研究了下。

 

Oracle 官网上的说明参考:

      Enabling Advanced Features of Oracle Net Services

       http://download.oracle.com/docs/cd/B19306_01/network.102/b14212/advcfg.htm#i473297

 

在这篇文章里讨论到了Net Services的几个特性:

·         Configuring Advanced Network Address and Connect Data Information

·         Configuring Runtime Connection Load Balancing

·         Configuring Transparent Application Failover

·         Configuring Connections to Non-Oracle Database Services

 

在这篇文章中,我们重点看一下TAF

Configuring Transparent Application Failover

http://download.oracle.com/docs/cd/B19306_01/network.102/b14212/advcfg.htm#i475648

 

RACFailover中也对TAF进行了说明:

       racle RAC Failover 详解

       http://blog.csdn.net/tianlesoftware/archive/2010/03/03/5340788.aspx

 

 

.  TAF 介绍

 

1.1  官网对TAF 的说明:

Transparent Application Failover (TAF) is a client-side feature that allows for clients to reconnect to surviving databases in the event of a failure of a database instance. Notifications are used by the server to trigger TAF callbacks on the client-side.

TAF is configured using either client-side specified TNS connect string or using server-side service attributes. However, if both methods are used to configure TAF, the server-side service attributes will supersede the client-side settings. The server-side service attributes are the preferred way to set up TAF.

TAF can operate in one of two modes, Session Failover and Select Failover. Session Failover will recreate lost connections and sessions. Select Failover will replay queries that were in progress.

When there is a failure, callback functions will be initiated on the client-side via OCI callbacks. This will work with standard OCI connections as well as Connection Pool and Session Pool connections. Please see the OCI manual for more details on callbacks, Connection Pools, and Session Pools.

TAF will work with RAC. For more details and recommended configurations, please see the RAC Administration Guide.

TAF will operate with Physical Data Guard to provide automatic failover.

 

1.2  TAF 使用场合

       TAF works with the following database configurations to effectively mask a database failure:

1Oracle Real Application Clusters

2Replicated systems

3Standby databases

4Single instance Oracle database

 

 

1.3  FAILOVER_MODE 参数

 

FAILOVER_MODE 参数必须包含CONNECT_DATA 选项,也可以包含一些其他的参数,具体参数和意义参考下表:

 

FAILOVER_MODE Subparameter

Description

BACKUP

Specify a different net service name for backup connections. A backup should be specified when using preconnect to pre-establish connections.

TYPE

Specify the type of failover. Three types of Oracle Net failover functionality are available by default to Oracle Call Interface (OCI) applications:

·         session: Set to failover the session. If a user's connection is lost, a new session is automatically created for the user on the backup. This type of failover does not attempt to recover selects.

·         select: Set to enable users with open cursors to continue fetching on them after failure. However, this mode involves overhead on the client side in normal select operations.

·         none: This is the default. No failover functionality is used. This can also be explicitly specified to prevent failover from happening.

METHOD

Determines how fast failover occurs from the primary node to the backup node:

·         basic: Set to establish connections at failover time. This option requires almost no work on the backup server until failover time.

·         preconnect: Set to pre-established connections. This provides faster failover but requires that the backup instance be able to support all connections from every supported instance.

RETRIES

Specify the number of times to attempt to connect after a failover. If DELAY is specified, RETRIES defaults to five retry attempts.

Note: If a callback function is registered, then this subparameter is ignored.

DELAY

Specify the amount of time in seconds to wait between connect attempts. If RETRIES is specified, DELAY defaults to one second.

Note: If a callback function is registered, then this subparameter is ignored.

 

 

 

.  TAF的示例

 

2.1 注意事项:

       不能在listener.ora 配置文件的SID_LIST_listener_name 部分设置GLOBAL_DBNAME参数, 这个静态的global配置会禁用TAF.

      

       启用这种Failover的方法就是在客户端的tnsnames.ora中添加FAILOVER=ON 条目,这个参数默认就是ON,所以即使不添加这个条目,客户端也会获得这种Failover能力。

 

 

2.2  TAF with Connect-Time Failover and Client Load Balancing

 

sales.us.acme.com=

 (DESCRIPTION=

  (LOAD_BALANCE=on)

  (FAILOVER=on)

  (ADDRESS=

       (PROTOCOL=tcp) 

       (HOST=sales1-server) 

       (PORT=1521))

  (ADDRESS=

       (PROTOCOL=tcp) 

       (HOST=sales2-server) 

       (PORT=1521))

  (CONNECT_DATA=

     (SERVICE_NAME=sales.us.acme.com)

     (FAILOVER_MODE=

       (TYPE=select)

       (METHOD=basic))))

 

       在这个示例中, Oraclenet 连接会随即去连2个地址,如果连接失败,会去连其他节点。

 

 

2.3  TAF Retrying a Connection

 
sales.us.acme.com=
 (DESCRIPTION=
  (ADDRESS=
       (PROTOCOL=tcp)  
       (HOST=sales1-server)  
       (PORT=1521)) 
  (CONNECT_DATA=
     (SERVICE_NAME=sales.us.acme.com) 
     (FAILOVER_MODE=
       (TYPE=select) 
       (METHOD=basic)
       (RETRIES=20)
       (DELAY=15))))

 

       在这个示例中,我们设置了一个ADDRESS 并且设置了 RetriesDELAY 参数。 当连接失败后, Oracle net 会等15秒,然后再次去连接address的地址。 最多重连20次。

 

 

2.4  TAF Pre-Establishing a Connection

 

sales1.us.acme.com=
 (DESCRIPTION=
  (ADDRESS=
       (PROTOCOL=tcp)  
       (HOST=sales1-server)  
       (PORT=1521)) 
  (CONNECT_DATA=
     (SERVICE_NAME=sales.us.acme.com) 
     (INSTANCE_NAME=sales1) 
     (FAILOVER_MODE=
       (BACKUP=sales2.us.acme.com) 
       (TYPE=select) 
       (METHOD=preconnect))))
sales2.us.acme.com=
 (DESCRIPTION=
  (ADDRESS=
       (PROTOCOL=tcp)  
       (HOST=sales2-server)  
       (PORT=1521)) 
  (CONNECT_DATA=
     (SERVICE_NAME=sales.us.acme.com) 
     (INSTANCE_NAME=sales2)
     (FAILOVER_MODE=
       (BACKUP=sales1.us.acme.com) 
       (TYPE=select) 
       (METHOD=preconnect))))

 

       在这里我们设置成preconnect模式。 是在最初建立连接时就同时建立到所有实例的连接,当发生故障时,立刻就可以切换到其他链路上。

       BASIC方式在Failover时会有时间延迟,PRECONNECT方式虽然没有时间延迟,但是建立多个冗余连接会消耗更多资源,两者就是是用时间换资源和用资源换时间的区别。

 

       这里要注意, 如果使用preconnect 模式,那么必须指定BACKUP参数。

 

 

.  Data Guard 下验证TAF

       RAC 下的TAF 之前做过多次, 这里用Data Guard 做一个验证。

 

在客户端的tnsnames.ora 文件里添加如下参数:

TAFTEST=

 (DESCRIPTION=

  (LOAD_BALANCE=on)

  (FAILOVER=on)

  (ADDRESS= (PROTOCOL=tcp) (HOST=192.168.6.2) (PORT=1521))

  (ADDRESS= (PROTOCOL=tcp) (HOST=192.168.6.3) (PORT=1521))

  (CONNECT_DATA= (SERVICE_NAME=orcl)

     (FAILOVER_MODE=

       (TYPE=select)

       (METHOD=basic)

       )))

 

Tnsping 测试一下:

C:/Users/Administrator.DavidDai>tnsping taftest

TNS Ping Utility for 32-bit Windows: Version 11.2.0.1.0 - Production on 13-12-2010 00:37:08

Copyright (c) 1997, 2010, Oracle.  All rights reserved.

已使用的参数文件:

D:/app/Administrator/product/11.2.0/dbhome_1/network/admin/sqlnet.ora

 

已使用 TNSNAMES 适配器来解析别名

尝试连接 (DESCRIPTION= (LOAD_BALANCE=on) (FAILOVER=on) (ADDRESS= (PROTOCOL=tcp) (HOST=192.168.6.2) (PORT=1521)) (ADDRESS= (PROTOCOL=tcp) (HOST=192.168.6.3) (PORT=1521)) (CONNECT_DATA= (SERVICE_NAME=orcl) (FAILOVER_MODE= (TYPE=select) (METHOD=basic))))

OK (20 毫秒)

 

C:/Users/Administrator.DavidDai>sqlplus /nolog

SQL*Plus: Release 11.2.0.1.0 Production on 星期一 12 13 00:40:49 2010

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

SQL>  conn sys/oracle@taftest as sysdba;

已连接。

SQL>  select db_unique_name from v$database;

DB_UNIQUE_NAME

------------------------------

orcl_pd

 

这时,我们把主库shutdown,在来查看:

SQL> select db_unique_name from v$database;

DB_UNIQUE_NAME

------------------------------

orcl_st

 

这里变成了备库,但是备库是mount standby模式,我们查看确认一下:

SQL> select open_mode from v$database;

OPEN_MODE

----------

MOUNTED

SQL>

 

TAF 切换成功。

 

       我们还可以通过对V$SESSION 视图的FAILOVER_TYPE, FAILOVER_METHOD, FAILED_OVER 三个字段的查看来验证TAF 的配置。

 

SQL 如下:

SQL> SELECT MACHINE, FAILOVER_TYPE, FAILOVER_METHOD, FAILED_OVER, COUNT(*)

FROM V$SESSION

GROUP BY MACHINE, FAILOVER_TYPE, FAILOVER_METHOD, FAILED_OVER;

 

MACHINE              FAILOVER_TYPE FAILOVER_M FAI   COUNT(*)

-------------------- ------------- ---------- --- ----------

dg1                  NONE          NONE       NO           2

dg2                  NONE          NONE       NO          15

WORKGROUP/DAVIDDAI   SELECT        BASIC      YES          1

 

 

 

 

      做这个测试的目的就是为了DG 切换的方便。 一般情况下应用会连接数据库是对应一个实例,假设这个数据库是DG. 当某次意外,我们进行了主备切换,这时候,IP地址发生改变,应用就不能连接到备库了。 所以,这就是对Data Guard设置TAF的意义。 设置TAF之后,即使发生切换,我们也可以不用修改IP,应用能正常连接数据库。

 

      当然如果客户端比较多的情况下,修改监听配置也是很麻烦的。 不过现在的系统,很多都是通过中间件与数据库进行连接的。 这种情况下,我们只需要把中间件与数据库连接这块搞定就ok了。

 

 

 

 

 

 

------------------------------------------------------------------------------

QQ:492913789

Email:ahdba@qq.com

Blog: http://www.cndba.cn/dave 


网上资源: http://tianlesoftware.download.csdn.net

相关视频:http://blog.csdn.net/tianlesoftware/archive/2009/11/27/4886500.aspx

DBA1 群:62697716(); DBA2 群:62697977()

DBA3 群:62697850   DBA 超级群:63306533;    

聊天 群:40132017

--加群需要在备注说明Oracle表空间和数据文件的关系,否则拒绝申请


http://www.ngui.cc/zz/2721253.html

相关文章

IBM AIX 5.3 系统管理 -- 监视和性能优化一

一. 监视文件系统增长 在 AIX 5L 系统上,管理员需要监视文件系统增长以防止文件系统装满。 基于“Berkeley 磁盘配额系统”(Berkeley Disk Quota System) 的磁盘配额系统提供了一种控制磁盘空间使用的有效方法。可以为各个用户或组定义配额系统,并且每…

IBM HACMP 系列 -- 基础知识

一. 什么是 HACMP(High Availability Cluster Multi-Processing) 1.1 高可用性 在当今的复杂环境中,为应用程序提供连续的服务是成功的 IT 实现的重要组成部分。高可用性屏蔽或消除计划内和计划外的系统和应用程序停机时间,是帮助为应用程序客户端提供…

浅谈 HACMP 心跳

一. 初识 HACMP 心跳 HACMP 软件主要监控 4 种故障:节点,网卡,网络,应用。其中前三种都是通过心跳来监控并产生事件响应的,我们可以看出使用 HACMP 集群,可谓玩的就是心跳。如果不了解心跳的过程和基本原理…

Oracle Golden Gate 简述

Oracle 在2009年收购了Golden Gate,之后Oracle 把Stream 的一些优点引入到了Golden Gate。 所以以后在数据复制这块,Oracle 肯定也是大力发展Golden Gate。 官网参考: http://www.oracle.com/us/corporate/Acquisitions/goldengate/index.h…

OEM 应用程序要求的数据库权限超出了您当前具有的权限 解决方法

当Oralce 访问OEM 出现如下错误时: 应用程序要求的数据库权限超出了您当前具有的权限 从如下2个方面检查: (1)给用户赋SELECT_CATALOG_ROLE grant SELECT_CATALOG_ROLE to user (2)DBSNMP,SYSMA…

RAC srvctl 命令报 libpthread.so.0 cannot open shared object file No such file or directory 解决方法

运行srvctl 命令报错: [oraclerac1 u01]$ srvctl remove asm -n rac1 /u01/app/oracle/product/10.2.0/db_1/jdk/jre/bin/java: error while loading shared libraries: libpthread.so.0: cannot open shared object file: No such file or directory 开始还觉…

How to copy a datafile from ASM to a file system not using RMAN

How to move a datafile from a file system to ASM http://blog.csdn.net/tianlesoftware/archive/2011/04/22/6342722.aspx How to move a datafile from ASM to the file system http://www.cndba.cn/Dave/article/817 步骤如下: 1. Log onto the ta…

How to Create Transportable Tablespaces Where the Source and Destination are ASM-Based

expdp/imp 的Transport_datafiles 在 之前的Blog里有实例,参考下面blog的3.12小节: Oracle expdp/impdp 使用示例 http://www.cndba.cn/Dave/article/1411 The purpose of this note is to describe the method to create transportable tablespaces(…

Oracle 数据文件 reuse 属性 说明

有关表空间创建的相关参数,参考: Oracle 表空间 创建参数 说明 http://blog.csdn.net/tianlesoftware/archive/2011/01/27/6166928.aspx 当我们对表空间添加数据文件的时候,有一个reuse 属性。 10g的官网对这个参数的说明如下: REUSE Speci…

dba_registry 和 v$option 与 Oracle 特新及组件

一. 先看官网对这2个视图的说明 1.1 V$OPTION This view lists database options and features. Typically, although not always, options must be separately purchased and installed, whereas features come with the product and are enabled based on the product that …