oracle resource manager
DESCRIPTION
Oracle Resource Manager Training PPTTRANSCRIPT
Oracle Resource Manager
Kamus@ACOUG
About ACOUG
• ACOUG: All China Oracle User Group
• http://acoug.org
About Me
• 张乐奕 Kamus
• http://www.dbform.com
• Oracle -> 恩墨科技 (http://www.enmou.com)
• Oracle & World of Warcraft
Resource Management
DBA_RSRC_GROUP_MAPPINGS
DBA_RSRC_CONSUMER_GROUPS
DBA_RSRC_PLAN_DIRECTIVES
DBA_RSRC_PLANS
Resource Plan
Element
Resource Plan
Directives
Resource
Consumer Group
Resource
Consumer Group
Resource Plan
Directives
Resource
Consumer Group
Session to Group Mapping
DBA_USERS. INITIAL_RSRC_CONSUMER_GROUP
USERS
Simple Plan Example
DBA_RSRC_CONSUMER_GROUPS.NAME
DBA_RSRC_PLAN_DIRECTIVES.CPU_P1
DBA_RSRC_PLANS.PLANResource Plan
“DAYTIME”
Directives 115%CPU
Consumer Group
“REPORT1”
Consumer Group
“REPORT2”
Directives 285%CPU
Consumer Group
“OTHER_GROUPS”
Sub Plan ExampleResource Plan
“TOP”
Directives 115%CPU
Resource Plan“SUB”
Directives 3
70%CPU
Consumer Group“SEVENTY”
Directives 4
20%CPU
Consumer Group“TWENTY”
Directives 5
10%CPU
Consumer Group“OTHER_GROUPS
”
Directives 285%CPU
Consumer Group“OTHER_GROUPS
”
Consumer Group Mappings
TYPEServiceModuleActionOracle UserClient ProgramClient OS UserClient Machine
Consumer Group B
Specific ValuePrio
rities
SYS,SYSTEM …
Specific ValueDEFAULT_CONSUMER_
GROUP
Consumer Group A
Resource Allocation Methods
Methods Columns Comments
CPU MGMT_Pn (CPU_Pn) Up to 8 levels
Max Utilization Limit MAX_UTILIZATION_LIMIT
Up to 8 levels
Active Session Pool with Queuing
ACTIVE_SESS_POOL_P1 Parallel count as one
Degree of Parallelism Limit
PARALLEL_DEGREE_LIMIT_P1
applies to one operation
Execution Time Limit MAX_EST_EXEC_TIME in CPU seconds
Undo Pool UNDO_POOL Kilobytes (K)
Idle Time Limit MAX_IDLE_TIME in seconds
DBA_RSRC_PLAN_DIRECTIVES
Notes
• The currently active resource plan does not enforce allocation limits until CPU usage is at 100%.
• When limits are enforced, unused allocation by any consumer group can be used by other consumer groups
• It is possible for a subplan or consumer group to have more than one parent.
• No more than 31 resource consumer groups in any active plan
• At most, a plan can have 31 children
• Plans and resource consumer groups cannot have the same name.
How to Manage
Use DBMS_RESOURCE_MANAGER
Use EM GUI
Resource Manager in EM
Plans: Plan and Plan Directives
Resource Manager by CLI
DBMS_RESOURCE_MANAGER
CREATE|DELETE|UPDATE_PLAN
CREATE|DELETE|UPDATE_PLAN_DIRECTIVE
CREATE|DELETE|UPDATE_CONSUMER_GROUP
SET_CONSUMER_GROUP_MAPPING
Create Simple Plan
Consumer Group Level 1 Level 2 Level 3
SYS_GROUP 100%
MYGROUP1 80%
MYGROUP2 20%
OTHER_GROUPS 100%
BEGIN DBMS_RESOURCE_MANAGER.CREATE_SIMPLE_PLAN (
SIMPLE_PLAN => 'SIMPLE_PLAN1', CONSUMER_GROUP1 => 'MYGROUP1', GROUP1_PERCENT => 80,
CONSUMER_GROUP2 => 'MYGROUP2', GROUP2_PERCENT => 20); END; /
Create Complex Plan• DBMS_RESOURCE_MANAGER.CREATE_PENDING_AREACreate a Pending Area
• DBMS_RESOURCE_MANAGER.CREATE_CONSUMER_GROUP
Create, Modify, Delete a Consumer Group
• DBMS_RESOURCE_MANAGER.CREATE_PLANCreate the Resource
Plan
• DBMS_RESOURCE_MANAGER.CREATE_PLAN_DIRECTIVE
Create the Resource Plan Directives
• DBMS_RESOURCE_MANAGER.VALIDATE_PENDING_AREA
Validate the Pending Area
• DBMS_RESOURCE_MANAGER.SUBMIT_PENDING_AREASubmit the Pending
Area
Complex Plan
via Oracle® Database Administrator's Guide11g Release 2 (11.2)
Complex Plan
Group
CPU Resource Allocation %
Active Session Pool Parameters
Automatic Consumer Group Switching
Maximum Estimated Execution Time
Undo Pool
OLTP Level 1: 80%
Switch to group: batch Switch time: 3 secs
200K
BATCH Level 2: 100%
Pool size: 5 Timeout: 600 secs
-- 3600 secs --
OTHER_GROUPS
Level 3: 100%
-- -- --
PrivilegesBEGIN DBMS_RESOURCE_MANAGER_PRIVS.GRANT_SWITCH_CONSUMER_GROUP ( GRANTEE_NAME => 'KAMUS', CONSUMER_GROUP => 'SYS_GROUP', GRANT_OPTION => TRUE);END;/
BEGIN DBMS_RESOURCE_MANAGER_PRIVS.REVOKE_SWITCH_CONSUMER_GROUP ( REVOKEE_NAME => 'KAMUS', CONSUMER_GROUP => 'SYS_GROUP');END;/
How to Enable/Disiable
Manually
By default the Resource Manager is not enabled
ALTER SYSTEM SET RESOURCE_MANAGER_PLAN = 'mydb_plan';
DBMS_RESOURCE_MANAGER.SWITCH_PLAN
By using Scheduler Windows
Enable: By Oracle Scheduler
Disable: ALTER SYSTEM SET RESOURCE_MANAGER_PLAN = 'FORCE:mydb_plan';
Switch Consumer Group
Method Program Comments
Manually
DBMS_RESOURCE_MANAGER.SWITCH_CONSUMER_GROUP_FOR_SESS
Switching a Single Session
DBMS_SESSION.SWITCH_CURRENT_CONSUMER_GROUP
Switching a Single Session
DBMS_RESOURCE_MANAGER.SWITCH_CONSUMER_GROUP_FOR_USER
Switching All Sessions for a User
Automatic
Automatic Switching with Mapping Rules
Session attribute changes while the session is running
Automatic Switching by Setting Resource Limits
Defined in resource plan directive
Views about RSRC• DBA_RSRC_CONSUMER_GROUP_PRIVS
• DBA_RSRC_PLANS
• V$RSRC_PLAN
• V$RSRC_CONSUMER_GROUP
• V$SESSION. RESOURCE_CONSUMER_GROUP
• V$RSRC_SESSION_INFO
• DBA_HIST_RSRC_*
Oracle ScheduleKamus@ACOUG
Automated Maintenance Tasks
Scheduler Windows
Resource Plan
DEFAULT_MAINTENANCE_PL
AN
DBMS_SCHEDULER.CREATE_WINDO
W