ITPub博客

首页 > 数据库 > Oracle > oracle 11g rac TAF 测试方案

oracle 11g rac TAF 测试方案

原创 Oracle 作者:sky_dizzy001 时间:2014-02-11 09:12:22 0 删除 编辑

1 系统环境描述
主机环境:
主机名 IP地址
SCDB1 192.168.1.100
SCDB2 192.168.1.102
操作系统版本 AIX 6100-04

2 数据库信息
数据库库版本 Oracle11.2.0.1 RAC
数据库名 SCDB
实例名 SCDB1 SCDB2
监听端口 1521

3 RAC节点配置信息
主机名    CPU     内存              IP                       IP别名 
SCDB1     4        16384 MB     192.168.1.100      public 
                                           192.168.1.101     virtual 
                                           172.16.18.1         private
SCDB2     4        16384 MB     192.168.1.102     public 
                                           192.168.1.103    virtual 
                                           172.16.18.2        private
SCAN                                   192.168.1.104      SCDB-cluster-scan

4 测试目的
    Oracle RAC 通过它的故障切换机制提供了一个卓越的解决方案,当集群中的某个节点出现故障时,用户将被自动移植到其他可用节点,透明应用程序故障切换 (TAF) 是 Oracle RAC 一个负责处理故障切换的主要功能。所有断开的数据库连接(和进程)将被重新连接到集群的其他节点上,故障切换对用户是完全透明的。为验证该功能,在纳服整合平台使用情况,现做出如下测试。

5 测试过程
需要添加如下信息到客户端机器:
修改C:\WINDOWS\system32\drivers\etc\hosts ,添加地址解析 
192.168.1.101 SCDB1-vip
192.168.1.103 SCDB2-vip
192.168.1.104 SCDB-cluster-scan

6 测试
6.1使用scanip连接方式
SCDB =
(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.1.104)(PORT=1521))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=SCDB)))

6.2使用VIP连接
实例shutdown时,连接会中断 
SCDB_VIP =
(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.1.101)(PORT=1521))(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.1.103)(PORT=1521))(LOAD_BALANCE=yes)(CONNET_DATA=(SERVER = DEDICATED)(SERVICE_NAME = SCDB) ) )

6.3使用TAF方式连接
实例shutdown时,连接会自动转到另一个实例 
SCDB_TAF =
(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.1.101)(PORT=1521))(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.1.103)(PORT=1521))(LOAD_BALANCE=yes)(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=SCDB)(FAILOVER_MODE=(TYPE=SELECT)(METHOD = BASIC)(RETRIES = 180)(DELAY = 5)
) ) )

6.4 使用首选实例方式连接
默认情况下连接到首选实例,当首选实例shutdown时,连接会自动转到另一个实例
SCDB1 =
(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.1.101)(PORT=1521))(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.1.103)(PORT=1521))(LOAD_BALANC=YES)(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=SCDB1)(FAILOVER_MODE=(TYPE=SELECT)(METHOD= BASIC)(RETRIES = 180)(DELAY = 5) ) ) )
注:服务 SCDB1 的首选实例是 SCDB1

6.5 应用服务器JDBC Data Sources配置信息 
jdbc:oracle:thin:@(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.1.101)(PORT=1521))(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.1.103)(PORT=1521))(LOAD_BALANCE=YES)(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=SCDB)(FAILOVER_MODE=(TYPE=SELECT)(METHOD=BASIC)(RETRIES=180)(DELAY=5))))
注意:如果你准备shutdown 某一个instance,那么必须要先停止该实例的service,然后再shutdown instance,否则service的首选实例会漂移至另一个节点,这种情况下即使instance重新startup,service也不会自动漂移回原先设定的首选实例,需要手工回切service的首选实例。注:重启database也可以使service恢复成预设状态。 
假设服务SCDB的首选实例漂移到SCDB2,回切到SCDB1的方法如下 :
srvctl relocate service -d SCDB -s SCDB -i SCDB2 -t SCDB1
Oracle的RAC的高可用功能除了负载均衡还包括TAF,是指会话连接到一个实例上,如果这个实例出现了故障,Oracle会自动将会话迁移到另一个实例上。

