managing resources

40
16 Copyright © 2004, Oracle. All rights reserved. Managing Resources

Upload: ozzie

Post on 12-Jan-2016

52 views

Category:

Documents


0 download

DESCRIPTION

Managing Resources. Objectives. After completing this lesson, you should be able to do the following: Set up Database Resource Manager Assign users to Resource Manager groups Create resource plans within groups. Overview. Manage mixed workload Control system performance. - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: Managing Resources

16Copyright © 2004, Oracle. All rights reserved.

Managing Resources

Page 2: Managing Resources

16-2 Copyright © 2004, Oracle. All rights reserved.

Objectives

After completing this lesson, you should be able to do the following:

• Set up Database Resource Manager

• Assign users to Resource Manager groups

• Create resource plans within groups

Page 3: Managing Resources

16-3 Copyright © 2004, Oracle. All rights reserved.

OLTP More resources

DSSuser

OLTPuser

Database resource manager

DSS Less resources Oracle

Database

Overview

• Manage mixed workload

• Control system performance

Page 4: Managing Resources

16-4 Copyright © 2004, Oracle. All rights reserved.

Resource plan directives

Database ResourceManager Concepts

User groups or sessions with similar resource needs

A blueprint for resource allocation among resource consumer groups (one active plan)

Specifies how a resource is divided among the resource consumer groups

Resource consumer

group

Resource plan

Page 5: Managing Resources

16-5 Copyright © 2004, Oracle. All rights reserved.

Resource Manager Configurations

• You can manage database and operating system resources, such as:– CPU usage– Number of active sessions– Degree of parallelism– Undo generation– Operation execution time– Idle time

• You can also specify criteria that, if met, causes the automatic switching of sessions to another consumer group.

Page 6: Managing Resources

16-7 Copyright © 2004, Oracle. All rights reserved.

The Initial Plan: SYSTEM_PLAN

Resource ConsumerGroup

Allocation Methods

CPU_P1 CPU_P2 CPU_P3

SYS_GROUP 100% 0% 0%

OTHER_GROUPS 0% 100% 0%

LOW_GROUP 0% 0% 100%

Page 7: Managing Resources

16-8 Copyright © 2004, Oracle. All rights reserved.

Creating a New Resource Plan

There are three ways to create a new resource plan:

• Use Enterprise Manager

• Use the CREATE_SIMPLE_PLAN procedure of DBMS_RESOURCE_MANAGER

• Use the procedures in the DBMS_RESOURCE_MANAGER package to create a complex plan.

Page 8: Managing Resources

16-10 Copyright © 2004, Oracle. All rights reserved.

Creating a Simple Plan

BEGIN DBMS_RESOURCE_MANAGER.CREATE_SIMPLE_PLAN( SIMPLE_PLAN => 'simple_plan1', CONSUMER_GROUP1 => 'mygroup1', GROUP1_CPU => 80, CONSUMER_GROUP2 => 'mygroup2', GROUP2_CPU => 20);END;

Page 9: Managing Resources

16-11 Copyright © 2004, Oracle. All rights reserved.

Oracle Enterprise Manager:Resource Manager

Page 10: Managing Resources

16-12 Copyright © 2004, Oracle. All rights reserved.

Active Session Pool Mechanism

OLTP Users

Active_sess_pool_P1=5

DSS Users

Active_sess_pool_P1=3

Sess6 Sess7

Sess8

p001 p002 p003

DSSActive

SessionQueue

Sess10

Sess9

Sess1 Sess2

Sess3

Sess5Sess4

Page 11: Managing Resources

16-13 Copyright © 2004, Oracle. All rights reserved.

Setting the Active Session Pool

Page 12: Managing Resources

16-14 Copyright © 2004, Oracle. All rights reserved.

Setting the Active Session Pool

Example:

• OLTP: Set no limit on concurrent active sessions

• BATCH: Set to limit concurrent active sessions to 5

• QUEUEING_P1, set to 600, aborts all operations that wait on the queue for more than ten minutes

GROUP

ONLINE

BATCH

ACTIVE SESSION POOL

No limits

ACTIVE_SESS_POOL_P1 = 5

QUEUEING_P1 = 600

Page 13: Managing Resources

16-15 Copyright © 2004, Oracle. All rights reserved.

Maximum Estimated Execution Time

• The Database Resource Manager can estimate the execution time of an operation proactively.

• A DBA can specify a maximum estimated execution time for an operation at the resource consumer group level.

• Operation will not start if the estimate is longer than MAX_EST_EXEC_TIME.

• The benefit of this feature is the elimination of the exceptionally large job that uses too many system resources.

• The default is UNLIMITED.

Page 14: Managing Resources

16-16 Copyright © 2004, Oracle. All rights reserved.

Setting Idle Timeouts

DBMS_RESOURCE_MANAGER.CREATE_PLAN_DIRECTIVE (PLAN => 'DAY_PLAN', GROUP_OR_SUBPLAN => 'DSS_GROUP', COMMENT => 'Limit Idle Time Example', MAX_IDLE_TIME => 600, MAX_IDLE_BLOCKER_TIME => 300);

