转 Oracle 12c: Managing Resources

http://www.oracle-class.com/?p=3058

1. Introduction:

Oracle database 12c comes with several Resource management enhancements to handle resources within CDBs and PDBs. In this article we will focus on the use of Resource Manager in a CDB environment.

Prior to Oracle database 12c, we used Resource Manager to manage
database workloads “fighting” for system resources such as CPU. For
environments, which have multiple Oracle databases running on the same
server, the use of Oracle Resource Manager to manage system resources
(CPU, I/O …) used by all those databases is not possible.

However with Oracle 12c, we can have multiple workloads within multiple
PDBS “fighting” for system and CDB resources. Thus the possibility to
use Oracle Resource Manager to manage system resources (CPU, I/O …) used
by all those databases.

In a CDB, Oracle Resource Manager can manage resources on 2 different levels:

– CDB level: Oracle Resource Manager can manage resource usage by all the PDBs within a CDB.

– PDB level: Oracle Resource Manager can manage resource usage within the PDB itself.

2. What Solutions Does Resource Manager Provide for a CDB?

By default, the whole system may have the following problems:

– Inappropriate allocation of resources among PDBs; All PDBs have same level of priority.

– Inappropriate allocation of resources within a single PDB; All workloads within a PDB have same level of priority.

– Lack of resource usage data for PDBs.

Oracle Resource Manager helps to overcome these problems.

In the following post, we will see how Oracle Resource Manager manages resources:

– Between PDBs.

– With a single PDB.

3. Managing Resources Between PDBs:

In a CDB, PDBs might have different levels of priority / importance.
You can create CDB resource plans to distribute resources to different
PDBs based on these priorities. PDBs may contend for CPU, I/O resources.

A CDB resource plan allocates resources to its PDBs according to its set
of resource plan directives (directives). Each directive references one
PDB, and no two directives for the currently active plan can reference
the same PDB.

The directives control allocation of the following resources to the PDBs:

? CPU

? I/O

? Parallel execution servers

Shares for resource allocation for PDBs:

A directive can control the allocation of resources to PDBs based on
the share value granted to each PDB. You can grant different shares to
different PDBs so that more system resources are allocated to the PDB
with the highest priority.

For example:

The following image shows each PDB has one “share” With a total of 4 shares; each PDB is guaranteed 1/4 or 25% of the CPU.

To allocate more resources to PDB4, you can assign more share values
to the PDB which results in more resource allocation for the PDB4.

The following image shows PDB4 get assigned 4 shares and the other PDBs
get 3, 1 and 2 shares respectively. With a total of 10 shares, PDB1,
PDB2 and PDB3 are guaranteed 3/10 (30%), 1/10 (10%), 2/10 (20%) of the
system resources respectively.

Because PDB4 is the most important, it has been given 4 shares; it is guaranteed 4/10 or 40% of the system resources.

Limits to restrict resource utilization for specific PDB:

A utilization limit restrains the system resource usage of a specific
PDB. You can specify utilization limits for CPU and parallel execution
servers. The limits are default to 100%.

Limits restrict the resource utilization; you can create a Resource
Manager Plan directive using the UTILIZATION_LIMIT parameter to limit
CPU for each PDB. For example, if you create a plan directive with a
UTILIZATION_LIMIT parameter equal to 20% for a specific PDB, the later
will get 20% the maximum of CPU usage at CDB level.

For parallel execution servers, you can override the default defined by
the UTILIZATION_LIMIT by creating a plan directive that uses the
PARALLEL_SERVER_LIMIT parameter. A PDB cannot use more than the value of
the PARALLEL_SERVERS_TARGET initialization parameter multiplied by the
value of the PARALLEL_SERVER_LIMIT parameter in the
CREATE_CDB_PLAN_DIRECTIVE procedure. For example, if the
PARALLEL_SERVERS_TARGET initialization parameter is set to 100 and the
PARALLEL_SERVER_LIMIT parameter for a PDB is set to 20%, then
utilization limit for the PDB is 20 parallel execution servers (100 X
0.20).

Creating CDB Resource Plan for PDBs using SQL*Plus:

