Oracle RAC 負載均衡測試(結合伺服器端與客戶端)
阿新 • • 發佈:2019-01-07
原文地址:http://blog.csdn.net/leshami/article/details/8072367
Oracle RAC 負載均衡使得從客戶端發起的連線能夠有效地分配到監聽器負載較小的例項上。有兩種方式實現客戶端負載均衡,一是通過配置客戶端的load_balance,一是通過配置伺服器端的remote_listener引數。兩種方式各有優劣,而且兩者並不相互排斥,因此可以結合兩種方式來更加有效的實現負載均衡。本文將描述兩者結合的使用情況(oralce 10g rac)。
本文的測試將結合前篇文章使用的指令碼與樣例,是前兩篇測試的一個總結。
一、配置需求
- 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]
- 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
- #監聽器路由的概念是指基於伺服器端的負載均衡
- #即伺服器端的監聽器根據自身以及遠端監聽器的負載情況來確定將當前的連線請求轉發到本地或遠端,此即為路由。
三、更多參考
有關基於使用者管理的備份和備份恢復的概念請參考
有關RMAN的備份恢復與管理請參考
有關ORACLE體系結構請參考