Page 15: Managing Resources

16-17 Copyright © 2004, Oracle. All rights reserved.

Switching Back to the Initial Consumer Group at End of Call

DBMS_RESOURCE_MANAGER.CREATE_PLAN_DIRECTIVE (PLAN => 'Day_Plan', GROUP_OR_SUBPLAN => 'LONGRUN_GROUP', CPU_P1 => 0, CPU_P2 => 100);

DBMS_RESOURCE_MANAGER.CREATE_PLAN_DIRECTIVE (PLAN => 'Day_Plan', GROUP_OR_SUBPLAN => 'DSS_GROUP', CPU_P1 => 100, CPU_P2 => 0, SWITCH_GROUP => 'LONGRUN_GROUP', SWITCH_TIME_IN_CALL => 600);

At call end

Call 1

Call 2

Page 16: Managing Resources

16-18 Copyright © 2004, Oracle. All rights reserved.

Creating Resource Consumer Groups

Page 17: Managing Resources

16-20 Copyright © 2004, Oracle. All rights reserved.

Assigning Users to Consumer Groups

Page 18: Managing Resources

16-21 Copyright © 2004, Oracle. All rights reserved.

Automatic Consumer Group Switching

ONLINE Group

BATCH Group

Sess3

Sess1 Sess2

Sess4 Sess5

SWITCH_GROUP=BATCH_GROUPSWITCH_TIME_IN_CALL=180SWITCH_ESTIMATE=TRUE

SWITCH_GROUP=ONLINE_GROUPSWITCH_TIME=43200

SWITCH_ESTIMATE=FALSE

Page 19: Managing Resources

16-23 Copyright © 2004, Oracle. All rights reserved.

Automatic Consumer Group Switching

ONLINE Group

Sess3

Sess1 Sess2

SELECT c.cust_last_name, line_item_id, product_idFROM customers c, orders o, order_itemsWHERE c.customer_id = ...;

SWITCH_GROUP='CANCEL_SQL'

SWITCH_TIME=300

SWITCH_ESTIMATE=TRUE

Page 20: Managing Resources

16-24 Copyright © 2004, Oracle. All rights reserved.

Configuring Consumer Group Switching

Page 21: Managing Resources

16-25 Copyright © 2004, Oracle. All rights reserved.

Adaptive Consumer Group Mapping

Page 22: Managing Resources

16-26 Copyright © 2004, Oracle. All rights reserved.

Creating a Mapping Using DBMS_RESOURCE_MANAGER

DBMS_RESOURCE_MANAGER.SET_CONSUMER_GROUP_MAPPING (DBMS_RESOURCE_MANAGER.ORACLE_USER, 'PDML', 'DSS_GROUP');

DBMS_RESOURCE_MANAGER.SET_CONSUMER_GROUP_MAPPING (DBMS_RESOURCE_MANAGER.ORACLE_USER, 'TP1', 'OLTP_GROUP');

DBMS_RESOURCE_MANAGER.SET_CONSUMER_GROUP_MAPPING (DBMS_RESOURCE_MANAGER.CLIENT_OS_USER, 'BILL', 'MANAGER_GROUP');

Page 23: Managing Resources

16-27 Copyright © 2004, Oracle. All rights reserved.

DBMS_RESOURCE_MANAGER.SET_CONSUMER_GROUP_MAPPING_PRI(EXPLICIT => 1, -- highest SERVICE_MODULE => 2, SERVICE_MODULE_ACTIONS => 3, MODULE_NAME_ACTION => 4, MODULE_NAME => 5, SERVICE_NAME => 6, ORACLE_USER => 9, CLIENT_PROGRAM => 8, CLIENT_OS_USER => 7, CLIENT_MACHINE => 10); -- lowest

Assigning Priorities Using DBMS_RESOURCE_MANAGER

Page 24: Managing Resources

16-28 Copyright © 2004, Oracle. All rights reserved.

BUG MAINT Group

70% @ L1

MYDB PLAN

30% @ L1

Using Sub-Plans to Limit CPU Utilization

MAILDBPLAN

ONLINEGroup

BATCHGroup

DELIVERYGroup

MAILSORTGroup

OTHERGroups

BUGDB PLAN

100% @ L2 100% @ L2

100% @ L3

100% @ L1 20% @ L180% @ L1

Page 25: Managing Resources

16-30 Copyright © 2004, Oracle. All rights reserved.

BUG MAINT Group

70% @ L1

MYDB PLAN

Limiting CPU Utilization: Example

ONLINEGroup

BATCHGroup

20% @ L180% @ L1

BUGDB PLAN

100% @ L2

30% @ L1

100% @ L1

100% @ L2

MAILDBPLAN

DELIVERYGroup

MAILSORTGroup

OTHERGroups

100% @ L3

Page 26: Managing Resources

16-31 Copyright © 2004, Oracle. All rights reserved.

Creating a Complex Plan

Page 27: Managing Resources

