当前位置:Gxlcms >
数据库问题 >
Oracle RAC 服务器端连接负载均衡(Load Balance)
Oracle RAC 服务器端连接负载均衡(Load Balance)
时间:2021-07-01 10:21:17
帮助过:2人阅读
print?
- 1、为tnsnames.ora 添加相应的网络服务名(每个节点配置)
- 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))
- )
-
- local_lsnr_gobo4a =
- (ADDRESS_LIST =
- (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.7.61)(PORT = 1521))
- )
-
- local_lsnr_gobo4b =
- (ADDRESS_LIST =
- (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.7.62)(PORT = 1521))
- )
-
- 2、设置remote_listener参数
- alter system set remote_listener=‘<net_service_name>‘ scope=both sid=‘*‘;
-
- SQL> show parameter instance_name
-
- NAME TYPE VALUE
-
- instance_name string GOBO4A
- SQL> show parameter listener
-
- NAME TYPE VALUE
-
- local_listener string
- remote_listener string
-
- SQL> alter system set remote_listener=‘remote_lsnr_gobo4‘ scope=both sid=‘*‘;
-
- System altered.
-
- 3、配置客户端tnsnames.ora
-
- SZDB:~ # ifconfig eth1 | grep "inet addr"|cut -d " " -f12|cut -d : -f2 #
- 192.168.7.2
- SZDB:~ # su - oracle
- oracle@SZDB:~> tail -10 $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 = off) #
- (CONNECT_DATA =
- (SERVER = DEDICATED)
- (SERVICE_NAME = GOBO4)
- )
- )
- #Author : Robinson Cheng
- #Blog : http://blog.csdn.net/robinson_0612
-
- 4、检查监听情况
- oracle@bo2dbp:~> lsnrctl status
- Listening Endpoints Summary...
- (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.7.61)(PORT=1521)))
- (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.7.51)(PORT=1521)))
- Services Summary...
- Service "+ASM" has 1 instance(s).
- Instance "+ASM1", status BLOCKED, has 1 handler(s) for this service...
- 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..
- .......
-
- oracle@bo2dbs:~> lsnrctl status
- Listening Endpoints Summary...
- (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.7.62)(PORT=1521)))
- (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.7.52)(PORT=1521)))
- Services Summary...
- Service "+ASM" has 1 instance(s).
- Instance "+ASM2", status BLOCKED, has 1 handler(s) for this service...
- Service "GOBO4" has 2 instance(s).
- Instance "GOBO4A", status READY, has 1 handler(s) for this service...
- Instance "GOBO4B", status READY, has 2 handler(s) for this service...
- ..........
-
- #
- #
- oracle@bo2dbp:/u01/oracle/db/network/log> cat /dev/null>listener_bo2dbp.log
- oracle@bo2dbs:/u01/oracle/db/network/log> cat /dev/null>listener_bo2dbs.log
二、测试服务器端的负载均衡
[python] view plain
copy
print?
- 1、从客户端建立连接
- oracle@SZDB:~> more load_balance.sh
-
- for i in {1..1000}
- do
- echo $i
- sqlplus -S system/oracle@GOBO4 <<EOF
- select instance_name from v\$instance;
- EOF
- sleep 1
- done
- exit 0
- oracle@SZDB:~> ./load_balance.sh >srv_load_bal.log
-
- 2、分析监听日志
- oracle@bo2dbp:/u01/oracle/db/network/log> more listener_bo2dbp.log
- 12-OCT-2012 12:00:10 * service_update * GOBO4B * 0
- 12-OCT-2012 12:00:35 * service_update * GOBO4B * 0
- 12-OCT-2012 12:01:04 * (CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=GOBO4)(CID=(PROGRAM=sqlplus@SZDB)(HOST=SZDB)
- (USER=oracle))) * (ADDRESS=(PROTOCOL=tcp)(HOST=192.168.7.2)(PORT=50322)) * establish * GOBO4 * 0
- 12-OCT-2012 12:01:05 * (CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=GOBO4)(CID=(PROGRAM=sqlplus@SZDB)(HOST=SZDB)
- (USER=oracle))) * (ADDRESS=(PROTOCOL=tcp)(HOST=192.168.7.2)(PORT=50325)) * establish * GOBO4 * 0
- 12-OCT-2012 12:01:07 * (CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=GOBO4)(CID=(PROGRAM=sqlplus@SZDB)(HOST=SZDB)
- (USER=oracle))) * (ADDRESS=(PROTOCOL=tcp)(HOST=192.168.7.2)(PORT=50328)) * establish * GOBO4 * 0
- 12-OCT-2012 12:01:08 * (CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=GOBO4)(CID=(PROGRAM=sqlplus@SZDB)(HOST=SZDB)
- (USER=oracle))) * (ADDRESS=(PROTOCOL=tcp)(HOST=192.168.7.2)(PORT=50330)) * establish * GOBO4 * 0
-
-
-
-
- oracle@bo2dbs:/u01/oracle/db/network/log> more listener_bo2dbs.log
- 12-OCT-2012 12:00:10 * service_update * GOBO4B * 0
- 12-OCT-2012 12:00:10 * service_update * GOBO4B * 0
- 12-OCT-2012 12:00:14 * (CONNECT_DATA=(CID=(PROGRAM=)(HOST=bo2dbs)(USER=oracle))(COMMAND=status)(ARGUMENTS=64)
- (SERVICE=LISTENER_BO2DBS)(VERSION=169870080)) * status * 0
- 12-OCT-2012 12:00:35 * service_update * GOBO4B * 0
- 12-OCT-2012 12:00:35 * service_update * GOBO4B * 0
- 12-OCT-2012 12:01:04 * (CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=GOBO4)(CID=(PROGRAM=sqlplus@SZDB)(HOST=SZDB)
- (USER=oracle))(INSTANCE_NAME=GOBO4B)) * (ADDRESS=(PROTOCOL=tcp)(HOST=192.168.7.2)(PORT=61862)) * establish * GOBO4 * 0
- 12-OCT-2012 12:01:07 * (CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=GOBO4)(CID=(PROGRAM=sqlplus@SZDB)(HOST=SZDB)
- (USER=oracle))(INSTANCE_NAME=GOBO4B)) * (ADDRESS=(PROTOCOL=tcp)(HOST=192.168.7.2)(PORT=61868)) * establish * GOBO4 * 0
- 12-OCT-2012 12:01:09 * (CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=GOBO4)(CID=(PROGRAM=sqlplus@SZDB)(HOST=SZDB)
- (USER=oracle))(INSTANCE_NAME=GOBO4B)) * (ADDRESS=(PROTOCOL=tcp)(HOST=192.168.7.2)(PORT=61872)) * establish * GOBO4 * 0
-
-
-
-
-
-
-
-
-
-
- 3、检查负载均衡结果
- oracle@SZDB:~> grep GOBO4A srv_load_bal.log |wc -l
- 755
- oracle@SZDB:~> grep GOBO4B srv_load_bal.log |wc -l
- 245
-
-
-
-
- oracle@bo2dbp:/u01/oracle/db/network/log> grep establish listener_bo2dbp.log |wc -l
- 1000
-
-
- oracle@bo2dbp:/u01/oracle/db/network/log> grep INSTANCE_NAME=GOBO4 listener_bo2dbp.log |wc -l
- 0
-
-
- oracle@bo2dbs:/u01/oracle/db/network/log> grep establish listener_bo2dbs.log |wc -l
- 245
-
-
- oracle@bo2dbs:/u01/oracle/db/network/log> grep INSTANCE_NAME=GOBO4 listener_bo2dbs.log |wc -l
- 245
-
-
-
-
三、总结
1、服务器端的负载均衡需要配置remote_listener参数,而该参数的值依赖于tnsnames.ora的连接字符串
2、对于基于服务器端的连接负载均衡,监听器会根据当前节点、实例上的连接负载情况进行转发到空闲的实例
3、转发的依据仅仅是当前节点监听的连接数量的多少,而非当前实例的过度负载
4、从上面的测试可以得出,各个节点的连接并不算均衡,是相对的均衡,因此应结合客户端连接负载协同工作
5、对于当前实例的过度负载的情形,应结合配置service方法来实现负载均衡
转:http://blog.csdn.net/leshami/article/details/8064599
Oracle RAC 服务器端连接负载均衡(Load Balance)
标签: