TAF(Transparent Application Failover)
RAC的TAF是指会话连接到一个实例上,如果这个实例出现了故障,Oracle会自动将会话迁移到另一个实例上。
以下为例:
(SERVICE_NAME = RACDB)
(FAILOVER_MODE =
(TYPE = SELECT)
(METHOD = BASIC)
(RETRIES = 180)
(DELAY = 5)
当FAILOVER_MODE类型为SELECT,METHOD = BASIC时可以实现查询语句不间断的返回结果.
当FAILOVER_MODE类型为SESSION,METHOD = BASIC时,可能会遇到的异常:
ORA-25408: can not safely replay call
ORA-25401: can not continue fetches
或许还有其它的错误。
这应该进行足够的测试,以应对TAF的不同Failover,以对特殊错误进行处理。
METHOD
BASIC 当感知到节点故障后,才创建到其它实例的连接。
PRECONNECT 在最初建立连接时就同时建立到所有实例的连接,当发生故障时就可以立刻切换到其它实例上。
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.
TYPE
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.
不管是select还是session,当发生实例故障时,未提交的事务都会自动回滚。
可以使用dbca生成service,也可以使用srvctl来生成service,使用srvctl时要使用dbms_service.modify_service更新数据字典,添加tns条目。