16-32 Copyright © 2004, Oracle. All rights reserved.

Resource Allocation Methods for Resource Plans

Parameter Possible Values

CPU_MTH EMPHASIS

RATIO

PARALLEL_DEGREE_LIMIT_MTH PARALLEL_DEGREE_LIMIT_ABSOLUTE

ACTIVE_SESS_POOL_MTH ACTIVE_SESS_POOL_ABSOLUTE

QUEUING_MTH FIFO_TIMEOUT

Page 28: Managing Resources

16-34 Copyright © 2004, Oracle. All rights reserved.

Comparison of EMPHASIS and RATIO

EMPHASIS RATIO

The value specifies the maximum percentage of CPU resources a consumer group can use.

The value specifies a number that indicates the ratio of CPU resources to be allocated to the consumer group.

You can allocate resources for up to 8 different levels.

You can only specify values for one level.

The sum of percentages at any given level must be less than or equal to 100.

You must use integer values, but there is no limit on the sum of values.

Default value is NULL. Default value is NULL.

Page 29: Managing Resources

16-36 Copyright © 2004, Oracle. All rights reserved.

Resource Allocation Methods for Consumer Groups

Parameter Possible Values

CPU_MTH ROUND_ROBIN

RUN_TO_COMPLETION

Page 30: Managing Resources

16-37 Copyright © 2004, Oracle. All rights reserved.

Administering the Resource Manager

• Grant privileges to administer the Resource Manager to users

• Activate a plan for the database instance

• Switch the current group for users or sessions with the package DBMS_RESOURCE_MANAGER or DBMS_SESSION

• Monitoring Resource Manager objects:– Consumer groups– Resource plans– Resource plan directives– Resource consumer group mappings

Page 31: Managing Resources

16-38 Copyright © 2004, Oracle. All rights reserved.

Assigning Resource Manager Privileges

Page 32: Managing Resources

16-39 Copyright © 2004, Oracle. All rights reserved.

Setting the Resource Plan for an Instance

Page 33: Managing Resources

16-41 Copyright © 2004, Oracle. All rights reserved.

DECLARE

old_grp VARCHAR2(32);

BEGIN

DBMS_SESSION.SWITCH_CURRENT_CONSUMER_GROUP (

new_consumer_group => 'ONLINE_GROUP',

old_consumer_group => old_grp,

initial_group_on_error => FALSE );

END;

/

Changing a Consumer GroupWithin a Session

The user or the application can manually switch the current consumer group.

Page 34: Managing Resources

16-42 Copyright © 2004, Oracle. All rights reserved.

Changing Consumer Groups for Sessions

• Can be set by DBA for a session

• Can be set by DBA for all sessions for a user

EXEC DBMS_RESOURCE_MANAGER.SWITCH_CONSUMER_GROUP_FOR_SESS ( -

session_id => 7, -

session_serial => 13, -

consumer_group => 'ONLINE_GROUP');

EXEC DBMS_RESOURCE_MANAGER.SWITCH_CONSUMER_GROUP_

FOR_USER ( -

user => 'SCOTT', -

consumer_group => 'BUG_MAINT_GROUP');

Page 35: Managing Resources

16-43 Copyright © 2004, Oracle. All rights reserved.

Database Resource Manager Information

View Name Information

DBA_RSRC_PLANS plans and status

DBA_RSRC_PLAN_DIRECTIVES plan directives

DBA_RSRC_CONSUMER_GROUPS consumer groups

DBA_RSRC_CONSUMER_GROUP_PRIVS users/roles

DBA_USERS columninitial_rsrc_ consumer_group

DBA_RSRC_MANAGER_SYSTEM_PRIVS users/roles

Page 36: Managing Resources

16-44 Copyright © 2004, Oracle. All rights reserved.

Resource Plan Directives

SQL> SELECT plan, group_or_subplan, cpu_p1, cpu_p2, 2 cpu_p3, parallel_degree_limit_p1, status 3 FROM DBA_RSRC_PLAN_DIRECTIVES;

Page 37: Managing Resources

16-46 Copyright © 2004, Oracle. All rights reserved.

Monitoring the Resource Manager

Page 38: Managing Resources

16-47 Copyright © 2004, Oracle. All rights reserved.

Monitoring the Resource Manager

• V$SESSION: Contains the resource_consumer_group column that shows the current group for a session

• V$RSRC_PLAN: A view that shows the active resource plan

• V$RSRC_CONSUMER_GROUP: A view that contains statistics for all active groups

Page 39: Managing Resources

16-49 Copyright © 2004, Oracle. All rights reserved.

Summary

In this lesson, you should have learned how to do the following:

• Set up Database Resource Manager

• Assign users to Resource Manager groups

• Create resource plans within groups

Page 40: Managing Resources

16-50 Copyright © 2004, Oracle. All rights reserved.

Practice 16 Overview: Using the Resource Manager

This practice covers the following topics:

• Creating resource consumer groups

• Specifying CPU resource allocation directives for consumer groups

• Associating users with a resource consumer group using Adaptive Consumer Group Mapping