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/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- 簡單瞭解負載均衡負載
- Nginx實現簡單的負載均衡Nginx負載
- Python實現簡單負載均衡Python負載
- 做了反向代理和負載均衡的nginx配置檔案簡單示例(nginx.conf) HTTP負載均衡/TCP負載均衡負載NginxHTTPTCP
- 簡單實踐搭建 nginx 負載均衡Nginx負載
- 負載均衡簡介負載
- jmeter壓力測試實現負載均衡JMeter負載
- 負載均衡技術(二)———常用負載均衡服務介紹負載
- 面試之負載均衡面試負載
- 在 Linux 上用 DNS 實現簡單的負載均衡LinuxDNS負載
- 負載均衡簡介與搭建負載
- nginx負載均衡原理分析到手動編寫簡易負載均衡器Nginx負載
- Nginx 學習系列(二) ————- 負載均衡Nginx負載
- Nginx 學習系列(二) ------------- 負載均衡Nginx負載
- Kubernetes中負載均衡功能簡介負載
- gRPC負載均衡(自定義負載均衡策略)RPC負載
- gRPC負載均衡(客戶端負載均衡)RPC負載客戶端
- 技術|如何為MySQL MGR實現簡單的負載均衡代理?MySql負載
- 負載均衡負載
- gRPC的負載均衡RPC負載
- SpringCloud(二):服務呼叫與負載均衡SpringGCCloud負載
- nginx Win下實現簡單的負載均衡(1)nginx搭建部署Nginx負載
- nginx Win下實現簡單的負載均衡(2)站點共享SessionNginx負載Session
- nginx Win下實現簡單的負載均衡(3)Session的SqlServer模式配置Nginx負載SessionSQLServer模式
- haproxy(單機)+mysql叢集負載均衡MySql負載
- IP負載均衡負載
- WebSocket負載均衡Web負載
- nginx負載均衡Nginx負載
- NGINX 負載均衡Nginx負載
- 【Nginx】負載均衡Nginx負載
- 負載均衡---ribbon負載
- LoadBalancer負載均衡負載
- LVS 負載均衡負載
- JMeter分散式壓測/JMeter負載新增/jmeter負載均衡/jmeter Windows系統壓測負載新增JMeter分散式負載Windows
- OceanBase 負載均衡的魅力負載
- 4.8 負載均衡的概念負載
- 負載均衡的那些事?負載
- 負載均衡的種類負載
- 負載均衡技術(一)———負載均衡技術介紹負載