Oracle RAC 负载均衡使得从客户端发起的连接能够有效地分配到监听器负载较小的实例上。有两种方式实现客户端负载均衡,一是通过配置客户端的load_balance,一是通过配置服务器端的remote_listener参数。两种方式各有优劣,而且两者并不相互排斥,因此可以结合两种方式来更加有效的实现负载均衡。本文将描述两者结合的使用情况(oralce 10g rac)。
有关客户端与服务端负载均衡的单独测试请参考:
Oracle RAC 客户端连接负载均衡(Load Balance)
Oracle RAC 服务器端连接负载均衡(Load Balance)
本文的测试将结合前篇文章使用的脚本与样例,是前两篇测试的一个总结。
一、配置需求
1、服务器端各节点监听器正常提供服务,如果使用非缺省的1521端口,请参考 ORACLE RAC 下非缺省端口监听配置(listener.ora tnsnames.ora)
oracle@bo2dbp:~> more $ORACLE_HOME/network/admin/listener.ora
# listener.ora.bo2dbp Network Configuration File: /u01/oracle/db/network/admin/listener.ora.bo2dbp
# Generated by Oracle configuration tools.
LISTENER_BO2DBP =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = bo2dbp-vip.2gotrade.com)(PORT = 1521)(IP = FIRST))
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.7.51)(PORT = 1521)(IP = FIRST))
)
)
SID_LIST_LISTENER_BO2DBP =
(SID_LIST =
(SID_DESC =
(SID_NAME = PLSExtProc)
(ORACLE_HOME = /u01/oracle/db)
(PROGRAM = extproc)
)
)
oracle@bo2dbp:~> lsnrctl status
Service "GOBO4" has 2 instance(s).
Instance "GOBO4A", status READY, has 2 handler(s) for this service...
Instance "GOBO4B", status READY, has 1 handler(s) for this service...
2、服务器端的remote_listener参数设置
要求remote_listener参数的连接标识符在服务器端的tnsnames.ora中有对应的条目
SQL> show parameter listener
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
local_listener string
remote_listener string remote_lsnr_gobo4
oracle@bo2dbp:~> more $ORACLE_HOME/network/admin/tnsnames.ora
# tnsnames.ora Network Configuration File: /u01/oracle/db/network/admin/tnsnames.ora
# Generated by Oracle configuration tools.
remote_lsnr_gobo4 =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.7.61)(PORT = 1521))
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.7.62)(PORT = 1521))
)
3、客户端tnsnames.ora中启用load_balance
oracle@SZDB:~> tail -11 $ORACLE_HOME/network/admin/tnsnames.ora
GOBO4 =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.7.61)(PORT = 1521))
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.7.62)(PORT = 1521))
(LOAD_BALANCE = yes)
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = GOBO4)
)
)