与本系列的前几篇不同,本文将在RAC上测试TAF的一些特性。而测试环境又有所不同:运行于Red Hat Enterprise Linux 5上的Oracle 10.2.0.1,客户端为Windows上的10.2.0.1。在客户端的TNSNAME配置如下:
DMDB =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.0.81)(PORT = 1521))
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.0.82)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = dmdb)
(FAILOVER_MODE =
(TYPE = SELECT)
(METHOD = BASIC)
(RETRIES = 180) (DELAY = 5)
)
)
)
我们使用sqlplus连接到数据库中(为节省篇幅,对部分无关紧要的输出做了剪裁):
D:\>sqlplus test/test@dmdb
连接到:
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, Real Application Clusters, OLAP and Data Mining options
由于负载均衡的作用,我们需要确定会话连接的实例(节点),下面的输出给出了当前会话连接的节点和会话信息:
SQL> show parameter instance_name
NAME TYPE VALUE
------------------------------------ ----------- -------
instance_name string rac2SQL> select sid from v$mystat where rownum=1;
SID
----------
147
SQL> select failover_type,failover_method,failed_over from v$session where sid=147;FAILOVER_TYPE FAILOVER_M FAILED_OVE
------------- ---------- ----------
SELECT BASIC NO
从上面输出的结果中的最后几行可以看出,会话已经启用了TAF。
现在将节点2上的实例(也就是rac2)关闭,在sqlplus依次执行下面的命令,得到的结果如下:
SQL> show parameter instance_name
NAME TYPE VALUE
------------------------------------ ----------- ------
instance_name string rac1SQL> select sid from v$mystat where rownum=1;
SID
----------
146
SQL> select failover_type,failover_method,failed_over from v$session where sid=146;FAILOVER_TYPE FAILOVER_M FAILED_OVE
------------- ---------- ----------
SELECT BASIC YES
从结果来看,会话已经顺利地failover到了第1个节点(rac1)上。
在接下来的测试中,为了避免服务器端的自动均衡对测试造成的干扰,我们将两个实例的remote_listener参数设置为空,并使用lsnrctl services命令确认设置已经生效:
SQL> alter system set remote_listener='' sid='rac1';
System altered.
SQL> alter system set remote_listener='' sid='rac2';
System altered.
同时将客户端tnsname设置中原来的两个IP地址改为一个IP地址,即将:
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.0.81)(PORT = 1521))
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.0.82)(PORT = 1521))
改为:
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.0.81)(PORT = 1521))
退出sqlplus,再次运行sqlplus,进行跟上面同样的测试: Read the rest of this entry