監聽負載平衡方案

1、監聽負載平衡的背景#

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時,新鏈接會自動經過另外一個監聽器鏈接,客戶端新建鏈接不會感受到切換,能夠避免客戶體驗下降。 shell

2、監聽負載平衡方案#

一、以本次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. 修改參數 oracle

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的正常起停。 app

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)     )   )
相關文章
相關標籤/搜索