In the following example,

– PDBBI is allocated 1 share which represents 1/3 or 33% of the CPU and
queued parallel. In addition, a UTILIZATION_LIMIT of 40% of resources is
set as well as 60% limit of the available parallel servers.

– PDBHR is allocated 2 shares which represents 2/3 or 66% of the CPU and
queued parallel. In addition, a UTILIZATION_LIMIT of 60% of resources
is set as well as 100% limit of the available parallel servers.

view plaincopy to clipboardprint?

  1. SQL> select con_id,dbid,NAME,OPEN_MODE from v$pdbs;
  2. CON_ID       DBID NAME                           OPEN_MODE
  3. ---------- ---------- ------------------------------ ----------
  4. 2 4063385794 PDB$SEED                       READ ONLY
  5. 4 1911833382 PDBBI                          READ WRITE
  6. 5  889037338 PDBHR                          READ WRITE
  7. SQL>

Connect to the root container database and do the following:

1. Create a pending area; pending area is staging areas where resource
objects get created, defined, before validated and activated.

2. Create a CDB resource plan; called “everyday_plan”.

3. Create directives for the PDBs.

4. (Optional) Update the default PDB directive using the UPDATE_CDB_DEFAULT_DIRECTIVE procedure.

5. (Optional) Update the default auto task directive using the UPDATE_CDB_AUTOTASK_DIRECTIVE procedure.

6. Validate the pending area.

7. Submit the pending area.

Use CREATE_CDB_PLAN procedure to create the CDB plan. Create a CDB
resource plan directives for the PDBs using the
CREATE_CDB_PLAN_DIRECTIVE procedure:

view plaincopy to clipboardprint?

  1. C:\Users\sesa258020>sqlplus / as sysdba
  2. SQL*Plus: Release 12.1.0.1.0 Production on Sat Jul 20 16:10:30 2013
  3. Copyright (c) 1982, 2013, Oracle.  All rights reserved.
  4. Connected to:
  5. Oracle Database 12c Enterprise Edition Release 12.1.0.1.0 - 64bit Production
  6. With the Partitioning, OLAP, Advanced Analytics and Real Application Testing options
  7. SQL> EXEC DBMS_RESOURCE_MANAGER.CREATE_PENDING_AREA();
  8. PL/SQL procedure successfully completed.
  9. SQL>
  10. SQL> BEGIN
  11. 2  DBMS_RESOURCE_MANAGER.CREATE_CDB_PLAN(
  12. 3     plan => ‘everyday_plan‘,
  13. 4     comment => ‘CDB Resource Plan for PDBBI $ PDBHR‘
  14. 5     );
  15. 6  END;
  16. 7  /
  17. PL/SQL procedure successfully completed.
  18. SQL>
  19. SQL> BEGIN
  20. 2  DBMS_RESOURCE_MANAGER.CREATE_CDB_PLAN_DIRECTIVE(
  21. 3  plan => ‘everyday_plan‘,
  22. 4  pluggable_database => ‘PDBBI‘,
  23. 5  shares => 1,
  24. 6  utilization_limit => 40,
  25. 7  parallel_server_limit => 60
  26. 8  );
  27. 9  END;
  28. 10  /
  29. PL/SQL procedure successfully completed.
  30. SQL>
  31. SQL> BEGIN
  32. 2  DBMS_RESOURCE_MANAGER.CREATE_CDB_PLAN_DIRECTIVE(
  33. 3  plan => ‘everyday_plan‘,
  34. 4  pluggable_database => ‘PDBHR‘,
  35. 5  shares => 2,
  36. 6  utilization_limit => 60,
  37. 7  parallel_server_limit => 100
  38. 8  );
  39. 9  END;
  40. 10  /
  41. PL/SQL procedure successfully completed.
  42. SQL>
  43. SQL> EXEC DBMS_RESOURCE_MANAGER.VALIDATE_PENDING_AREA();
  44. PL/SQL procedure successfully completed.
  45. SQL> EXEC DBMS_RESOURCE_MANAGER.SUBMIT_PENDING_AREA();
  46. PL/SQL procedure successfully completed.
  47. SQL>

