RAC負載均衡的簡單測試(二)
Rac環境安裝完成之後,打算簡單測試一下Oracle RAC的負載均衡功能。
這篇繼續討論負載均衡的特性。
RAC負載均衡的簡單測試(一):http://yangtingkun.itpub.net/post/468/279433
上一篇的測試中可以看到,當兩個例項的負載相當的時候,新連線會平均分配到兩個例項上去。
下面看看如果其中一個例項的連線數明顯大於另一個例項的情況。增加連線TESTRAC2例項的連線數,這裡使用的方法是在racnode2資料庫上使用直接連線的方式:
$ sqlplus ndmain
SQL*Plus: Release 10.2.0.2.0 - Production on 星期四 3月 22 19:24:23 2007
Copyright (c) 1982, 2005, Oracle. All Rights Reserved.
輸入口令:
連線到:
Oracle Database 10g Enterprise Edition Release 10.2.0.2.0 - 64bit Production
With the Partitioning, Real Application Clusters, OLAP and Data Mining options
SQL> host
$ sqlplus ndmain
SQL*Plus: Release 10.2.0.2.0 - Production on 星期四 3月 22 19:24:28 2007
Copyright (c) 1982, 2005, Oracle. All Rights Reserved.
輸入口令:
連線到:
Oracle Database 10g Enterprise Edition Release 10.2.0.2.0 - 64bit Production
With the Partitioning, Real Application Clusters, OLAP and Data Mining options
SQL> host
$ sqlplus ndmain
SQL*Plus: Release 10.2.0.2.0 - Production on 星期四 3月 22 19:24:33 2007
Copyright (c) 1982, 2005, Oracle. All Rights Reserved.
輸入口令:
連線到:
Oracle Database 10g Enterprise Edition Release 10.2.0.2.0 - 64bit Production
With the Partitioning, Real Application Clusters, OLAP and Data Mining options
SQL> host
$ sqlplus ndmain
SQL*Plus: Release 10.2.0.2.0 - Production on 星期四 3月 22 19:24:37 2007
Copyright (c) 1982, 2005, Oracle. All Rights Reserved.
輸入口令:
連線到:
Oracle Database 10g Enterprise Edition Release 10.2.0.2.0 - 64bit Production
With the Partitioning, Real Application Clusters, OLAP and Data Mining options
SQL> host
$ sqlplus ndmain
SQL*Plus: Release 10.2.0.2.0 - Production on 星期四 3月 22 19:24:44 2007
Copyright (c) 1982, 2005, Oracle. All Rights Reserved.
輸入口令:
連線到:
Oracle Database 10g Enterprise Edition Release 10.2.0.2.0 - 64bit Production
With the Partitioning, Real Application Clusters, OLAP and Data Mining options
SQL> host
$ sqlplus ndmain
SQL*Plus: Release 10.2.0.2.0 - Production on 星期四 3月 22 19:24:48 2007
Copyright (c) 1982, 2005, Oracle. All Rights Reserved.
輸入口令:
連線到:
Oracle Database 10g Enterprise Edition Release 10.2.0.2.0 - 64bit Production
With the Partitioning, Real Application Clusters, OLAP and Data Mining options
SQL> host
$ sqlplus ndmain
SQL*Plus: Release 10.2.0.2.0 - Production on 星期四 3月 22 19:24:54 2007
Copyright (c) 1982, 2005, Oracle. All Rights Reserved.
輸入口令:
連線到:
Oracle Database 10g Enterprise Edition Release 10.2.0.2.0 - 64bit Production
With the Partitioning, Real Application Clusters, OLAP and Data Mining options
SQL> host
$ sqlplus ndmain
SQL*Plus: Release 10.2.0.2.0 - Production on 星期四 3月 22 19:25:00 2007
Copyright (c) 1982, 2005, Oracle. All Rights Reserved.
輸入口令:
連線到:
Oracle Database 10g Enterprise Edition Release 10.2.0.2.0 - 64bit Production
With the Partitioning, Real Application Clusters, OLAP and Data Mining options
SQL>
查詢目前資料庫的連線情況:
SQL> SELECT INST_ID, COUNT(*) FROM GV$SESSION GROUP BY INST_ID;
INST_ID COUNT(*)
---------- ----------
1 31
2 38
下面嘗試多次連線,並檢查連線的例項:
SQL> CONN NDMAIN/NDMAIN@TESTRAC已連線。
SQL> SELECT INSTANCE_NAME FROM V$INSTANCE;
INSTANCE_NAME
----------------
testrac2
SQL> CONN NDMAIN/NDMAIN@TESTRAC已連線。
SQL> SELECT INSTANCE_NAME FROM V$INSTANCE;
INSTANCE_NAME
----------------
testrac1
SQL> CONN NDMAIN/NDMAIN@TESTRAC已連線。
SQL> SELECT INSTANCE_NAME FROM V$INSTANCE;
INSTANCE_NAME
----------------
testrac2
SQL> CONN NDMAIN/NDMAIN@TESTRAC已連線。
SQL> SELECT INSTANCE_NAME FROM V$INSTANCE;
INSTANCE_NAME
----------------
testrac1
SQL> CONN NDMAIN/NDMAIN@TESTRAC已連線。
SQL> SELECT INSTANCE_NAME FROM V$INSTANCE;
INSTANCE_NAME
----------------
testrac2
發現連線到兩個例項的機率仍然是一樣的。看看連續啟動多個連線的情況:
E:>SQLPLUS NDMAIN/NDMAIN@TESTRAC
SQL*Plus: Release 10.2.0.1.0 - Production on 星期四 3月 22 19:27:05 2007
Copyright (c) 1982, 2005, Oracle. All rights reserved.
連線到:
Oracle Database 10g Enterprise Edition Release 10.2.0.2.0 - 64bit Production
With the Partitioning, Real Application Clusters, OLAP and Data Mining options
SQL> SELECT INSTANCE_NAME FROM V$INSTANCE;
INSTANCE_NAME
----------------
testrac1
SQL> HOST
Microsoft Windows 2000 [Version 5.00.2195]
(C) 版權所有 1985-2000 Microsoft Corp.
E:>SQLPLUS NDMAIN/NDMAIN@TESTRAC
SQL*Plus: Release 10.2.0.1.0 - Production on 星期四 3月 22 19:27:18 2007
Copyright (c) 1982, 2005, Oracle. All rights reserved.
連線到:
Oracle Database 10g Enterprise Edition Release 10.2.0.2.0 - 64bit Production
With the Partitioning, Real Application Clusters, OLAP and Data Mining options
SQL> SELECT INSTANCE_NAME FROM V$INSTANCE;
INSTANCE_NAME
----------------
testrac2
SQL> HOST
Microsoft Windows 2000 [Version 5.00.2195]
(C) 版權所有 1985-2000 Microsoft Corp.
E:>SQLPLUS NDMAIN/NDMAIN@TESTRAC
SQL*Plus: Release 10.2.0.1.0 - Production on 星期四 3月 22 19:27:31 2007
Copyright (c) 1982, 2005, Oracle. All rights reserved.
連線到:
Oracle Database 10g Enterprise Edition Release 10.2.0.2.0 - 64bit Production
With the Partitioning, Real Application Clusters, OLAP and Data Mining options
SQL> SELECT INSTANCE_NAME FROM V$INSTANCE;
INSTANCE_NAME
----------------
testrac1
SQL> HOST
Microsoft Windows 2000 [Version 5.00.2195]
(C) 版權所有 1985-2000 Microsoft Corp.
E:>SQLPLUS NDMAIN/NDMAIN@TESTRAC
SQL*Plus: Release 10.2.0.1.0 - Production on 星期四 3月 22 19:27:40 2007
Copyright (c) 1982, 2005, Oracle. All rights reserved.
連線到:
Oracle Database 10g Enterprise Edition Release 10.2.0.2.0 - 64bit Production
With the Partitioning, Real Application Clusters, OLAP and Data Mining options
SQL> SELECT INSTANCE_NAME FROM V$INSTANCE;
INSTANCE_NAME
----------------
testrac2
可以看到,結果仍然是50%的機率。難道負載均衡不考慮例項本身的負載,只是對新增連線進行平均分配?
其實並不是這樣,關鍵在於負載均衡的功能是透過LISTENER來實現的。而在上面增加TESTRAC2上的連線數的時候,採用的是本地連線方式,恰恰繞過了LISTENER,對於LISTENER來說,這些新增的會話都是不可見的。因此,得到的結果當然和原來的一致。
下面斷開剛才連線的所有會話:
SQL> SELECT INST_ID, COUNT(*) FROM GV$SESSION GROUP BY INST_ID;
INST_ID COUNT(*)
---------- ----------
1 31
2 30
然後以TESTRAC2為服務名,連線到RAC的TESTRAC2例項上:
$ sqlplus ndmain/ndmain@testrac2
SQL*Plus: Release 10.2.0.2.0 - Production on 星期四 3月 22 21:14:44 2007
Copyright (c) 1982, 2005, Oracle. All Rights Reserved.
連線到:
Oracle Database 10g Enterprise Edition Release 10.2.0.2.0 - 64bit Production
With the Partitioning, Real Application Clusters, OLAP and Data Mining options
SQL> host
$ sqlplus ndmain/ndmain@testrac2
SQL*Plus: Release 10.2.0.2.0 - Production on 星期四 3月 22 21:14:52 2007
Copyright (c) 1982, 2005, Oracle. All Rights Reserved.
連線到:
Oracle Database 10g Enterprise Edition Release 10.2.0.2.0 - 64bit Production
With the Partitioning, Real Application Clusters, OLAP and Data Mining options
SQL> host
$ sqlplus ndmain/ndmain@testrac2
SQL*Plus: Release 10.2.0.2.0 - Production on 星期四 3月 22 21:14:55 2007
Copyright (c) 1982, 2005, Oracle. All Rights Reserved.
連線到:
Oracle Database 10g Enterprise Edition Release 10.2.0.2.0 - 64bit Production
With the Partitioning, Real Application Clusters, OLAP and Data Mining options
SQL> host
$ sqlplus ndmain/ndmain@testrac2
SQL*Plus: Release 10.2.0.2.0 - Production on 星期四 3月 22 21:14:59 2007
Copyright (c) 1982, 2005, Oracle. All Rights Reserved.
連線到:
Oracle Database 10g Enterprise Edition Release 10.2.0.2.0 - 64bit Production
With the Partitioning, Real Application Clusters, OLAP and Data Mining options
SQL> host
$ sqlplus ndmain/ndmain@testrac2
SQL*Plus: Release 10.2.0.2.0 - Production on 星期四 3月 22 21:15:04 2007
Copyright (c) 1982, 2005, Oracle. All Rights Reserved.
連線到:
Oracle Database 10g Enterprise Edition Release 10.2.0.2.0 - 64bit Production
With the Partitioning, Real Application Clusters, OLAP and Data Mining options
SQL> host
$ sqlplus ndmain/ndmain@testrac2
SQL*Plus: Release 10.2.0.2.0 - Production on 星期四 3月 22 21:15:14 2007
Copyright (c) 1982, 2005, Oracle. All Rights Reserved.
連線到:
Oracle Database 10g Enterprise Edition Release 10.2.0.2.0 - 64bit Production
With the Partitioning, Real Application Clusters, OLAP and Data Mining options
SQL>
再次測試連線例項的情況:
SQL> SELECT INST_ID, COUNT(*) FROM GV$SESSION GROUP BY INST_ID;
INST_ID COUNT(*)
---------- ----------
1 31
2 36
SQL> CONN NDMAIN/NDMAIN@TESTRAC已連線。
SQL> SELECT INSTANCE_NAME FROM V$INSTANCE;
INSTANCE_NAME
----------------
testrac1
SQL> CONN NDMAIN/NDMAIN@TESTRAC已連線。
SQL> SELECT INSTANCE_NAME FROM V$INSTANCE;
INSTANCE_NAME
----------------
testrac1
SQL> CONN NDMAIN/NDMAIN@TESTRAC已連線。
SQL> SELECT INSTANCE_NAME FROM V$INSTANCE;
INSTANCE_NAME
----------------
testrac1
SQL> DISC從 Oracle Database 10g Enterprise Edition Release 10.2.0.2.0 - 64bit Production
With the Partitioning, Real Application Clusters, OLAP and Data Mining options 斷開
可以看到,連線時Oracle都會將會話連線到TESTRAC1上。下面看看連續啟動多個會話,Oracle如何在例項間分配會話:
E:>SQLPLUS NDMAIN/NDMAIN@TESTRAC
SQL*Plus: Release 10.2.0.1.0 - Production on 星期四 3月 22 21:19:41 2007
Copyright (c) 1982, 2005, Oracle. All rights reserved.
連線到:
Oracle Database 10g Enterprise Edition Release 10.2.0.2.0 - 64bit Production
With the Partitioning, Real Application Clusters, OLAP and Data Mining options
SQL> SELECT INSTANCE_NAME FROM V$INSTANCE;
INSTANCE_NAME
----------------
testrac1
SQL> HOST
Microsoft Windows 2000 [Version 5.00.2195]
(C) 版權所有 1985-2000 Microsoft Corp.
E:>SQLPLUS NDMAIN/NDMAIN@TESTRAC
SQL*Plus: Release 10.2.0.1.0 - Production on 星期四 3月 22 21:19:59 2007
Copyright (c) 1982, 2005, Oracle. All rights reserved.
連線到:
Oracle Database 10g Enterprise Edition Release 10.2.0.2.0 - 64bit Production
With the Partitioning, Real Application Clusters, OLAP and Data Mining options
SQL> SELECT INSTANCE_NAME FROM V$INSTANCE;
INSTANCE_NAME
----------------
testrac1
SQL> HOST
Microsoft Windows 2000 [Version 5.00.2195]
(C) 版權所有 1985-2000 Microsoft Corp.
E:>SQLPLUS NDMAIN/NDMAIN@TESTRAC
SQL*Plus: Release 10.2.0.1.0 - Production on 星期四 3月 22 21:20:12 2007
Copyright (c) 1982, 2005, Oracle. All rights reserved.
連線到:
Oracle Database 10g Enterprise Edition Release 10.2.0.2.0 - 64bit Production
With the Partitioning, Real Application Clusters, OLAP and Data Mining options
SQL> SELECT INSTANCE_NAME FROM V$INSTANCE;
INSTANCE_NAME
----------------
testrac1
SQL>
根據上面的測試可以看出,Oracle的負載均衡和例項透過LISTENER建立的連線數有關。
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/4227/viewspace-69237/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- RAC負載均衡的簡單測試(三)負載
- RAC負載均衡的簡單測試(一)負載
- RAC負載均衡的簡單測試(四)負載
- 簡單測試nginx1.90做TCP協議負載均衡的功能NginxTCP協議負載
- TestLoadBalancer測試均衡負載負載
- [zt] RAC的負載均衡負載
- 簡單瞭解負載均衡負載
- Nginx實現簡單的負載均衡Nginx負載
- Nginx簡單的負載均衡配置示例Nginx負載
- 關於負載均衡的簡單總結負載
- ORACLE 11G負載均衡測試Oracle負載
- 淺談RAC中的負載均衡負載
- 簡單實踐搭建 nginx 負載均衡Nginx負載
- Python實現簡單負載均衡Python負載
- 負載均衡簡介負載
- WEBLOGIC連線OracleRAC的負載均衡測試(轉載)WebOracle負載
- jmeter壓力測試實現負載均衡JMeter負載
- 負載均衡技術(二)———常用負載均衡服務介紹負載
- Oracle RAC的TAF簡單測試Oracle
- 搭建LVS負載均衡測試環境負載
- 【RAC】RAC中的負載均衡和故障切換--TAF配置負載
- 配置 RAC 負載均衡與故障轉移負載
- Oracle RAC 客戶端負載均衡配置Oracle客戶端負載
- 負載均衡簡介與搭建負載
- 靈活實現RAC三節點的負載均衡及TAF配置(二)負載
- 負載均衡探測器lbd負載
- 在 Linux 上用 DNS 實現簡單的負載均衡LinuxDNS負載
- nginx負載均衡原理分析到手動編寫簡易負載均衡器Nginx負載
- Nginx 學習系列(二) ------------- 負載均衡Nginx負載
- Nginx 學習系列(二) ————- 負載均衡Nginx負載
- Haproxy和Nginx負載均衡測試效果對比記錄Nginx負載
- 簡述負載均衡&CDN技術負載
- Nginx反向代理+負載均衡簡單實現(https方式)Nginx負載HTTP
- 負載均衡負載
- 技術|如何為MySQL MGR實現簡單的負載均衡代理?MySql負載
- gRPC負載均衡(客戶端負載均衡)RPC負載客戶端
- gRPC負載均衡(自定義負載均衡策略)RPC負載
- 負載均衡的迷惑負載