实验环境:vmware server+ rh4.5+ oracle 10.2.0.1.0 + rac,客户端 xporacle配置参数:
SQL> show parameter instance_name NAME TYPE VALUE ------------------------------------ ----------- ------------------------------ instance_name string zzcgs1 SQL> show parameter listener NAME TYPE VALUE ------------------------------------ ----------- ------------------------------ local_listener string (ADDRESS = (PROTOCOL = TCP)(HO ST = 192.168.1.111)(PORT = 152 1)) remote_listener string LISTENERS_ZZCGS
SQL> show parameter instance_name NAME TYPE VALUE ------------------------------------ ----------- ------------------------------ instance_name string zzcgs2 SQL> show parameter listener NAME TYPE VALUE ------------------------------------ ----------- ------------------------------ local_listener string (ADDRESS = (PROTOCOL = TCP)(HO ST = 192.168.1.112)(PORT = 152 1)) remote_listener string LISTENERS_ZZCGSLISTENER_ZZCGS参数在数据库上tnsnames.ora中的配置为:
ZZCGS = (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = node1-vip.orademo.org)(PORT = 1521)) (ADDRESS = (PROTOCOL = TCP)(HOST = node2-vip.orademo.org)(PORT = 1521)) (LOAD_BALANCE = yes) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = zzcgs) ) ) LISTENERS_ZZCGS = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = node1-vip.orademo.org)(PORT = 1521)) (ADDRESS = (PROTOCOL = TCP)(HOST = node2-vip.orademo.org)(PORT = 1521)) )客户端中tnsnames.ora中对TAF配置如下:
ZZCGSRAC= (DESCRIPTION = (LOAD_BALANCE=ON) (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.111)(PORT = 1521)) (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.112)(PORT = 1521)) ) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = zzcgs) (FAILOVER_MODE = (TYPE = SELECT) (METHOD = BASIC) ) ) )使用JDBC连接的测试结果参考一
使用sqlplus连接时,即使LOAD_BALANCE=OFF,在一个sqlplus中两个实例之间也可以切换。
当配置FAILOVER_MODE,通过下列语句可以查询。
SELECT MACHINE, FAILOVER_TYPE, FAILOVER_METHOD, FAILED_OVER, COUNT(*) FROM V$SESSION GROUP BY MACHINE, FAILOVER_TYPE, FAILOVER_METHOD, FAILED_OVER以下是测试过程:
SQL> select instance_name from v$instance; INSTANCE_NAME -------------------------------- zzcgs1$ srvctl stop inst -d zzcgs -i zzcgs1 //在节点1或2上执行,关闭zzcgs1
不断执行上述语句先后出现以下错误:
ORA-01089: immediate shutdown in progress - no operations are permitted
ORA-03113: 通信通道的文件结束
ORA-01012: 没有登录
疑惑一、无论在客户端怎么修改tnsnames.ora参数,都无效,对failover_mode中参数的修改也不能立即反应在数据库中。
当(FAILOVER_MODE = (TYPE = SELECT) (METHOD = BASIC) )执行以上的查询语句可行:
MACHINE FAILOVER_TYPE FAILOVER_METHOD FAILED COUNT(*) ------------------------- ------------------ -------------------- ------ ---------- WORKGROUP\WMZPC SELECT BASIC NO 1 node2.orademo.org NONE NONE NO 29 node1.orademo.org NONE NONE NO 2
当(FAILOVER_MODE = (TYPE = SESSION) (METHOD =PRECONNECT) ),使用conn 再次登录并执行时不变,找不到规律所在。
疑惑二、当客户端的tnsnames.ora中配置如下时
rac1= (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.111)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = zzcgs) (INSTANCE_NAME = zzcgs1) (FAILOVER_MODE = (TYPE = SELECT) (METHOD = BASIC) (BACKUP = rac2) ) ) ) rac2= (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.112)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = zzcgs) (INSTANCE_NAME = zzcgs2) (FAILOVER_MODE = (TYPE = SELECT) (METHOD = BASIC) (BACKUP = rac1) ) ) )在作任一节点上查询时,得到的结果都是
MACHINE FAILOVER_TYPE FAILOVER_METHOD FAILED COUNT(*) -------------------- --------------- -------------------- ------ ---------- WORKGROUP\WMZPC NONE NONE NO 1且无法实现runtime load balancing
不解!