一、配置过程:
1、先配置两个节点的tnsnames.ora文件,包含下面的内容:
failover =
(DESCRIPTION =
(enable=broken)
(LOAD_BALANCE = yes)
(ADDRESS = (PROTOCOL = TCP)(HOST = jxgs550a)(PORT = 1521))
(ADDRESS = (PROTOCOL = TCP)(HOST = jxgs550b)(PORT = 1521))
(CONNECT_DATA =
(SERVICE_NAME = jxdc.jxgs.gov)
(failover_mode=(type=select)(method=basic))
)
)
LISTENER_RACa =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = jxgs550a)(PORT = 1521))
)
LISTENER_RACb =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = jxgs550b)(PORT = 1521))
)
LISTENER_RAC =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = jxgs550a)(PORT = 1521))
(ADDRESS = (PROTOCOL = TCP)(HOST = jxgs550b)(PORT = 1521))
)
2、执行下面的命令,修改local_listener和remote_listener的值:
alter system set local_listener='LISTENER_RACa' scope=both sid='jxdc1';
alter system set remote_listener='LISTENER_RAC' scope=both sid='jxdc1';
alter system set local_listener='LISTENER_RACb' scope=both sid='jxdc2';
alter system set remote_listener='LISTENER_RAC' scope=both sid='jxdc2';
3、分别查看两边监听的状态:
在节点2:
$ lsnrctl service
LSNRCTL for IBM/AIX RISC System/6000: Version 9.2.0.8.0 - Production on 20-JUN-2007 12:19:10
Copyright (c) 1991, 2006, Oracle Corporation. All rights reserved.
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=jxgs550b)(PORT=1521)))
Services Summary...
Service "PLSExtProc" has 1 instance(s).
Instance "PLSExtProc", status UNKNOWN, has 1 handler(s) for this service...
Handler(s):
"DEDICATED" established:0 refused:0
LOCAL SERVER
Service "jxdc.jxgs.gov" has 2 instance(s).
Instance "jxdc1", status READY, has 1 handler(s) for this service...
Handler(s):
"DEDICATED" established:69 refused:0 state:ready
REMOTE SERVER
(ADDRESS=(PROTOCOL=TCP)(HOST=jxgs550a)(PORT=1521))
Instance "jxdc2", status READY, has 2 handler(s) for this service...
Handler(s):
"DEDICATED" established:0 refused:0 state:ready
REMOTE SERVER
(ADDRESS=(PROTOCOL=TCP)(HOST=jxgs550b)(PORT=1521))
"DEDICATED" established:43 refused:0 state:ready
LOCAL SERVER
在节点1:
$ lsnrctl service
LSNRCTL for IBM/AIX RISC System/6000: Version 9.2.0.8.0 - Production on 20-JUN-2007 12:18:02
Copyright (c) 1991, 2006, Oracle Corporation. All rights reserved.
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=jxgs550a)(PORT=1521)))
Services Summary...
Service "PLSExtProc" has 1 instance(s).
Instance "PLSExtProc", status UNKNOWN, has 1 handler(s) for this service...
Handler(s):
"DEDICATED" established:0 refused:0
LOCAL SERVER
Service "jxdc.jxgs.gov" has 2 instance(s).
Instance "jxdc1", status READY, has 2 handler(s) for this service...
Handler(s):
"DEDICATED" established:0 refused:0 state:ready
REMOTE SERVER
(ADDRESS=(PROTOCOL=TCP)(HOST=jxgs550a)(PORT=1521))
"DEDICATED" established:0 refused:0 state:ready
LOCAL SERVER
Instance "jxdc2", status READY, has 1 handler(s) for this service...
Handler(s):
"DEDICATED" established:4 refused:0 state:ready
REMOTE SERVER
(ADDRESS=(PROTOCOL=TCP)(HOST=jxgs550b)(PORT=1521))
4、从其它客户端开一个窗口进行测试,发现有时候可以连接数据库,有时候不能,不能的时候提示不能找到主机。
5、直接在服务器上进行连接没有任何问题。猜想是服务器上在/etc/hosts中定义了名称解析,在客户端则没有,于是将两接点上的tnsnames.ora中机器名称全部修改为IP地址,客户端有时能连接有时不能的问题得到了解决。
6、对这个问题,我个人的看法是当客户端试图连接某个节点的实例时候,监听根据负载均衡的原则决定客户端与哪个节点进行连接,并根据本机上tnsnames.ora将节点信息传递给客户端,客户端再根据相关信息进行连接,因为客户端无法解析机器名称,因此连接不上。
7、设置完毕后,通过语句select inst_id, count(*) from gv$session group by inst_id进行监测,发现负载是均衡的,一度达到实例1上130个会话,实例2上129个会话这样的均衡状态。
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/85922/viewspace-922137/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/85922/viewspace-922137/