Oracle RAC服务器端的负载均衡是根据RAC中各节点的连接负荷数情况,将新的连接请求分配到负荷最小的节点上去。当数据库处于运行时,RAC中各节点的PMON进程每3秒会将各自节点的连接负荷数更新到service_register。而对于节点中任意监听器故障或监听器意外失败时,PMON进程会每1秒钟检查当前节点上的监听是否重启,以获得最新的负载信息来及时调整负载均衡。本文主要演示suse 10 + oracle 10g rac下的服务器端的负载均衡。
一、服务器端负载均衡配置
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
-->客户端为suse 10
SZDB:~ # ifconfig eth1 | grep "inet addr"|cut -d " " -f12|cut -d : -f2 #--客户端主机的ip
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
4、检查监听情况
oracle@bo2dbp:~> lsnrctl status
Listening Endpoints Summary...
查看本栏目更多精彩内容:http://www.bianceng.cnhttp://www.bianceng.cn/database/Oracle/