Resource Manager Enhancements in Oracle Database 11g (文档 ID 884082.1)
APPLIES TO:
Enterprise Manager for Oracle Database - Version 11.1.0.6 and laterOracle Database - Enterprise Edition - Version 11.1.0.6 and later
Information in this document applies to any platform.
***Checked for relevance on 26-Apr-2013***
PURPOSE
This article provides an overview of all the resource manager enhancements in Oracle Database 11g.
TOPICS:
1. I/O Calibration
2. Per Session I/O Limits
3. Resource Manager Statistics in AWR
4. Built-In Resource Plans
DETAILS
1) I/O Calibration (DBMS_RESOURCE_MANAGER.CALIBRATE_IO):
++ This feature help assess the I/O capability of the database‘s storage system, and gauge maximum IOPS and Mbytes/s. When Calibrate I/O is invoked it will generate I/O intensive read-only random I/O (db_block_size) and large-block (1MByte) sequential I/O workloads. Unlike various external I/O calibration tools, this tool uses the Oracle code stack and runs in the database, issuing I/O against blocks stored in the database.
IMPORTANT NOTES:
- This should only be run during off-peak times to make sure the calibration doesn‘t affect production workloads, as well as the production workloads affecting the results of the calibration.
- Only users with the SYSDBA privilege can run this procedure. Qualified users must also turn on timed_statistics, and ensure asynch_io is enabled for datafiles. This can be achieved by setting filesystemio_options to either ASYNCH or SETALL.
Example:
SQL> SELECT name, asynch_io FROM v$datafile f,v$iostat_file i
2 WHERE f.file# = i.file_no
3 AND filetype_name = ‘Data File‘
4 /
NAME ASYNCH_IO
-------------------------------------------------- ---------
C:\APP\PVELUSAM\ORADATA\PRATH\SYSTEM01.DBF ASYNC_ON
C:\APP\PVELUSAM\ORADATA\PRATH\SYSAUX01.DBF ASYNC_ON
C:\APP\PVELUSAM\ORADATA\PRATH\UNDOTBS01.DBF ASYNC_ON
C:\APP\PVELUSAM\ORADATA\PRATH\USERS01.DBF ASYNC_ON
++ If asynchronous I/O is not enabled, the procedure returns the following error.
*
ERROR at line 1:
ORA-56708: Could not find any datafiles with asynchronous i/o capability
ORA-06512: at "SYS.DBMS_RMIN", line 453
ORA-06512: at "SYS.DBMS_RESOURCE_MANAGER", line 1153
ORA-06512: at line 6
++ Only one calibration can be run at a time. If another calibration is initiated at the same time, it will fail.
SETUP:
a) Asynchronous I/O shoulbd be enabled by setting the FILESYSTEMIO_OPTIONS parameter to ASYNC or SETALL.
SHUTDOWN IMMEDIATE;
STARTUP;
b) Then call the CALIBRATE_IO function using the DBMS_RESOURCE_MANAGER procedure.
++ The CALIBRATE_IO procedure accepts two parameters to specify the number of physical disks (default 1) and the maximum tolerable latency (default 20ms).
Example:
--------
SQL> DECLARE
2 l_max_iops PLS_INTEGER;
3 l_max_mbps PLS_INTEGER;
4 l_actual_latency PLS_INTEGER;
5 BEGIN
6 DBMS_RESOURCE_MANAGER.calibrate_io (
7 num_physical_disks => 1,
8 max_latency => 20,
9 max_iops => l_max_iops,
10 max_mbps => l_max_mbps,
11 actual_latency => l_actual_latency);
12
13 DBMS_OUTPUT.put_line (‘l_max_iops = ‘ || l_max_iops);
14 DBMS_OUTPUT.put_line (‘l_max_mbps = ‘ || l_max_mbps);
15 DBMS_OUTPUT.put_line (‘l_actual_latency = ‘ || l_actual_latency);
16 END;
17 /
l_max_iops = 148
l_max_mbps = 45
l_actual_latency = 19
++ The V$IO_CALIBRATION_STATUS views show the current status of the calibration runs. During a run the status of ‘IN PROGRESS‘ is displayed. Once a run is complete the status switches to ‘READY‘ and the calibration time is displayed.
Description of DBA_RSRC_IO_CALIBRATE (DBA table that stores I/O Calibration results):
END_TIME End time of the most recent I/O calibration
MAX_IOPS Maximum number of data block read requests that can be sustained per second
MAX_MBPS Maximum megabytes per second of maximum-sized read requests that can be sustained
MAX_PMBPS Maximum megabytes per second of large I/O requests that can be sustained by a single process
LATENCY Latency for data block read requests
NUM_PHYSICAL_DISKS Number of physical disks in the storage subsystem (as specified by the user)
++ Output can be seen as below,
SQL> COLUMN start_time FORMAT A30
SQL> COLUMN end_time FORMAT A30
SQL> SELECT * FROM dba_rsrc_io_calibrate;
START_TIME END_TIME MAX_IOPS MAX_M
BPS MAX_PMBPS LATENCY NUM_PHYSICAL_DISKS
------------------------------ ------------------------------ ---------- -----
--- ---------- ---------- ------------------
08-SEP-09 11.32.13.703000 AM 08-SEP-09 11.34.47.062000 AM 148
45 29 19 1
2) Per Session I/O Limits:
++ In previous versions of Oracle, the DBA could specify the maximum amount of time a session could run before some action was taken; for example, the call was aborted, the session was killed, or the session was migrated to a new consumer group. This feature is configured on a per consumer group basis in a resource plan.
++ In Oracle Database 11g, DBAs can also specify the maximum number of I/O requests or the maximum megabytes of I/O that a session can issue before the same set of actions are taken. This feature is used for two purposes. The first is to automatically identify runaway queries. The second is to move sessions executing long-running calls to lower-priority consumer groups.
++ The SWITCH_IO_MEGABYTES and SWITCH_IO_REQS parameters are now available in addition to the SWITCH_TIME parameter. All three parameters default to NULL, meaning unlimited.
EXAMPLE:
--------
The following example switches the resource consumer group from oltp_group to batch_group for the current call within the session if the elapsed time exceeds 120 seconds, the number of I/O requests exceeds 5000 or the amount of I/O requested exceeds 1024M.
DBMS_RESOURCE_MANAGER.create_plan_directive (
plan => ‘my_plan‘,
group_or_subplan => ‘oltp_group‘,
comment => ‘OLTP Group‘,
mgmt_p1 => 70,
switch_group => ‘batch_group‘,
switch_time => 120,
switch_io_reqs => 5000,
switch_io_megabytes => 1024,
switch_for_call => TRUE);
END;
/
3) Resource Manager Statistics in AWR:
++ AWR contains new historical views for Resource Manager statistics. These new views, DBA_HIST_RSRC_PLAN and DBA_HIST_RSRC_CONSUMER_GROUP, contain the historical version of the statistics in the views V$RESOURCE_PLAN and
V$RESOURCE_CONSUMER_GROUP. AWR also contains per-minute metrics for resource consumption and Resource Manager-induced waits in the view V$RSRCMGRMETRIC.
This feature makes it easier to view historical Resource Manager statistics.
4) Built-In Resource Plans
++ Oracle 11g includes a built-in MIXED_WORKLOAD_PLAN, designed to give OLTP operations priority over batch operations. The plan contains two consumer groups (INTERACTIVE_GROUP and BATCH_GROUP). Calls assigned to the INTERACTIVE_GROUP are automatically switched to the BATCH_GROUP if they exceed 60 seconds. The complete definition of this plan is referenced in the Oracle documentation:
Oracle? Database Administrator‘s Guide
11g Release 1 (11.1)
Part Number B28310-04
An Oracle-Supplied Mixed Workload Plan
The RESOURCE_MANAGER_PLAN parameter is used to tell the instance which resource plan to use.
System altered.
NAME TYPE VALUE
------------------------------------ ----------- -----------------------
resource_limit boolean FALSE
resource_manager_cpu_allocation integer 2
resource_manager_plan string MIXED_WORKLOAD_PLAN
++ You must then grant access on the relevant consumer groups to individual users. The following example grants access on both consumer groups to the TEST user and makes the INTERACTIVE_GROUP the default consumer group. Querying the DBA_USERS view shows the default setting has been recorded.
2 -- Assign users to consumer groups
3 DBMS_RESOURCE_MANAGER_PRIVS.grant_switch_consumer_group(
4 grantee_name => ‘test‘,
5 consumer_group => ‘interactive_group‘,
6 grant_option => FALSE);
7 DBMS_RESOURCE_MANAGER_PRIVS.grant_switch_consumer_group(
8 grantee_name => ‘test‘,
9 consumer_group => ‘batch_group‘,
10 grant_option => FALSE);
11 DBMS_RESOURCE_MANAGER.set_initial_consumer_group(‘test‘, ‘interactive_group‘);
12 END;
13 /
PL/SQL procedure successfully completed.
INITIAL_RSRC_CONSUMER_GROUP
------------------------------
INTERACTIVE_GROUP
++ Connecting to the database as the TEST user and querying the V$SESSION view shows the correct consumer group assignment is working.
Connected.
SQL> SELECT resource_consumer_group
2 FROM v$session
3 WHERE audsid = SYS_CONTEXT(‘USERENV‘, ‘SESSIONID‘);
RESOURCE_CONSUMER_GROUP
--------------------------------
INTERACTIVE_GROUP
++ We can see the consumer group switch take place if we create an artificially long call.
SQL> SET SERVEROUTPUT ON
SQL> DECLARE
2 l_cg v$session.resource_consumer_group%TYPE;
3 BEGIN
4 SELECT resource_consumer_group
5 INTO l_cg
6 FROM v$session
7 WHERE audsid = SYS_CONTEXT(‘USERENV‘, ‘SESSIONID‘);
8 DBMS_OUTPUT.put_line(‘Current Consumer Group: ‘ || l_cg);
9 DBMS_LOCK.sleep(65);
10 SELECT resource_consumer_group
11 INTO l_cg
12 FROM v$session
13 WHERE audsid = SYS_CONTEXT(‘USERENV‘, ‘SESSIONID‘);
14 DBMS_OUTPUT.put_line(‘Current Consumer Group: ‘ || l_cg);
15 END;
16 /
Current Consumer Group: INTERACTIVE_GROUP
Current Consumer Group: BATCH_GROUP
++ As we can see, the call was initially assigned to the INTERACTIVE_GROUP, but switched to the BATCH_GROUP as the call took longer than 60 seconds.
郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。