Oracle resource manager

來源:互聯網
上載者:User

oracle resource manager 是對資料庫包括主機資源的再分配

 

二. 兩個軟體包

dbms_resource_manager

dbms_resource_manager_privs

樣本:

dbms_resource_manager.create_pending_area();

建立一個草稿區

DBMS_RESOURCE_MANAGER.CREATE_CONSUMER_RESOURCE

建消費組

dbms_resource_manage.create_plan ()

建立計劃

也可以利用

dbms_resource_manage.create_simple_plan 建立一個簡單計劃

 

例如

       oadb

--------------------

|        |        |

sales組 market組 develop組

60%cpu 20%cpu 20%

 

dbms_resource_manager.create_simple_resource(

simple_plan =>'oadb_plan',

consumer_group1=>'sales',group1_cpu=>60,

consumer_group2=>'market',group1_cpu=>20,

consumer_group3=>'develop',group1_cpu=>20

)

 

就可以自動建立一個簡單資源計劃

 

三 資源分派

 

利用dbms_resource_manager.create_plan_directive 可以指定各個組的資源的分配,包括session_pool,cpu,並行度, undo pool ,切換組 等資訊

1.DBA 可以為每個組設定active session pool,每個cousumer group 同時並發的session 數量,如果超過 了這個數量則會自動進行排隊。

active session pool parameter:

active_sess_pool_p1 :

該consumer group 的並發session 上限 default 1000000

queueing_p1:

session 在隊列中等待的時間上限,超過該時間則會自動cancel. default 1000000 秒

 

2. oracle resource manager 可以評估事務最大執行時間,可以設定max_est_exec_time ,如果resource manager 評估的時間超過了這個時間,系統將不會執行,避免佔用過多的系統資源。

 

3. automotic consumer group switch :

directive 參數:

switch_group : group switch to ,default is null.

swtich_time : active time 啟用時間,過了這個時間就會自動切換到其他組中,default 1000000

swtich_estimate : true-> oracle 使用在切換前的評估執行時間,如果評估時間大於switch_time ,則直接切換,否則就是達到了switch_time 後才進行切換。 DEFAUL : FALSE

4. undo pool 的限額

限制某個consumer group 的undo size : 如果大於的話,則會阻止DML 的執行

default :1000000kB

 

Automatic Consumer Group Switching

This method enables you to control resources by specifying criteria that, if met, causes the automatic switching of sessions to another consumer group. The criteria used to determine switching are:

 

Switch group--specifies the consumer group to which this session is switched if the other (following) criteria are met

Switch time--specifies the length of time that a session can execute before it is switched to another consumer group

Use estimate--specifies whether Oracle is to use its own estimate of how long an operation will execute

The Database Resource Manager switches a running session to switch group if the session is active for more than switch time seconds. Active means that the session is running and consuming resources, not waiting idly for user input or waiting for CPU cycles. The session is allowed to continue running, even if the active session pool for the new group is full. Under these conditions a consumer group can have more sessions running than specified by its active session pool. Once the session finishes its operation and becomes idle, it is switched back to its original group.

 

If use estimate is set to TRUE, the Database Resource Manager uses a predicted estimate of how long the operation will take to complete. If Oracle's predicted estimate is longer than the value specified as the switch time, then Oracle switches the session before execution starts. If this parameter is not set, the operation starts normally and only switches groups when other switch criteria are met.

 

 

四:驗證草稿區

 

驗證 pending area

dbms_resource_manager.validate_pending_area()

提交

dbms_resource_manager.SUBMIT_pending_area()

預設調用dbms_resource_manager.validate_pending_area()

注意:

但是如果修改錯誤,則submit_penging_area過程會失敗,自create_pending_area過程以來所有對資源計劃的修改都將丟失,pending區也被清空。想要進行修改,只能重新create_pengding_area,並重做前面的步驟。所以最好在submit_pending_area前加上validate_pending_area。

oracle resource 最多32 個group

 

五. 分配使用者到consumer group

assign user to group:

將使用者OE 分配到組oltp 中

dbms_resource_manager_privs.grant_switch_comsumer_group (

grantee_name=>'OE',

consumer_group =>'OLTP',

grant_option=> false

)

set initial group to user:

就是使用者登陸後,自動屬於那個consumer_group ,如果不指定,則系統自動認為屬於default_consumer_group 。

dbms_resource_manager.set_initial_consumer_group (

user =>'OE',

consumer_group=>'OLTP'

)

 

六: 指定系統參數-spfile 參數

 

show parameter resource_manager_plan

alter system set resource_manager_plan=erp_plan ;

如果該計劃不存在,則會在啟動的alert日誌中,報告出錯

在session 層級可以切換consumer group

dbms_session.switch_current_consumer_group() 將當前session使用者切換到另一個consumer組中

DBA用許可權切換其他的session 到另一個consumer group ,將session 7 切換到oltp 組

dbms_resource_manager.switch_consumer_group_for_sess (

session_id=>7,

serial => 13,

consumer_group=>'OLTP'

)

也可以將某個user 的全部session 切換到一個組

dbms_resource_manager.switch_consumer_group_for_user()

 

七. 與resource manager 有關的 視圖

dba_rsrc_*

 

dba_user 中的 initial_rsrc_consumer_group

 

 

 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.