监听负载平衡方案

一、监听负载平衡的背景#

dg报表的cron监控时间出现异常。原因是dg后台的cron“6 * * * * /etc/paic/shell/odg_mon_stat_dg.sh”在每个小时06分会连入monitor更新数据。dg报表有300多个dg,每个dg至少连接monitor3次,经ssc分析这是一个连接风暴。
对monitor监听实施监听负载平衡的方案,通过多个监听器的负载均衡和冗余,可以实现对listener crash问题的workaround,如果再次遇到该问题,当LISTENER监听器异常crash时,新连接会自动通过另一个监听器连接,客户端新建连接不会感觉到切换,可以避免客户体验降低。

二、监听负载平衡方案#

1、以本次monitor为例#

monitor为单实例11.2.0.2数据库,GI管理。因此在对当前主机实施监听负载平衡时,要考虑如何在GI配置好HA切换,在所有节点均需配置好脚本。当前listener监听端口为1530,通过新建监听器监听相同地址的其他端口,并且通过修改local listener 参数,可以实现同一个数据库同时对几个监听器的的注册;而在客户端,通过修改相应的tnsnames,添加新的监听地址并指定LOAD_BALANCE 参数为YES 可以实现同时对几个监听器的申请访问,并且实现负载均衡和冗余。
整个方案的实施不需要停止数据库或监听器。
实施监听负载平衡的步骤如下:
1. 添加新的监听
备份原来的监听,cp listener.ora listener.ora.0806bk
为monitor添加新的监听:
现有listener MONITOR =   (DESCRIPTION_LIST =     (DESCRIPTION =       (ADDRESS = (PROTOCOL = TCP)(HOST = 10.33.30.64)(PORT = 1530)(queuesize=1024))     )   ) 考虑到目前dg报表中有300dg库,每个库至少同时连接3monitor,从长远看,日后还会增加同城dg和上海dg,因此添加至5listener vi listener.ora 添加如下内容: SID_LIST_MONITOR2 =   (SID_LIST =     (SID_DESC =       (ORACLE_HOME = /paic/app/oracle/rdbms/11g/11.2.0.2_1)       (SID_NAME = monitor )     )   ) MONITOR2 =   (DESCRIPTION_LIST =     (DESCRIPTION =       (ADDRESS = (PROTOCOL = TCP)(HOST = 10.33.30.64)(PORT = 1531))     )   ) SID_LIST_MONITOR3 =   (SID_LIST =     (SID_DESC =       (ORACLE_HOME = /paic/app/oracle/rdbms/11g/11.2.0.2_1)       (SID_NAME = monitor )     )   ) MONITOR3 =   (DESCRIPTION_LIST =     (DESCRIPTION =       (ADDRESS = (PROTOCOL = TCP)(HOST = 10.33.30.64)(PORT = 1532))     )   )   
SID_LIST_MONITOR4 =   (SID_LIST =     (SID_DESC =       (ORACLE_HOME = /paic/app/oracle/rdbms/11g/11.2.0.2_1)       (SID_NAME = monitor )     )   ) MONITOR4 =   (DESCRIPTION_LIST =     (DESCRIPTION =       (ADDRESS = (PROTOCOL = TCP)(HOST = 10.33.30.64)(PORT = 1533))     )   )   
  
SID_LIST_MONITOR5 =   (SID_LIST =     (SID_DESC =       (ORACLE_HOME = /paic/app/oracle/rdbms/11g/11.2.0.2_1)       (SID_NAME = monitor )     )   ) MONITOR5 =   (DESCRIPTION_LIST =     (DESCRIPTION =       (ADDRESS = (PROTOCOL = TCP)(HOST = 10.33.30.64)(PORT = 1534))     )   )
2. 启动新添加的监听器
lsnrctl start MONITOR2
lsnrctl start MONITOR3
lsnrctl start MONITOR4
lsnrctl start MONITOR5 Lsnrctl Status 查看都为ready,则进行下一步。

3. 修改monitor主机的tns

备份: cp tnsnames.ora tnsnames.ora.0807bk Vi tnsnames.ora

LOCAL_MONITOR =   (DESCRIPTION =     (ADDRESS_LIST =       (ADDRESS = (PROTOCOL = TCP)(HOST = 10.33.30.64)(PORT = 1530))       (ADDRESS = (PROTOCOL = TCP)(HOST = 10.33.30.64)(PORT = 1531))       (ADDRESS = (PROTOCOL = TCP)(HOST = 10.33.30.64)(PORT = 1532))       (ADDRESS = (PROTOCOL = TCP)(HOST = 10.33.30.64)(PORT = 1533))       (ADDRESS = (PROTOCOL = TCP)(HOST = 10.33.30.64)(PORT = 1534))  
    )   ) MONITOR =   (DESCRIPTION =     (LOAD_BALANCE = yes)       (ADDRESS = (PROTOCOL = TCP)(HOST = 10.33.30.64)(PORT = 1530))       (ADDRESS = (PROTOCOL = TCP)(HOST = 10.33.30.64)(PORT = 1531))       (ADDRESS = (PROTOCOL = TCP)(HOST = 10.33.30.64)(PORT = 1532))       (ADDRESS = (PROTOCOL = TCP)(HOST = 10.33.30.64)(PORT = 1533))       (ADDRESS = (PROTOCOL = TCP)(HOST = 10.33.30.64)(PORT = 1534))     (CONNECT_DATA =       (SERVICE_NAME = monitor)     )   )

4. 修改参数

alter system set local_listener='LOCAL_MONITOR' scope=both;

5. 在备机上同样修改listener.ora和tnsnames.ora

6. 配置监听的HA切换脚本
6.1 /oracle_grid/11.2.0/grid/crs/public/monitor增加资源切换的act_lsnr.ksh脚本。
act_lsnr.ksh脚本的作用就是资源切换的时候,起停监听。增加几组act_lsnr.ksh脚本,将每个脚本中的监听名字指定为对应的monitor新增的监听。用以控制新监听的起停。如act_lsnr2.ksh中修改监听名字为monitor2
新增脚本: act_lsnr.ksh act_lsnr2.ksh act_lsnr3.ksh act_lsnr4.ksh act_lsnr5.ksh
6.2 测试脚本能够正常起停新的监听。
6.3 将脚本增加到集群的所有节点上,保持一致。
6.3 通知主机组增加monitor的资源控制,将几个监听都配置好资源管理。
6.3 安排monitor切换测试,验证listeners的正常起停。

7. 在dg client端修改monitor的连接串如下:

MONITOR =   (DESCRIPTION =     (LOAD_BALANCE = yes)        (ADDRESS = (PROTOCOL = TCP)(HOST = monitor.db.paic.com.cn)(PORT = 1530))       (ADDRESS = (PROTOCOL = TCP)(HOST = monitor.db.paic.com.cn)(PORT = 1531))       (ADDRESS = (PROTOCOL = TCP)(HOST = monitor.db.paic.com.cn)(PORT = 1532))       (ADDRESS = (PROTOCOL = TCP)(HOST = monitor.db.paic.com.cn)(PORT = 1533))       (ADDRESS = (PROTOCOL = TCP)(HOST = monitor.db.paic.com.cn)(PORT = 1534))     (CONNECT_DATA =       (SERVICE_NAME = monitor)     )   )

你可能感兴趣的:(监听负载平衡方案)