7 首先不配置TAF,进行实例级的故障测试
在客户端TNSNAMES.ORA中进行如下的配置进行测试
TESTRAC = 
(DESCRIPTION = 
(ADDRESS = (PROTOCOL = TCP)(HOST =192.168.1.101)(PORT = 1521)) 
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.103)(PORT = 1521))(CONNECT_DATA = 
(SERVER = DEDICATED) 
(SERVICE_NAME = SCDB) 

)
实例级故障转移测试:
conn / as sysdba
select instance_name from v$instance;
关闭SCDB1实例
Srvctl stop instance –d SCDB –i SCDB1
conn / as sysdba
select instance_name from v$instance;---查看连接实例
ORA-03114: 未连接到 ORALCE
Srvctl start instance –d SCDB –i SCDB1

8 配置TAF进行测试
在客户端TNSNAMES.ORA中进行如下的测试:
TESTRAC = 
(DESCRIPTION = 
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.101)(PORT = 1521))
 (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.103)(PORT = 1521))
 (CONNECT_DATA =
 (SERVER = DEDICATED)
(SERVICE_NAME = SCDB) 
FAILOVER_MODE =
(TYPE = SELECT) 
(METHOD = BASIC)
(RETRIES=180)
(DELAY=5)
)



TESTRAC = 
(DESCRIPTION = 
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.101)(PORT = 1521))
 (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.103)(PORT = 1521))
 (CONNECT_DATA =
 (SERVER = DEDICATED)
(SERVICE_NAME = SCDB) 
(FAILOVER_MODE =
 (TYPE = SESSION) 
(METHOD = BASIC)
(RETRIES=180)
(DELAY=5)
)


注:SESSION和SELECT的区别,配置了SELECT选项的FAILOVER在数据库实例失败时,会将会话切换到另一个实例,且将实例失败时运行的SELECT语句继续执行,并返回正确的结果。而SESSION则不具备这个功能。
检查实例信息,进行实例级测试
Select instance_name,status from gv$instance;
再次分别停掉实例SCDB1或SCDB2进行验证:
Srvctl stop instance –d SCDB –i SCDB1
Select instance_name from v$instance;
Srvctl start instance –d SCDB –i SCDB1
Srvctl stop instance –d SCDB –i SCDB2
Select instance_name from v$instance;
至此,数据库实例级的FAILOVER测试完成。

8.1下一步进行session级的FAILOVER测试过程
TESTRAC = 
(DESCRIPTION = 
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.101)(PORT = 1521)) 
 (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.103)(PORT = 1521)) 
 (CONNECT_DATA = 
 (SERVER = DEDICATED) 
 (SERVICE_NAME = SCDB) 
(FAILOVER_MODE = 
 (TYPE = SESSION) 
(METHOD = BASIC)
(RETRIES=180)
(DELAY=5) 
)
)
)
先看看FAILOVER设置为SESSION的情况:
SELECT INSTANCE_NAME FROM V$INSTANCE;
任意查询一个表
SET PAUSE ON  -----打开暂停
SELECT TRIGGER_NAME FROM DBA_TRIGGERS;
关闭当前会话连接的实例
Srvctl stop instance –d SCDB –i SCDB1
返回刚才执行SQL窗口,按回车继续
Error:ORA-25401:无法继续读取
下面测试一下FAILOVER设置为SELECT的情况
TESTRAC = 
(DESCRIPTION = 
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.101)(PORT = 1521)) 
 (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.103)(PORT = 1521)) 
 (CONNECT_DATA = 
 (SERVER = DEDICATED) 
 (SERVICE_NAME = SCDB) 
(FAILOVER_MODE = 
 (TYPE = SELECT) 
(METHOD = BASIC)
(RETRIES=180)
(DELAY=5) 
)


Srvctl start instance –d SCDB –i SCDB1
SET PAUSE ON -----打开暂停
SELECT INSTANCE_NAME FROM V$INSTANCE;
SELECT TRIGGER_NAME FROM DBA_TRIGGERS;
关闭当前会话连接的实例
Srvctl stop instance –d SCDB –i SCDB1
返回刚才执行SQL窗口,按回车继续
-----能继续执行当前的select并显示结果
SELECT INSTANCE_NAME FROM V$INSTANCE;
不但将会话切换到了正常的实例上,而且SELECT也得到了完整的结果,没有因实例故障而出现错误。这就是FAILOVER的SESSION和SELECT设置的区别。

至此,TAF测试完毕。

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

请登录后发表评论 登录
全部评论

注册时间:2014-02-01

  • 博文量
    27
  • 访问量
    129568