Update CDB Resource Plan for PDBs using SQL*Plus:

Use the procedure UPDATE_CDB_AUTOTASK_DIRECTIVE to update CDB auto task (automated maintenance tasks).

For example:

view plaincopy to clipboardprint?

  1. SQL> EXEC DBMS_RESOURCE_MANAGER.CREATE_PENDING_AREA();
  2. PL/SQL procedure successfully completed.
  3. SQL> BEGIN
  4. 2    DBMS_RESOURCE_MANAGER.UPDATE_CDB_AUTOTASK_DIRECTIVE(
  5. 3      plan                  => ‘everyday_plan‘,
  6. 4      new_shares            => 2,
  7. 5      new_utilization_limit => 20,
  8. 6      new_parallel_server_limit => 75);
  9. 7  END;
  10. 8  /
  11. PL/SQL procedure successfully completed.
  12. SQL> EXEC DBMS_RESOURCE_MANAGER.VALIDATE_PENDING_AREA();
  13. PL/SQL procedure successfully completed.
  14. SQL> EXEC DBMS_RESOURCE_MANAGER.SUBMIT_PENDING_AREA();
  15. PL/SQL procedure successfully completed.
  16. SQL>

You can create new directives for the new PDB. You can also change
the default directive attribute values for PDBs by using the
UPDATE_CDB_DEFAULT_DIRECTIVE procedure in the DBMS_RESOURCE_MANAGER
package. New PDB will have 1 share of CPU. In addition, a
UTILIZATION_LIMIT of 40% of resources is set as well as 30% limit of the
available parallel servers.

view plaincopy to clipboardprint?

  1. SQL> EXEC DBMS_RESOURCE_MANAGER.CREATE_PENDING_AREA();
  2. PL/SQL procedure successfully completed.
  3. SQL> BEGIN
  4. 2  DBMS_RESOURCE_MANAGER.UPDATE_CDB_DEFAULT_DIRECTIVE(
  5. 3  plan => ‘everyday_plan‘,
  6. 4  new_shares => 1,
  7. 5  new_utilization_limit => 40,
  8. 6  new_parallel_server_limit => 30
  9. 7  );
  10. 8  END;
  11. 9  /
  12. PL/SQL procedure successfully completed.
  13. SQL> EXEC DBMS_RESOURCE_MANAGER.VALIDATE_PENDING_AREA();
  14. PL/SQL procedure successfully completed.
  15. SQL> EXEC DBMS_RESOURCE_MANAGER.SUBMIT_PENDING_AREA();
  16. PL/SQL procedure successfully completed.
  17. SQL>

You can delete CDB resource plan directives for the PDBs using the DELETE_CDB_PLAN_DIRECTIVE procedure

Example:

view plaincopy to clipboardprint?

  1. BEGIN
  2. DBMS_RESOURCE_MANAGER.DELETE_CDB_PLAN_DIRECTIVE(
  3. plan               => ‘everyday_plan‘,
  4. pluggable_database => ‘PDBBI‘);
  5. END;

View CDB Resource Plan for PDBs using SQL*Plus:

Query the table DBA_CDB_RSRC_PLAN_DIRECTIVES to see all of the
directives defined in all the CDB resource plans in the root container.

Note: The ORA$DEFAULT_PDB_DIRECTIVE is the default directive for PDBs
(You can see shares set to 1, the UTILIZATION_LIMIT set to 40% and
PARALLEL_SERVER_LIMIT set to 30% like we already modified using the
UPDATE_CDB_DEFAULT_DIRECTIVE procedure.)

Query the table DBA_CDB_RSRC_PLANS to see all of the resource plans defined in the root container.

Enable CDB Resource Plan for PDBs using SQL*Plus:

You can enable the Resource Manager for a CDB by setting the
RESOURCE_MANAGER_PLAN parameter in the root. This parameter specifies a
CDB resource plan to be active;

