ITPub博客

首页 > Linux操作系统 > Linux操作系统 > RAC的TAF简单测试(四)

RAC的TAF简单测试(四)

原创 Linux操作系统 作者:yangtingkun 时间:2007-05-01 00:00:00 0 删除 编辑

OracleRAC的高可用功能除了负载均衡还包括TAFTransparent Application Failover)。

RACTAF是指会话连接到一个实例上,如果这个实例出现了故障,Oracle会自动将会话迁移到另一个实例上。

RACTAF简单测试(一):http://yangtingkun.itpub.net/post/468/283068

RACTAF简单测试(二):http://yangtingkun.itpub.net/post/468/283277

RACTAF简单测试(三):http://yangtingkun.itpub.net/post/468/283474

这篇简单讨论一下TAFBASIC方式和PRECONNECT方式


TAF有两种切换方式,BASIC方式和PRECONNECT方式。对于BASIC方式,所有设置了TAF的会话在当前实例失败后,会连接到另外一个实例上。而对于PRECONNECT方式,每个连接的会话在主实例和备份实例上各连接一个会话,一旦主实例失败,可以迅速的切换到备份实例。

首先看看普通BASIC方式的tnsnames.ora的设置:

TESTRAC_BASIC =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 172.25.198.224)(PORT = 1521))
(ADDRESS = (PROTOCOL = TCP)(HOST = 172.25.198.225)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = testrac)
(FAILOVER_MODE =
(TYPE = SELECT)
(METHOD = BASIC)
)
)
)

下面看看PRECONNECT的配置:

TESTRAC_PRE1 =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 172.25.198.224)(PORT = 1521))
(ADDRESS = (PROTOCOL = TCP)(HOST = 172.25.198.225)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = testrac)
(FAILOVER_MODE =
(TYPE = SELECT)
(METHOD = PRECONNECT)
(BACKUP = TESTRAC_PRE2)
)
)
)

TESTRAC_PRE2 =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 172.25.198.224)(PORT = 1521))
(ADDRESS = (PROTOCOL = TCP)(HOST = 172.25.198.225)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = testrac)
(FAILOVER_MODE =
(TYPE = SELECT)
(METHOD = PRECONNECT)
(BACKUP = TESTRAC_PRE1)
)
)
)

对于BASIC方式的TAF

SQL> CONN TEST/TEST@TESTRAC_BASIC已连接。
SQL> SELECT SID, FAILOVER_TYPE, FAILOVER_METHOD, FAILED_OVER
2 FROM V$SESSION
3 WHERE SID IN (SELECT SID FROM V$MYSTAT WHERE ROWNUM = 1);

SID FAILOVER_TYPE FAILOVER_M FAI
---------- ------------- ---------- ---
130 SELECT BASIC NO

SQL> SELECT INSTANCE_NAME FROM V$INSTANCE;

INSTANCE_NAME
----------------
testrac1

通过SET TIMING ON来检查观察切换时间:

SQL> SET TIMING ON
SQL> SELECT INSTANCE_NAME FROM V$INSTANCE;

INSTANCE_NAME
----------------
testrac1

已用时间: 00: 00: 00.01
SQL> SELECT INSTANCE_NAME FROM V$INSTANCE;

INSTANCE_NAME
----------------
testrac1

已用时间: 00: 00: 00.01
SQL> SELECT INSTANCE_NAME FROM V$INSTANCE;

INSTANCE_NAME
----------------
testrac2

已用时间: 00: 00: 00.25
SQL> SELECT INSTANCE_NAME FROM V$INSTANCE;

INSTANCE_NAME
----------------
testrac2

已用时间: 00: 00: 00.00

在执行查询的同时在另外的窗口关闭实例1

bash-2.03$ srvctl stop instance -d testrac -i testrac1

下面看看PRECONNECT的情况,首先开启实例:

bash-2.03$ srvctl start instance -d testrac -i testrac1

通过TESTRAC_PRE1服务名连接数据库:

SQL> SET TIMING OFF
SQL> CONN TEST/TEST@TESTRAC_PRE1
已连接。
SQL> SELECT SID, FAILOVER_TYPE, FAILOVER_METHOD, FAILED_OVER
2 FROM V$SESSION
3 WHERE SID IN (SELECT SID FROM V$MYSTAT WHERE ROWNUM = 1);

SID FAILOVER_TYPE FAILOVER_M FAI
---------- ------------- ---------- ---
149 SELECT PRECONNECT NO

SQL> SELECT INSTANCE_NAME FROM V$INSTANCE;

INSTANCE_NAME
----------------
testrac1

执行刚才的操作,检查PRECONNECTTAF情况:

SQL> SET TIMING OFF
SQL> CONN TEST/TEST@TESTRAC_PRE1
已连接。
SQL> SELECT SID, FAILOVER_TYPE, FAILOVER_METHOD, FAILED_OVER
2 FROM V$SESSION
3 WHERE SID IN (SELECT SID FROM V$MYSTAT WHERE ROWNUM = 1);

SID FAILOVER_TYPE FAILOVER_M FAI
---------- ------------- ---------- ---
149 SELECT PRECONNECT NO

SQL> SELECT INSTANCE_NAME FROM V$INSTANCE;

INSTANCE_NAME
----------------
testrac1

SQL> SET TIMING ON
SQL> SELECT INSTANCE_NAME FROM V$INSTANCE;

INSTANCE_NAME
----------------
testrac1

已用时间: 00: 00: 00.00
SQL> SELECT INSTANCE_NAME FROM V$INSTANCE;

INSTANCE_NAME
----------------
testrac1

已用时间: 00: 00: 00.01
SQL> SELECT INSTANCE_NAME FROM V$INSTANCE;

INSTANCE_NAME
----------------
testrac1

已用时间: 00: 00: 00.01
SQL> SELECT INSTANCE_NAME FROM V$INSTANCE;

INSTANCE_NAME
----------------
testrac2

已用时间: 00: 00: 00.01
SQL> SELECT INSTANCE_NAME FROM V$INSTANCE;

INSTANCE_NAME
----------------
testrac2

已用时间: 00: 00: 00.00
SQL> SELECT INSTANCE_NAME FROM V$INSTANCE;

INSTANCE_NAME
----------------
testrac2

已用时间: 00: 00: 00.01

在查询的同时管理实例testrac1

bash-2.03$ srvctl stop instance -d testrac -i testrac1

数据库负载很小,而且会话需要恢复的操作不多,所以切换时所需的时间不长,不过即使是这样,通过对比BASICPRECONNECT所需的切换时间,也可以看到明显的区别。

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/4227/viewspace-69260/,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论
暂无介绍

注册时间:2007-12-29

  • 博文量
    1955
  • 访问量
    10487217