12c_Resource_plans
12c_Resource_plans
In a CDB since we have multiple pluggable databases sharing a set of common resources, we can prevent multiple workloads to compete with
each other for both system as well as CDB resources by using Resource Manager.
Let us look at an example of managing resources for Pluggable Databases (between PDB’s) at the multitenant Container database level.
The same can be achieved using 12c Cloud Control, but displayed here are the steps to be performed at the command line using the
DBMS_RESOURCE_MANAGER package.
With Resource Manager at the Pluggable Database level, we can limit CPU usage of a particular PDB as well as the number of parallel execution
servers which a particular PDB can use.
To allocate resources among PDB’s we use a concept of shares where we assign shares to particular PDB’s and a higher share to a PDB results in
higher allocation of guaranteed resources to that PDB.
Optionally update the default directives which will specify resources which any newly created PDB’s will be allocated or which will be
used when no directives have been explicitly defined for a particular PDB
Optionally update the directives which apply by default to the Automatic Maintenance Tasks which are configured to run in the out of
the box maintenance windows
Enable the plan at the CDB level by setting the RESOURCE_MANAGER_PLAN parameter
We have 5 Pluggable databases contained in the Container database and we wish to enable resource management at the PDB level.
We wish to guarantee CPU allocation in the ratio 4:3:1:1:1 so that the CPU is distributed among the PDB’s in this manner:
PDBPROD1 : 40%
PDBPROD2: 30%
PDBPROD3: 10%
PDBPROD4 : 10%
PDBPROD5: 10%
Further for PDB’s PDBPROD3, PDBPROD4 and PDBPROD5 we wish to ensure that CPU utilization for these 3 PDB’s never crosses the 70% limit.
Also for these 3 PDB’s we would like to limit the maximum number of parallel execution servers available to the PDB.
The value of 70% means that if the PARALLEL_SERVERS_TARGET initialization parameter is 200, then the PDB cannot use more than a maximum
of 140 parallel execution servers. For PDBPROD1 and PDBPROD2 there is no limit, so they can use all 200 parallel execution servers if available.
We also want to limit the resources used by the Automatic Maintenance Tasks jobs when they do execute in a particular job window and also
want to specify a default resource allocation limit for newly created PDB’s or those PDB’s where a resource limit directive has not been explicitly
defined.
Create directives which will specify how resources are allocated to each particular PDB
Update (if required) default directive applies to PDBs for which specific directives have not been defined
Update the directive (if required) which will limit the resources available to run the Automatic Maintenance Tasks
System altered.
If we launch Database Express (or OEM for that matter) we can now see the resource allocation to each of the PDB’s as well as the resource
utilization limit which has been imposed on some of the PDB’s.
We can also query the DBA_CDB_RSRC_PLAN_DIRECTIVES view to obtain the same information in some more detail
SQL SYS@PRODCDB> SQL SYS@PRODCDB> SQL SYS@PRODCDB> SQL SYS@PRODCDB> SELECT PLAN,
2 PLUGGABLE_DATABASE,
3 SHARES,
4 UTILIZATION_LIMIT,
5 PARALLEL_SERVER_LIMIT
6 FROM DBA_CDB_RSRC_PLAN_DIRECTIVES
7 ORDER BY PLAN;
Parallel
Pluggable Utilization Server
Plan Database Shares Limit Limit
-------------------------- ------------------------- ------ ----------- --------
DEFAULT_CDB_PLAN ORA$AUTOTASK 90 100
DEFAULT_CDB_PLAN ORA$DEFAULT_PDB_DIRECTIVE 1 100 100
DEFAULT_MAINTENANCE_PLAN ORA$AUTOTASK 90 100
DEFAULT_MAINTENANCE_PLAN ORA$DEFAULT_PDB_DIRECTIVE 1 100 100
Parallel
Pluggable Utilization Server
Plan Database Shares Limit Limit
-------------------------- ------------------------- ------ ----------- --------
ORA$INTERNAL_CDB_PLAN ORA$DEFAULT_PDB_DIRECTIVE
ORA$INTERNAL_CDB_PLAN ORA$AUTOTASK
ORA$QOS_CDB_PLAN ORA$AUTOTASK 90 100
ORA$QOS_CDB_PLAN ORA$DEFAULT_PDB_DIRECTIVE 1 100 100
PRODCDB_PLAN PDBPROD3 2 70 70
PRODCDB_PLAN PDBPROD5 1 70 70
PRODCDB_PLAN PDBPROD2 3 100 100
PRODCDB_PLAN PDBPROD1 4 100 100
PRODCDB_PLAN PDBPROD4 1 70 70
Parallel
Pluggable Utilization Server
Plan Database Shares Limit Limit
-------------------------- ------------------------- ------ ----------- --------
PRODCDB_PLAN ORA$AUTOTASK 1 75 75
PRODCDB_PLAN ORA$DEFAULT_PDB_DIRECTIVE 1 50 50
20 rows selected.
exec DBMS_RESOURCE_MANAGER.CREATE_PENDING_AREA();
BEGIN
DBMS_RESOURCE_MANAGER.CREATE_CDB_PLAN(
plan => 'PRODCDB_PLAN',
comment => 'CDB resource plan for PRODCDB');
END;
/
BEGIN
DBMS_RESOURCE_MANAGER.CREATE_CDB_PLAN_DIRECTIVE(
plan => 'PRODCDB_PLAN',
pluggable_database => 'PDBPROD1',
shares => 4,
utilization_limit => 100,
parallel_server_limit => 100);
END;
/
BEGIN
DBMS_RESOURCE_MANAGER.CREATE_CDB_PLAN_DIRECTIVE(
plan => 'PRODCDB_PLAN',
pluggable_database => 'PDBPROD2',
shares => 3,
utilization_limit => 100,
parallel_server_limit => 100);
END;
/
BEGIN
DBMS_RESOURCE_MANAGER.CREATE_CDB_PLAN_DIRECTIVE(
plan => 'PRODCDB_PLAN',
pluggable_database => 'PDBPROD3',
shares => 1,
utilization_limit => 70,
parallel_server_limit => 70);
END;
/
BEGIN
DBMS_RESOURCE_MANAGER.CREATE_CDB_PLAN_DIRECTIVE(
plan => 'PRODCDB_PLAN',
pluggable_database => 'PDBPROD4',
shares => 1,
utilization_limit => 70,
parallel_server_limit => 70);
END;
/
BEGIN
DBMS_RESOURCE_MANAGER.CREATE_CDB_PLAN_DIRECTIVE(
plan => 'PRODCDB_PLAN',
pluggable_database => 'PDBPROD5',
shares => 1,
utilization_limit => 70,
parallel_server_limit => 70);
END;
/
BEGIN
DBMS_RESOURCE_MANAGER.UPDATE_CDB_DEFAULT_DIRECTIVE(
plan => 'PRODCDB_PLAN',
new_shares => 1,
new_utilization_limit => 50,
new_parallel_server_limit => 50);
END;
/
BEGIN
DBMS_RESOURCE_MANAGER.UPDATE_CDB_AUTOTASK_DIRECTIVE(
plan => 'PRODCDB_PLAN',
new_shares => 1,
new_utilization_limit => 75,
new_parallel_server_limit => 75);
END;
/
exec DBMS_RESOURCE_MANAGER.VALIDATE_PENDING_AREA();
exec DBMS_RESOURCE_MANAGER.SUBMIT_PENDING_AREA();
Part Two: Creating an Oracle 12c Pluggable Database (PDB) Resource Plan
We have seen how a CDB resource plan allocates resources among the various PDB’s in the container database.
The PDB resource plan will now allocate resources within the database based on Consumer Groups – the method is in fact the same as what we
used for Non-CDB’s in earlier versions of the Oracle database.
Our requirement is to ensure certain Batch users do not hog the system resources when batch jobs execute and we would like to enable a PDB
resource plan which will impose limits on the amount of Undo the statement can use as well as the amount of time the statement is allowed to
run and also the amount of physical I/O resources it can use.
Connect to the appropriate PDB where we need to create the PDB Resource Plan
Session altered.
Create the directives which will limit resources allocated to a particular Consumer Group
Note – 20 MB of UNDO usage is a very small value – only used to illustrate the example!
Here are some of the other common directives we can set (taken from the official documentation)
Map the user SH to the Consumer Group BATCH_USER_GROUP and set the initial Consumer Group for the user SH
System altered.
Let us now test the PDB resource plan and see if the directive to limit the use of Undo to 20 MB is enforced.
Initially we can see that the user SH which belongs to the BATCH_USER_GROUP Consumer Group is not using any Undo.
From another session let us connect as the user SH and execute an UPDATE statement which will cause the amount of Undo usage to exceed the
20 MB limit.
Back to the original session we can now Undo usage is increasing – and then we see it has gone back to 0
This is because the session was cancelled as the resource limit of 20 MB Undo usage was exceeded
SQL SYS@PRODCDB> /
SQL SYS@PRODCDB> /
SQL SYS@PRODCDB> /
SQL SYS@PRODCDB> /
SESS_ID CONSUMER_GROUP CURRENT_UNDO_CONSUMPTION MAX_UNDO_CONSUMPTION
---------- -------------------------------- ------------------------ --------------------
43 BATCH_USER_GROUP 11872540 0
74 OTHER_GROUPS 0 0
SQL SYS@PRODCDB> /
If we limit the usage of Undo now by including a WHERE clause in the UPDATE statement, we can see that the Undo usage remains below the 20
MB imposed resource limit and the statement executes successfully this time.
SQL SH@pdbprod4> update sh.sales set amount_sold=1 where rownum < 50001;
SQL SYS@PRODCDB> /
SQL SYS@PRODCDB> /
SQL SYS@PRODCDB> /