view plaincopy to clipboardprint?

  1. SQL> ALTER SYSTEM SET resource_manager_plan=‘everyday_plan‘;
  2. System altered.
  3. OR
  4. ALTER SYSTEM SET RESOURCE_MANAGER_PLAN = ‘FORCE:everyday_plan‘;

You can disable CDB resource management;

view plaincopy to clipboardprint?

  1. SQL> ALTER SYSTEM SET resource_manager_plan=’’;
  2. System altered.

4. Creating a PDB resource plan:

We have seen in the previous section, a CDB resource plan determines
the amount of resources allocated to each PDB within the multitenant
environment. A PDB resource plan determines how the resources allocated
to a specific PDB are allocated to consumer groups within that PDB. A
PDB resource plan is similar to a resource plan for a non-CDB, thus
similar to previous versions of Oracle database.

The following is a summary of the steps required to create a PDB resource plan:

1. In SQL*Plus, ensure that the current container is a PDB.

2. Create a pending area using the CREATE_PENDING_AREA procedure.

3. Create, modify, or delete consumer groups using the CREATE_CONSUMER_GROUP procedure.

4. Map sessions to consumer groups using the SET_CONSUMER_GROUP_MAPPING procedure.

5. Create the PDB resource plan using the CREATE_PLAN procedure.

6. Create PDB resource plan directives using the CREATE_PLAN_DIRECTIVE procedure.

7. Validate the pending area using the VALIDATE_PENDING_AREA procedure.

8. Submit the pending area using the SUBMIT_PENDING_AREA procedure.

Example: For PDBHR, according to the image above, we will use CPU
ratio allocation method; the result of these directives will allocate
CPU resources using 10:2:1 ratio. The OLTP group will get only 2 CPU
cycles for every 10 that REPORTING group receives. We will create the
following plan and plan directives; OLTP_PLAN and REPORTING_PLAN. But,
before that we will create resource consumer groups. Consumer groups
allow classifying end users into logical groupings based on resource
consumption requirements; we create OLTP and REPORTING consumer groups.
After creation of consumer groups, we can assign user sessions to it
using the SET_CONSUMER_GROUP_MAPPING procedure (Obviously we need to
create resource groups, plan and plan directives before issue the
following commands). For example we assign the Oracle user “WISSEM” to
the consumer group OLTP:

view plaincopy to clipboardprint?

  1. SQL> EXEC DBMS_RESOURCE_MANAGER.CREATE_PENDING_AREA();
  2. PL/SQL procedure successfully completed.
  3. SQL> BEGIN
  4. 2  DBMS_RESOURCE_MANAGER.SET_CONSUMER_GROUP_MAPPING
  5. 3  (
  6. 4  ATTRIBUTE=> ‘ORACLE_USER‘,
  7. 5  VALUE=> ‘WISSEM‘,
  8. 6  CONSUMER_GROUP => ‘OLTP‘
  9. 7  );
  10. 8  END;
  11. 9  /
  12. PL/SQL procedure successfully completed.
  13. SQL> EXEC DBMS_RESOURCE_MANAGER.VALIDATE_PENDING_AREA();
  14. PL/SQL procedure successfully completed.
  15. SQL> EXEC DBMS_RESOURCE_MANAGER.SUBMIT_PENDING_AREA();
  16. PL/SQL procedure successfully completed.
  17. SQL>

We create resource groups, plan and plan directives. Before doing
that, we need to switch the session from the root container to the PDBHR
using “alter session set container=PDBHR” command.

