转 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.
- SQL> select con_id,dbid,NAME,OPEN_MODE from v$pdbs;
- CON_ID DBID NAME OPEN_MODE
- ---------- ---------- ------------------------------ ----------
- 2 4063385794 PDB$SEED READ ONLY
- 4 1911833382 PDBBI READ WRITE
- 5 889037338 PDBHR READ WRITE
- 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:
- C:\Users\sesa258020>sqlplus / as sysdba
- SQL*Plus: Release 12.1.0.1.0 Production on Sat Jul 20 16:10:30 2013
- Copyright (c) 1982, 2013, Oracle. All rights reserved.
- Connected to:
- Oracle Database 12c Enterprise Edition Release 12.1.0.1.0 - 64bit Production
- With the Partitioning, OLAP, Advanced Analytics and Real Application Testing options
- SQL> EXEC DBMS_RESOURCE_MANAGER.CREATE_PENDING_AREA();
- PL/SQL procedure successfully completed.
- SQL>
- SQL> BEGIN
- 2 DBMS_RESOURCE_MANAGER.CREATE_CDB_PLAN(
- 3 plan => 'everyday_plan',
- 4 comment => 'CDB Resource Plan for PDBBI $ PDBHR'
- 5 );
- 6 END;
- 7 /
- PL/SQL procedure successfully completed.
- SQL>
- SQL> BEGIN
- 2 DBMS_RESOURCE_MANAGER.CREATE_CDB_PLAN_DIRECTIVE(
- 3 plan => 'everyday_plan',
- 4 pluggable_database => 'PDBBI',
- 5 shares => 1,
- 6 utilization_limit => 40,
- 7 parallel_server_limit => 60
- 8 );
- 9 END;
- 10 /
- PL/SQL procedure successfully completed.
- SQL>
- SQL> BEGIN
- 2 DBMS_RESOURCE_MANAGER.CREATE_CDB_PLAN_DIRECTIVE(
- 3 plan => 'everyday_plan',
- 4 pluggable_database => 'PDBHR',
- 5 shares => 2,
- 6 utilization_limit => 60,
- 7 parallel_server_limit => 100
- 8 );
- 9 END;
- 10 /
- PL/SQL procedure successfully completed.
- SQL>
- SQL> EXEC DBMS_RESOURCE_MANAGER.VALIDATE_PENDING_AREA();
- PL/SQL procedure successfully completed.
- SQL> EXEC DBMS_RESOURCE_MANAGER.SUBMIT_PENDING_AREA();
- PL/SQL procedure successfully completed.
- 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:
- SQL> EXEC DBMS_RESOURCE_MANAGER.CREATE_PENDING_AREA();
- PL/SQL procedure successfully completed.
- SQL> BEGIN
- 2 DBMS_RESOURCE_MANAGER.UPDATE_CDB_AUTOTASK_DIRECTIVE(
- 3 plan => 'everyday_plan',
- 4 new_shares => 2,
- 5 new_utilization_limit => 20,
- 6 new_parallel_server_limit => 75);
- 7 END;
- 8 /
- PL/SQL procedure successfully completed.
- SQL> EXEC DBMS_RESOURCE_MANAGER.VALIDATE_PENDING_AREA();
- PL/SQL procedure successfully completed.
- SQL> EXEC DBMS_RESOURCE_MANAGER.SUBMIT_PENDING_AREA();
- PL/SQL procedure successfully completed.
- 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.
- SQL> EXEC DBMS_RESOURCE_MANAGER.CREATE_PENDING_AREA();
- PL/SQL procedure successfully completed.
- SQL> BEGIN
- 2 DBMS_RESOURCE_MANAGER.UPDATE_CDB_DEFAULT_DIRECTIVE(
- 3 plan => 'everyday_plan',
- 4 new_shares => 1,
- 5 new_utilization_limit => 40,
- 6 new_parallel_server_limit => 30
- 7 );
- 8 END;
- 9 /
- PL/SQL procedure successfully completed.
- SQL> EXEC DBMS_RESOURCE_MANAGER.VALIDATE_PENDING_AREA();
- PL/SQL procedure successfully completed.
- SQL> EXEC DBMS_RESOURCE_MANAGER.SUBMIT_PENDING_AREA();
- PL/SQL procedure successfully completed.
- SQL>
You can delete CDB resource plan directives for the PDBs using the DELETE_CDB_PLAN_DIRECTIVE procedure
Example:
- BEGIN
- DBMS_RESOURCE_MANAGER.DELETE_CDB_PLAN_DIRECTIVE(
- plan => 'everyday_plan',
- pluggable_database => 'PDBBI');
- 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;
- SQL> ALTER SYSTEM SET resource_manager_plan='everyday_plan';
- System altered.
- OR
- ALTER SYSTEM SET RESOURCE_MANAGER_PLAN = 'FORCE:everyday_plan';
You can disable CDB resource management;
- SQL> ALTER SYSTEM SET resource_manager_plan=’’;
- 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:
- SQL> EXEC DBMS_RESOURCE_MANAGER.CREATE_PENDING_AREA();
- PL/SQL procedure successfully completed.
- SQL> BEGIN
- 2 DBMS_RESOURCE_MANAGER.SET_CONSUMER_GROUP_MAPPING
- 3 (
- 4 ATTRIBUTE=> 'ORACLE_USER',
- 5 VALUE=> 'WISSEM',
- 6 CONSUMER_GROUP => 'OLTP'
- 7 );
- 8 END;
- 9 /
- PL/SQL procedure successfully completed.
- SQL> EXEC DBMS_RESOURCE_MANAGER.VALIDATE_PENDING_AREA();
- PL/SQL procedure successfully completed.
- SQL> EXEC DBMS_RESOURCE_MANAGER.SUBMIT_PENDING_AREA();
- PL/SQL procedure successfully completed.
- 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.
- SQL> alter session set container=PDBHR;
- Session altered.
- SQL> EXEC DBMS_RESOURCE_MANAGER.CREATE_PENDING_AREA();
- PL/SQL procedure successfully completed.
- SQL> BEGIN
- 2 DBMS_RESOURCE_MANAGER.CREATE_CONSUMER_GROUP('OLTP');
- 3 END;
- 4 /
- PL/SQL procedure successfully completed.
- SQL> BEGIN
- 2 DBMS_RESOURCE_MANAGER.CREATE_CONSUMER_GROUP('REPORTING');
- 3 END;
- 4 /
- PL/SQL procedure successfully completed.
- SQL> BEGIN
- 2 DBMS_RESOURCE_MANAGER.CREATE_PLAN('OLTP_PLAN');
- 3 END;
- 4 /
- PL/SQL procedure successfully completed.
- SQL> BEGIN
- 2 DBMS_RESOURCE_MANAGER.CREATE_PLAN('REPORTING_PLAN');
- 3 END;
- 4 /
- PL/SQL procedure successfully completed.
- SQL> BEGIN
- 2 DBMS_RESOURCE_MANAGER.CREATE_PLAN_DIRECTIVE
- 3 (PLAN => 'OLTP_PLAN',
- 4 GROUP_OR_SUBPLAN => 'SYS_GROUP',
- 5 CPU_P1 => 2);
- 6 DBMS_RESOURCE_MANAGER.CREATE_PLAN_DIRECTIVE
- 7 (PLAN => 'REPORTING_PLAN',
- 8 GROUP_OR_SUBPLAN => 'SYS_GROUP',
- 9 CPU_P1 => 10);
- 10 END;
- 11 /
- PL/SQL procedure successfully completed.
- SQL> BEGIN
- 2 DBMS_RESOURCE_MANAGER.CREATE_PLAN_DIRECTIVE
- 3 (PLAN => 'OLTP_PLAN',
- 4 GROUP_OR_SUBPLAN => 'OTHER_GROUPS',
- 5 CPU_P1 => 1);
- 6 END;
- 7 /
- PL/SQL procedure successfully completed.
- SQL> BEGIN
- 2 DBMS_RESOURCE_MANAGER.CREATE_PLAN_DIRECTIVE
- 3 (PLAN => 'REPORTING_PLAN',
- 4 GROUP_OR_SUBPLAN => 'OTHER_GROUPS',
- 5 CPU_P1 => 1);
- 6 END;
- 7 /
- PL/SQL procedure successfully completed.
- SQL> EXEC DBMS_RESOURCE_MANAGER.VALIDATE_PENDING_AREA();
- PL/SQL procedure successfully completed.
- SQL> EXEC DBMS_RESOURCE_MANAGER.SUBMIT_PENDING_AREA();
- PL/SQL procedure successfully completed.
- 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
转 Oracle 12c: Managing Resources的更多相关文章
- Oracle 12c RAC 搭建手册
1 共享设备配置 1.1 设备划分说明 冗余策略 卷划分及大小说明 OCRVOTING Ocrvoting01 8G Ocrvoting02 8G Ocrvoting03 8G ...
- Oracle 12c用户和安全管理
前言: Oracle 12c的多租户(multitenant)环境与SQL Server的架构非常相似,CDB$ROOT类似于master.PDB$SEED类似于model.各个pluggable d ...
- ORACLE 12c RAC的常用管理命令
ORACLE 12c RAC的常用管理命令 一.查询 1.RAC查询 1.1.查询节点 [grid@swnode1 ~]$ su - grid [grid@swnode1 ~]$ /u01/app/1 ...
- Oracle 12c 多租户家族(12c 18c 19c)如何在 PDB 中添加 HR 模式
Oracle 12c 多租户家族(12c [12.2.0.1].18c [12.2.0.2].19c [12.2.0.3])如何在 PDB 中添加模式:19c (19.3) 手工添加示例 HR 用户 ...
- ORACLE 12C新特性——CDB与PDB
Oracle 12C引入了CDB与PDB的新特性,在ORACLE 12C数据库引入的多租用户环境(Multitenant Environment)中,允许一个数据库容器(CDB)承载多个可插拔数据库( ...
- Oracle 12c 使用scott等普通用户的方法
目录: 一.前言 二.使用普通用户 三.自动启动PDB 一.前言 最近电脑上安装了oracle 12c数据库,想体验下新特性.安装完后,便像11g一样在dos窗口进行下面的操作: SQL Produc ...
- [原创]Oracle 12c 抢先安装手迹
[前言] Oracle 12c 终于投放市场了,唉,等了很久了.据官方说这是一个为云计算平台量身定做的版本....且不管真的假的,先让我们把它装上再说. 注:笔者在安装的过程中发现12c的安装过程,较 ...
- java开发连接Oracle 12c采用PDB遇到问题记录
今天初次使用java连接Oracle 12c,遇到各种问题,为方便后续查询,在汇总了问题记录及解决方案如下. ORA-28040: No matching authentication protoco ...
- oracle 12c 创建PDB用户即Local User (PDB与CDB)
Oracle 12C用户创建与表空间分配 数据库安装完成后,首先用系统用户链接数据库容器(CDB), 在数据库容器(CDB)中创建表空间‘imei’ SQL>create tablespace ...
随机推荐
- ASP.NET MVC 学习笔记-2.Razor语法 ASP.NET MVC 学习笔记-1.ASP.NET MVC 基础 反射的具体应用 策略模式的具体应用 责任链模式的具体应用 ServiceStack.Redis订阅发布服务的调用 C#读取XML文件的基类实现
ASP.NET MVC 学习笔记-2.Razor语法 1. 表达式 表达式必须跟在“@”符号之后, 2. 代码块 代码块必须位于“@{}”中,并且每行代码必须以“: ...
- shutdown abort模式丢失redo,使用隐含參数启库
shutdown abort模式 丢失redo log 无法open数据库 通过告警报错ORA-00354: corrupt redo log block header 从该错误能够看出当前日志的re ...
- sql server 笔记1--case、WAITFOR、TRY CATCH
一.case 转自:http://blog.csdn.net/add8849/article/details/576424 深入使用:http://blog.csdn.net/akuoma/artic ...
- JavaScript语言基础12
使用if语句时.假设碰到很多个条件时,就不应该继续使用if语句了,JavaScript提供了一个更高效的替代方案,那就是switch语句,我们先看看switch语句的模板: <HTML> ...
- 基于struts环境下的jquery easyui环境搭建
下载地址: http://download.csdn.net/detail/cyberzhaohy/7348451 加入了json包:jackson-all-1.8.5.jar,项目结构例如以下: 測 ...
- Android Studio运行app时提示Error: Please select Android SDK
最近开启了一个android项目,点“Run”键运行app,并报错Error:Please select Android SDK: 选择 File -> Project Structure 调整 ...
- java泛型-类型擦除
详细内容:参考java编程思想P373,p650. Java 泛型(Generic)的引入加强了参数类型的安全性,减少了类型的转换,但有一点需要注意:Java 的泛型在编译器有效,在运行期被删除,也就 ...
- 关于数论【polya计数法】
可以预见数论推公式是有多么蛋疼. 让我简明扼要的讲讲吧(多都说不出来,毕竟才做了两道题)其实呢,这个算法应该归入群论,有个有用的东西:置换群,它表示一个集合包括很多的置换.先讲讲置换吧:↓(这是个置换 ...
- How to Execute Page_Load() in Page's Base Class?
https://stackoverflow.com/questions/2737092/how-to-execute-page-load-in-pages-base-class We faced th ...
- 在Main Thread中使用异步
Whenever you first start an Android application, a thread called "main" is automatically c ...