18
ORACLE DATABASE RESOURCE MANAGER BROAD STEPS 1. Create Pending area – (Automatic if using EM)- either Grid control or DB control. 2. Create a resource consumer group – Grouping of users who will receive the same amount of resources. 3. Create a Resource plan – This is a collection of directives that specify how Oracle should allocate resources to consumer groups. 4. Create a plan directive – This associates resource consumer groups with resource plans and allocates resources amongst resource consumer groups. 5. Validate the pending area - (Automatic if using EM)- either Grid control or DB control 6. Submit the pending area - (Automatic if using EM)- either Grid control or DB control We will use EM to carry out these tasks – Login to rac database db control page – https://xxxxxxx.xxxxxxxx.com:1158/em/console Login as sys/xxxxxx Go to racdev1 instance on home page under Instances

ORACLE DATABASE RESOURCE MANAGER - …€¦  · Web viewHR oracle 406 58655 733346 ACTIVE 2990 816 SQL*Plus devu044n1 sqlplus@devu044n1 (TNS V1-V3 ... ORACLE DATABASE RESOURCE MANAGER

Embed Size (px)

Citation preview

Page 1: ORACLE DATABASE RESOURCE MANAGER - …€¦  · Web viewHR oracle 406 58655 733346 ACTIVE 2990 816 SQL*Plus devu044n1 sqlplus@devu044n1 (TNS V1-V3 ... ORACLE DATABASE RESOURCE MANAGER

ORACLE DATABASE RESOURCE MANAGER

BROAD STEPS

1. Create Pending area – (Automatic if using EM)- either Grid control or DB control.

2. Create a resource consumer group – Grouping of users who will receive the same amount of resources.

3. Create a Resource plan – This is a collection of directives that specify how Oracle should allocate resources to consumer groups.

4. Create a plan directive – This associates resource consumer groups with resource plans and allocates resources amongst resource consumer groups.

5. Validate the pending area - (Automatic if using EM)- either Grid control or DB control

6. Submit the pending area - (Automatic if using EM)- either Grid control or DB control

We will use EM to carry out these tasks –

Login to rac database db control page –

https://xxxxxxx.xxxxxxxx.com:1158/em/console

Login as sys/xxxxxx

Go to racdev1 instance on home page under Instances –

Page 2: ORACLE DATABASE RESOURCE MANAGER - …€¦  · Web viewHR oracle 406 58655 733346 ACTIVE 2990 816 SQL*Plus devu044n1 sqlplus@devu044n1 (TNS V1-V3 ... ORACLE DATABASE RESOURCE MANAGER

Click on Server .

Next create a consumer group – click on Consumer groups

Enter Object name OOAS and click on create.

Page 3: ORACLE DATABASE RESOURCE MANAGER - …€¦  · Web viewHR oracle 406 58655 733346 ACTIVE 2990 816 SQL*Plus devu044n1 sqlplus@devu044n1 (TNS V1-V3 ... ORACLE DATABASE RESOURCE MANAGER

Enter consumer group name and description – and click OK.

Confirmation on screen –

Exit to Server page –

Next Create a resource plan .

Page 4: ORACLE DATABASE RESOURCE MANAGER - …€¦  · Web viewHR oracle 406 58655 733346 ACTIVE 2990 816 SQL*Plus devu044n1 sqlplus@devu044n1 (TNS V1-V3 ... ORACLE DATABASE RESOURCE MANAGER

Click on Plans

Object name – OAAS_PLAN and Create –

Page 5: ORACLE DATABASE RESOURCE MANAGER - …€¦  · Web viewHR oracle 406 58655 733346 ACTIVE 2990 816 SQL*Plus devu044n1 sqlplus@devu044n1 (TNS V1-V3 ... ORACLE DATABASE RESOURCE MANAGER

OK

Confirmation received.

Next create a plan directive –

Back to Server page –

Click on Plans

Page 6: ORACLE DATABASE RESOURCE MANAGER - …€¦  · Web viewHR oracle 406 58655 733346 ACTIVE 2990 816 SQL*Plus devu044n1 sqlplus@devu044n1 (TNS V1-V3 ... ORACLE DATABASE RESOURCE MANAGER

Click on OAAS_PLAN radio button and then on VIEW

As you can see OTHER_GROUPS is a default resource consumer group which must be assigned – otherwise a plan cannot be submitted to the Pending area.

Now we will assign another resource consumer group to the OAAS_PLAN.

Click on Edit on the right hand bottom –

Page 7: ORACLE DATABASE RESOURCE MANAGER - …€¦  · Web viewHR oracle 406 58655 733346 ACTIVE 2990 816 SQL*Plus devu044n1 sqlplus@devu044n1 (TNS V1-V3 ... ORACLE DATABASE RESOURCE MANAGER

Click on Advanced and then on Modify –

Move OAAS consumer group and click OK.

Now OAAS group is part of the OAAS_PLAN directive.

Now various resource allocations can be controlled – click on all tabs – ex General, Parallelism, Session Pool etc.

We will choose Session Pool to control the number of Active sessions for this plan.

Page 8: ORACLE DATABASE RESOURCE MANAGER - …€¦  · Web viewHR oracle 406 58655 733346 ACTIVE 2990 816 SQL*Plus devu044n1 sqlplus@devu044n1 (TNS V1-V3 ... ORACLE DATABASE RESOURCE MANAGER

We can control the number of active sessions for each user assigned to this consumer group via this plan.

For example we say only 2 active sessions are allowed –

Click on Show Sql –

BEGINdbms_resource_manager.clear_pending_area();dbms_resource_manager.create_pending_area();dbms_resource_manager.create_plan_directive(    plan => ?,    group_or_subplan => ?,

Page 9: ORACLE DATABASE RESOURCE MANAGER - …€¦  · Web viewHR oracle 406 58655 733346 ACTIVE 2990 816 SQL*Plus devu044n1 sqlplus@devu044n1 (TNS V1-V3 ... ORACLE DATABASE RESOURCE MANAGER

    comment => ?,    mgmt_p1 => ?, mgmt_p2 => ?, mgmt_p3 => ?, mgmt_p4 => ?,    mgmt_p5 => ?, mgmt_p6 => ?, mgmt_p7 => ?, mgmt_p8 => ? ,    parallel_degree_limit_p1 => ? ,    switch_io_reqs => ? ,   switch_io_megabytes => ? ,    active_sess_pool_p1 => ?,    queueing_p1 => ?,    switch_group => ?,    switch_time => ?,    switch_estimate => case ? when 'false' then false when 'true' then true else false end,    max_est_exec_time => ?,    undo_pool => ? ,    max_idle_time => ?,    max_idle_blocker_time => ?,    switch_for_call => case ? when 'false' then false when 'true' then true else false end

);dbms_resource_manager.submit_pending_area();END; Apply.

Click Return and then Apply –

Confirmation that plan has been modified.

In this case only 2 active sessions of users assigned to the OAAS group can run transactions, a third session will remain in the queue for 300 seconds ( 5 minutes ) before getting disconnected.

Page 10: ORACLE DATABASE RESOURCE MANAGER - …€¦  · Web viewHR oracle 406 58655 733346 ACTIVE 2990 816 SQL*Plus devu044n1 sqlplus@devu044n1 (TNS V1-V3 ... ORACLE DATABASE RESOURCE MANAGER

Apply

Now we will have to assign users to the particular consumer group.

Back to HOME PAGE – Server tab.

Page 11: ORACLE DATABASE RESOURCE MANAGER - …€¦  · Web viewHR oracle 406 58655 733346 ACTIVE 2990 816 SQL*Plus devu044n1 sqlplus@devu044n1 (TNS V1-V3 ... ORACLE DATABASE RESOURCE MANAGER

Click on Users under Secuirty.

Click on Selection Mode drop down and change to Multiple.

Now click on radio button against 3 users – HR

CLICK ON HR

Page 12: ORACLE DATABASE RESOURCE MANAGER - …€¦  · Web viewHR oracle 406 58655 733346 ACTIVE 2990 816 SQL*Plus devu044n1 sqlplus@devu044n1 (TNS V1-V3 ... ORACLE DATABASE RESOURCE MANAGER

Click Edit

Click on Consumer group privileges, then on Edit list and choose OOAS as consumer group to be attached to.

Page 13: ORACLE DATABASE RESOURCE MANAGER - …€¦  · Web viewHR oracle 406 58655 733346 ACTIVE 2990 816 SQL*Plus devu044n1 sqlplus@devu044n1 (TNS V1-V3 ... ORACLE DATABASE RESOURCE MANAGER

OK –

Also make the default consumer group OAAS.

Show sql –

BEGIN    dbms_resource_manager_privs.grant_switch_consumer_group(         grantee_name => 'HR',        consumer_group => 'OAAS',        grant_option => FALSE    );END;

Page 14: ORACLE DATABASE RESOURCE MANAGER - …€¦  · Web viewHR oracle 406 58655 733346 ACTIVE 2990 816 SQL*Plus devu044n1 sqlplus@devu044n1 (TNS V1-V3 ... ORACLE DATABASE RESOURCE MANAGER

BEGIN     dbms_resource_manager.set_initial_consumer_group(         user => 'HR',        consumer_group => 'OAAS'    );END;

Return

Apply.

Activate OAAS_PLAN –

Server – plans

CLICK ON OAAS_PLAN and then activate – go.

Page 15: ORACLE DATABASE RESOURCE MANAGER - …€¦  · Web viewHR oracle 406 58655 733346 ACTIVE 2990 816 SQL*Plus devu044n1 sqlplus@devu044n1 (TNS V1-V3 ... ORACLE DATABASE RESOURCE MANAGER

Confirmation.

Now test –

Login as HR and run 3 different queries – the third query must queued up and then be killed after 5 minutes of waiting.

I ran 3 sessions after logging in as HR –

On first look they all seemed active – however after 5 minutes, the last session was killed with the following error.

Page 16: ORACLE DATABASE RESOURCE MANAGER - …€¦  · Web viewHR oracle 406 58655 733346 ACTIVE 2990 816 SQL*Plus devu044n1 sqlplus@devu044n1 (TNS V1-V3 ... ORACLE DATABASE RESOURCE MANAGER

SQL> @loop 14 /declare*ERROR at line 1:ORA-07454: queue timeout, 300 second(s), exceeded

SQL>

SQL> select resource_consumer_group,status from v$session where username='HR';

RESOURCE_CONSUMER_GROUP STATUS-------------------------------- --------OAAS ACTIVEOAAS ACTIVEOAAS ACTIVE

After resource manager killed the session –

SQL> select resource_consumer_group,status from v$session where username='HR';

RESOURCE_CONSUMER_GROUP STATUS-------------------------------- --------OAAS INACTIVEOAAS ACTIVEOAAS ACTIVE

Therefore the Resource manager made sure that no more than 2 active sessions were allowed at one time for HR user logins.

This can now be incorporated for other users…..more plans can be added if necessary.

@sessions –

HR oracle 406 58655 733346 ACTIVE 2990 816 SQL*Plus devu044n1 sqlplus@devu044n1 (TNS V1-V3) 18-Aug-2010 09:03:58

HR oracle 404 64015 258248 INACTIVE 1838 304 SQL*Plus devu044n1 sqlplus@devu044n1 (TNS V1-V3) 18-Aug-2010 09:06:27

HR oracle 598 6591 712782 ACTIVE 2094 304 SQL*Plus devu044n1 sqlplus@devu044n1 (TNS V1-V3) 18-Aug-2010 09:06:53

Kill -9 258248 to kill inactive session.