view plaincopy to clipboardprint?

  1. SQL> alter session set container=PDBHR;
  2. Session altered.
  3. SQL> EXEC DBMS_RESOURCE_MANAGER.CREATE_PENDING_AREA();
  4. PL/SQL procedure successfully completed.
  5. SQL> BEGIN
  6. 2  DBMS_RESOURCE_MANAGER.CREATE_CONSUMER_GROUP(‘OLTP‘);
  7. 3  END;
  8. 4  /
  9. PL/SQL procedure successfully completed.
  10. SQL> BEGIN
  11. 2  DBMS_RESOURCE_MANAGER.CREATE_CONSUMER_GROUP(‘REPORTING‘);
  12. 3  END;
  13. 4  /
  14. PL/SQL procedure successfully completed.
  15. SQL> BEGIN
  16. 2  DBMS_RESOURCE_MANAGER.CREATE_PLAN(‘OLTP_PLAN‘);
  17. 3  END;
  18. 4  /
  19. PL/SQL procedure successfully completed.
  20. SQL> BEGIN
  21. 2  DBMS_RESOURCE_MANAGER.CREATE_PLAN(‘REPORTING_PLAN‘);
  22. 3  END;
  23. 4  /
  24. PL/SQL procedure successfully completed.
  25. SQL> BEGIN
  26. 2    DBMS_RESOURCE_MANAGER.CREATE_PLAN_DIRECTIVE
  27. 3     (PLAN             => ‘OLTP_PLAN‘,
  28. 4      GROUP_OR_SUBPLAN => ‘SYS_GROUP‘,
  29. 5      CPU_P1          => 2);
  30. 6    DBMS_RESOURCE_MANAGER.CREATE_PLAN_DIRECTIVE
  31. 7     (PLAN             => ‘REPORTING_PLAN‘,
  32. 8      GROUP_OR_SUBPLAN => ‘SYS_GROUP‘,
  33. 9        CPU_P1          => 10);
  34. 10  END;
  35. 11  /
  36. PL/SQL procedure successfully completed.
  37. SQL>  BEGIN
  38. 2   DBMS_RESOURCE_MANAGER.CREATE_PLAN_DIRECTIVE
  39. 3      (PLAN            => ‘OLTP_PLAN‘,
  40. 4      GROUP_OR_SUBPLAN => ‘OTHER_GROUPS‘,
  41. 5      CPU_P1          => 1);
  42. 6  END;
  43. 7  /
  44. PL/SQL procedure successfully completed.
  45. SQL>  BEGIN
  46. 2   DBMS_RESOURCE_MANAGER.CREATE_PLAN_DIRECTIVE
  47. 3      (PLAN            => ‘REPORTING_PLAN‘,
  48. 4      GROUP_OR_SUBPLAN => ‘OTHER_GROUPS‘,
  49. 5      CPU_P1          => 1);
  50. 6  END;
  51. 7  /
  52. PL/SQL procedure successfully completed.
  53. SQL> EXEC DBMS_RESOURCE_MANAGER.VALIDATE_PENDING_AREA();
  54. PL/SQL procedure successfully completed.
  55. SQL> EXEC DBMS_RESOURCE_MANAGER.SUBMIT_PENDING_AREA();
  56. PL/SQL procedure successfully completed.
  57. SQL>

For more information about plans and directive plans, refer to the Oracle documentation. Find below the link:

Doc 12cR1

5. Summary:

In this article, we learned how Oracle 12c Resource Manager manages resources:

– Between PDBs.

– With a single PDB.

Now, with the new Oracle 12c database, we can use Oracle Resource
Manager to manage resource consumption, sharing between all the
databases installed on your server, under the condition that those
databases are plugged into one CDB (PDBs).

Download the article in PDF here: Oracle_12c_Resource_Management

Cheers,

Wissem

时间: 2024-10-10 22:12:59

转 Oracle 12c: Managing Resources的相关文章

Oracle 12c RAC 搭建手册

1  共享设备配置 1.1            设备划分说明 冗余策略 卷划分及大小说明 OCRVOTING Ocrvoting01 8G Ocrvoting02 8G Ocrvoting03 8G DATAFILE Data01 8G Data02 8G FRA_ARCH Fra01 8G Fra02 8G 我们这里OCRVOTING 采用Normal,DATA和FRA 采用external. 11g中每个OCR和vote disk 至少需要600M空间.在ASM 的冗余级别中: exter

Linux+Oracle+12c+RAC+安装配置详细-GI安装

IP地址 主机名 用途 实例名 192.168.12.58 oracle-rac03-db03 Public ip (节点1) 192.168.12.59 oracle-rac04-db04 Public ip(节点2) 192.168.12.73 rac03-db03-vip vip(节点1) racdb3   asm1 192.168.12.74 rac04-db04-vip vip(节点2) racdb4   asm2 192.168.12.75 SCANIP Scan ip shncdb

