RAC connection management整理


对于RAC来说,当Oracle Instance失败的,应用有几种高可用技术来保证可用性,这些技术对客户端来说都是透明的,客户端可能感知不到instance failure。

一.Transparent Application Failover (TAF)

二.Fast Connection Failover (FCF).

当一个节点failure的时候,TAF允许数据库session使用OCI libraries进行fail over到其他存活的一个节点。但是如果应用使用JDBC thin driver则不能使用TAF。

Failover Modes:

Session failover

Select failover

None(default)

1.select mode允许query重新在新的节点执行,并且丢弃已经fetch的行,继续返回结果给客户端。

2.none mode显式的声明不使用TAF

3.TAF不能够恢复任何DML事务,事务将在另一个节点回滚。

Failover Methods:

Basic

Preconnect

1.Basic选项意味着客户端在实例失败后重新建立新的连接,这个method可能导致节点失败时,另一节点的性能下降,因为有很多的session将要重新连接到幸存的节点。

2.客户端产生一个preconnected session作为备份,在实例失败时加速failover。

TAF是client-side feature,我们需要配置它在客户端Tnsnames.ora或者server端通过service来实现

1,客户端实现

RAC中在tnsnames.ora里面典型配置如下:

  1. LEO1 =  
  2.   (DESCRIPTION_LIST =  
  3.      (LOAD_BALANCE = off)  
  4.      (FAILOVER = on)  
  5.      (DESCRIPTION =  
  6.         (ADDRESS_LIST =  
  7.            (LOAD_BALANCE=OFF)  
  8.            (FAILOVER=ON)  
  9.            (ADDRESS = (PROTOCOL = TCP)(HOST = node1.chinamobile.com)(PORT = 1521))  
  10.         )  
  11.         (CONNECT_DATA =  
  12.            (SERVICE_NAME = leo)  
  13.            (INSTANCE_NAME = leo1)  
  14.            (FAILOVER_MODE=(TYPE=session)(METHOD=basic)(RETRIES=4)(DELAY=1))  
  15.          )  
  16.       )  
  17.      (DESCRIPTION =  
  18.         (ADDRESS_LIST =  
  19.            (LOAD_BALANCE=OFF)  
  20.            (FAILOVER=ON)  
  21.            (ADDRESS = (PROTOCOL = TCP)(HOST = node2.chinamobile.com)(PORT = 1521))  
  22.          )  
  23.         (CONNECT_DATA =  
  24.            (SERVICE_NAME = leo)  
  25.            (INSTANCE_NAME = leo2)  
  26.            (FAILOVER_MODE=(TYPE=session)(METHOD=basic)(RETRIES=4)(DELAY=1))  
  27.          )  
  28.        )  
  29.   )  

2,server端实现

  1. srvctl add service -d leo -s cmcc -q TRUE -P BASIC -e SESSION -z 4 -w 5  具体使用参数如下:  
  2. Usage: srvctl add service -d <db_unique_name> -s <service_name> {-r "<preferred_list>" [-a "<available_list>"] [-P {BASIC | NONE | PRECONNECT}]   
  3. | -g <pool_name> [-c {UNIFORM | SINGLETON}] } [-k   <net_num>] [-l [PRIMARY][,PHYSICAL_STANDBY][,LOGICAL_STANDBY][,SNAPSHOT_STANDBY]]   
  4. [-y {AUTOMATIC | MANUAL}] [-q {TRUE|FALSE}] [-x {TRUE|FALSE}] [-j {SHORT|LONG}] [-B {NONE|SERVICE_TIME|THROUGHPUT}]   
  5. [-e {NONE|SESSION|SELECT}] [-m {NONE|BASIC}] [-z <failover_retries>] [-w <failover_delay>] [-t <edition>] [-f]  
  6.     -d <db_unique_name>      Unique name for the database  
  7.     -s <service>             Service name  
  8.     -r "<preferred_list>"    Comma separated list of preferred instances  
  9.     -a "<available_list>"    Comma separated list of available instances  
  10.     -g <pool_name>           Server pool name  
  11.     -c {UNIFORM | SINGLETON} Service runs on every active server in the server pool hosting this service (UNIFORM) or just one server (SINGLETON)  
  12.     -k <net_num>             network number (default number is 1)  
  13.     -P {NONE | BASIC | PRECONNECT}        TAF policy specification  
  14.     -l <role>                Role of the service (primary, physical_standby, logical_standby, snapshot_standby)  
  15.     -y <policy>              Management policy for the service (AUTOMATIC or MANUAL)  
  16.     -e <Failover type>       Failover type (NONE, SESSION, or SELECT)  
  17.     -m <Failover method>     Failover method (NONE or BASIC)  
  18.     -w <integer>             Failover delay  
  19.     -z <integer>             Failover retries  
  20.     -t <edition>             Edition (or "" for empty edition value)  
  21.     -j <clb_goal>  Connection Load Balancing Goal (SHORT or LONG). Default is LONG.  
  22.     -B <Runtime Load Balancing Goal>     Runtime Load Balancing Goal (SERVICE_TIME, THROUGHPUT, or NONE)  
  23.     -x <Distributed Transaction Processing>  Distributed Transaction Processing (TRUE or FALSE)  
  24.     -q <AQ HA notifications> AQ HA notifications (TRUE or FALSE)  
  25. Usage: srvctl add service -d <db_unique_name> -s <service_name> -u {-r "<new_pref_inst>" | -a "<new_avail_inst>"} [-f]  
  26.     -d <db_unique_name>      Unique name for the database  
  27.     -s <service>             Service name  
  28.     -u                       Add a new instance to service configuration  
  29.     -r <new_pref_inst>       Name of new preferred instance  
  30.     -a <new_avail_inst>      Name of new available instance  
  31.     -f                       Force the add operation even though a listener is not configured for a network  
  32.     -h                       Print usage  
  33. Fast Connection Failover and Fast Application Notification  

FAN是一种消息发布机制,在instance up/down发布消息到客户端,来进行群集的重新配置,FCF是通过FAN来透明的进行
instance failure failover。

FCF支持的客户端驱动:

                    Java Database Connection Driver (JDBC)
                    Oracle Universal Connection Pool UCP
                    Clients using the Oracle Call Interface
                    Oracle Data Providers for .Net          

在11R2(11.2.0.1)中当设置了db_domain参数,FCF将会失效,bug:8779597

更多Oracle相关信息见Oracle 专题页面 http://www.bkjia.com/topicnews.aspx?tid=12

相关内容