Oracle RAC 负载均衡测试(结合服务器端与客户端)
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Oracle RAC 负载均衡测试(结合服务器端与客户端)相关的知识,希望对你有一定的参考价值。
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)
- [email protected]:~> 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)
- )
- )
- [email protected]:~> 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
- [email protected]:~> 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
- [email protected]:~> 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)
- )
- )
二、测试Load Balance
- #还是使用之前的脚步来进行测试
- #Author : Robinson
- #Blog : http://blog.csdn.net/robinson_0612
- [email protected]:~> more load_balance.sh
- #!/bin/bash
- for i in {1..1000}
- do
- echo $i
- sqlplus -S system/[email protected] <<EOF
- select instance_name from v\$instance;
- EOF
- sleep 1
- done
- exit 0
- [email protected]:~> ./load_balance.sh >load_bal.log
- #查看日志
- [email protected]:~> grep GOBO4A load_bal.log |wc -l
- 750
- [email protected]:~> grep GOBO4B load_bal.log |wc -l
- 250
- #查看监听器的日志
- [email protected]:/u01/oracle/db/network/log> grep establish listener_bo2dbp.log |wc -l
- 894
- [email protected]:/u01/oracle/db/network/log> grep INSTANCE_NAME=GOBO4 listener_bo2dbp.log |wc -l
- 415
- #从上面的查询中可以得知,节点bo2dbp总共接受了894个连接请求,而有415连接请求是由bo2dbs转发过来的
- #因此,实际上从客户端发起到bo2dbp的实际连接请求数为894-415=479
- #下面来看在节点bo2dbs上的监听日志
- [email protected]:/u01/oracle/db/network/log> grep establish listener_bo2dbs.log |wc -l
- 665
- [email protected]:/u01/oracle/db/network/log> grep INSTANCE_NAME=GOBO4 listener_bo2dbs.log |wc -l
- 144
- #从上面的查询中可知,节点bo2dbs总共接受了665个连接请求,而有144个连接请求是由bo2dbp转发过来的
- #因此,实际上从客户端发起到bo2dbs的实际连接请求数为655-144=511
- #从上面的结果可知,
- #基于客户端的连接请求数为节点bo2dbp为479,节点bo2dbs为511
- #监听器路由到本地实例数目为,节点bo2dbp,479-144=335,节点bo2dbs,511-415=96
- #远程监听器路由道本地实例的数据为,节点bo2dpb为415,节点bo2dbs为144
- #监听器路由的概念是指基于服务器端的负载均衡
- #即服务器端的监听器根据自身以及远程监听器的负载情况来确定将当前的连接请求转发到本地或远程,此即为路由。
- 转:http://blog.csdn.net/leshami/article/details/8072367
以上是关于Oracle RAC 负载均衡测试(结合服务器端与客户端)的主要内容,如果未能解决你的问题,请参考以下文章
Oracle RAC 服务器端连接负载均衡(Load Balance)