Oracle Instance Caging技術
Ref: https://blog.csdn.net/hijk139/article/details/7714125
當多個Instance運行在同一台伺服器上時,為了避免Instance間的相互影響,從oracle 11gr2開始推出了Instance Caging的概念。Instance Caging能夠限制資料庫Instance使用的CPU資源。使用Instance Caging,只需要設置CPU_COUT和resource_manager_plan兩個參數。該功能可以用於的資料庫資源整合,而取代之前的虛擬化和分區等傳統的資源切割方法
1,打開swingbench準備設置後進行壓力測試(具體方法見前面文章)
2,查看伺服器的CPU個數
select value from v$osstat where stat_name = 'NUM_CPUS';
3,開啟Instance Caging,只需設置兩個參數即可
alter system set cpu_count = 4;
alter system set resource_manager_plan = 'default_plan';
備註:這個地方很奇怪,第一次使用報錯ORA-00450,經過一段時間後,設置竟然成功了
4,驗證功能已經啟用
SQL> select instance_caging from v$rsrc_plan where is_top_plan = 'TRUE';
INS
---
ON
SQL> show parameter cpu_count;
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
cpu_count integer 4
5,查看功能使用情況
SQL> select to_char(begin_time, 'HH24:MI') time, sum(avg_running_sessions) avg_running_sessions, sum(avg_waiting_sessions) avg_waiting_sessions from v$rsrcmgrmetric_history group by begin_time order by begin_time;
TIME AVG_RUNNING_SESSIONS AVG_WAITING_SESSIONS
----- -------------------- --------------------
14:48 .82905 .000083333
14:49 .536 .40295
14:50 .334233333 .060016667
17:30 8.53193333 4.39328333
17:31 15.85885 .0001
17:32 9.46965 22.3486667
avg_running_sessions是一分鐘內的活動sessions數,如果次數遠小於CPU_COUNT,這Instance遠沒有達到限制。如果AVG_WAITING_SESSIONS很大,這系統基本達到最大限制了
6,可以動態的調整CPU_COUNT來調整Instance使用的資源。下麵是測試結果
a, 設置cpu_count為32,即不設置限制。
SQL> alter system set cpu_count =32;
開始壓力測試,PC伺服器的TPMC達到45萬TPMC,CPU利用率75%左右
09:44:17 all 69.73 0.00 5.65 2.83 0.00 21.79
09:44:27 all 71.52 0.00 5.81 2.69 0.00 19.99
09:44:37 all 61.98 0.00 5.12 2.91 0.00 29.99
09:44:47 all 69.76 0.00 5.66 3.58 0.00 21.00
b, 設置InstanceCaging功能,即限制CPU_cout為16,資料庫出現大量resmgr:cpu quantum等待事件(這個和資源管理有關),此時系統利用率65%左右,但%user為50%左右,即16個cpu.TPMC為20萬。能力受到限制
SQL> alter system set cpu_count=16;
09:49:28 CPU %user %nice %system %iowait %steal %idle
09:49:38 all 53.91 0.00 8.78 1.81 0.00 35.50
09:49:48 all 52.15 0.00 8.66 2.88 0.00 36.31
09:49:58 all 53.91 0.00 8.37 1.85 0.00 35.87
09:50:08 all 50.98 0.00 8.76 2.66 0.00 37.60
09:50:18 all 53.24 0.00 8.42 1.91 0.00 36.43
c, cpu_count=8;%User為27%,基本保持在8個CPU數量,TPMC 10萬左右
09:57:38 CPU %user %nice %system %iowait %steal %idle
09:57:48 all 27.96 0.00 4.99 3.01 0.00 64.03
09:57:58 all 27.82 0.00 4.47 2.49 0.00 65.21
09:58:08 all 27.97 0.00 4.54 2.31 0.00 65.18
09:58:18 all 27.90 0.00 4.50 2.25 0.00 65.34
d,查看動態視圖avg_running_sessions和cpu_count基本一致,說明已經達到最大限度了
SQL> select to_char(begin_time, 'HH24:MI') time, sum(avg_running_sessions) avg_running_sessions, sum(avg_waiting_sessions) avg_waiting_sessions from v$rsrcmgrmetric_history group by begin_time order by begin_time;
09:44 18.4489333 .017666667
09:45 14.9326833 34.1877333
09:46 14.5135167 44.6346167
09:47 13.7069167 41.3688333
09:48 14.3363833 43.9001667
09:49 14.3411 43.345
09:50 14.2703333 43.2445
09:51 8.04406667 58.9471667
09:52 1.86445 15.7961833
09:53 7.1256 62.3546667
09:54 7.32335 64.64055
09:55 7.30835 64.3774
09:56 7.2753 64.0636333
09:57 7.35958333 65.0054
09:58 7.23883333 64.4193333
09:59 7.06161667 62.3264833
10:00 7.3477 66.1179333
10:01 7.3673 66.7519
10:02 5.44061667 48.0556167
10:03 .009183333 0
10:04 .006833333 0
10:05 .00545 0
10:06 .0062 0
10:07 1.5357 12.9266833
10:08 7.35653333 65.4692333
10:09 7.36343333 65.6357833
10:10 7.1894 63.24075
參考文檔
Configuring and Monitoring Instance Caging [ID 1362445.1]
http://www.oracle.com/technetwork/database/performance/instance-caging-wp-166854.pdf
http://www.dbi-services.com/index.php/blog/entry/oracle-11g-instance-caging-limit-database-cpu-consumption
沒有留言:
張貼留言