ORACLE 12C R2 RAC实战首发

大家都知道ORACLE database 12cR2当前正式版并没有发布,当前网上所发布的但是ORACLE database 12cR2技术文档,大多是理论型的从ORACLE OWW会议上,及该会议流露出来的PPT上所摘抄下来,重新组织而发布的文档,对于实战应用操作文档,则较少甚至很难找到. 但是,子衿技术团队已经提前拿到了ORACLE database12cR2的Beta版,已经完全具备了实战应用操作条件,所以有了<ORACLE 12C R2 RAC实战首发>一文". 实战的第一步

Centos 6.5 安装Oracle 12C RAC

1  共享设备配置 1.1            设备划分说明 冗余策略 卷划分及大小说明 OCRVOTING Ocrvoting01 8G Ocrvoting02 8G Ocrvoting03 8G DATAFILE Data01 8G Data02 8G FRA_ARCH Fra01 8G Fra02 8G 我们这里OCRVOTING 采用Normal,DATA和FRA 采用external. 11g中每个OCR和vote disk 至少需要600M空间.在ASM 的冗余级别中: exter

Oracle 12c 基于ASM 的单实例 搭建手册

从Oracle 10g开始,Oracle 开始推广ASM的使用,到了11g,RAC 集群已经必须使用ASM,所以对ASM的掌握程度也决定RAC的运维水平,这篇Blog 演示 Oracle12c 基于ASM 的单实例的的环境搭建. 这样即可以玩12c 的ASM,又不需要起2个集群,从而方便学习.具体环境搭建步骤如下. 1  安装需要的RPM 包 binutils-2.20.51.0.2-5.11.el6 (x86_64) glibc-2.12-1.7.el6 (x86_64) libgcc-4.4

Oracle 12c RAC MGMTDB 说明

 注:本文谢绝转载. 1  MGMTDB 说明 在Oracle 12.1.0.1的Grid Infrastructure 的安装中,可以选择是否安装Grid Infrastructure Management Repository (GIMR) 数据库:MGMTDB. 如下图: 在Grid Infrastructure 12.1.0.2 中,已经没有改选项,MIMR 数据库已经变成了强制选项. 在Oracle 12c 中Management Database 用来存储Cluster Health

Oracle 12c RAC 修改SCAN 配置

注:本文谢绝转载! 关于RAC 的SCAN 的理论说明,参考如下链接: Oracle RAC 集群 SCAN 说明 http://blog.csdn.net/tianlesoftware/article/details/42712979 Oracle 12c RAC 集群使用DNS 实现 SCAN http://blog.csdn.net/tianlesoftware/article/details/42917867 这篇blog 看下12c中对SCAN 的修改,修改包括2个方面: (1)  修

Oracle 12c RAC 替换 OCR 磁盘组操作步骤

注:本文谢绝转载! 为方便以后的测试,整了一套新的测试环境,600G PCIe 闪存卡+8核CPU+16G内存.  把整个虚拟机从我的电脑上直接copy 过去,网络什么都没问题,但是RAC 的共享设备是重新添加的. 这样之前旧的数据都不存在. 所以用脚本直接重建了OCR和Voting Disk,RAC 启动,没有问题,但是磁盘组出现错乱,Dave 有强迫症的倾向,所以重新重新添加了一个磁盘组.  把OCR 和 voting disk 都替换到新创建的OCR 磁盘组了. 所以以下所有的操作,只为一

Oracle 12c RAC 集群使用DNS 实现 SCAN

注:本文谢绝转载! 1   说明 关于RAC 集群的SCAN 特性说明参考: Oracle RAC 集群 SCAN 说明 http://blog.csdn.net/tianlesoftware/article/details/42712979 本文描述Oracle 12c RAC 集群使用DNS 实现SCAN. DNS 的配置工作,就是分配SCAN IP地址,并映射到一个域名上. SCAN IP最多有3个,我的环境,只有2个节点,这个也没关系,我照样弄3个SCANIP. 当前IP规划: [[em