Category Archives: Administration

Oracle 12c – User administrative privileges Changes

Oracle 12c has increased the security of the RDBMS by increasing the number of user accounts for administrative tasks and reducing the overall permissions these users have in the RDBMS.   This increases security by limiting the amount of control a single user account has over your data.   This article outlines the general changes to administrative account privileges in Oracle 12c.

 

  1. New roles were created to increase security through separation of duties and the principle of least privilege. SYSDACKUP, SYSDG, SYSKM.   This new roles are used to eliminate the need to grant SYSDBA to some users.
    1. SYSBACKUP – Allows for connection to DB through RMAN for all backup and recovery operation.
    2. SYSDG – Allows for Data Guard operations and can be used either through Data Guard Broker or the DGMGRL command line. To connect with a password, you must create a password file for this user.
    3. SYSKM – Allows for management of Transparent Data Encryption wallet operations. To connect with a password, you must create a password file for this user.
  2. New privilege PURGE DBA_RECYCLEBIN has been created to execute PURGE DBA_RECYCLEBIN command without requiring the SYSDBA privilege.
  3. SELCT ANY DICTIONARY privilege no longer permits access to tables:
    1. DEFAULT_PWD$
    2. ENC$
    3. LINK$
    4. USER$
    5. USER_HISTORY$
    6. XS$VERIFIERS
  4. UNLIMITED TABLESPACE privilege no longer included in RESOURCE role.

 

Larry Catt

OCP

Oracle 12c – Recovery Manager (RMAN) Utility Commands

RMAN is the preferred method used for backup and recovery of Oracle database.   This article gives a brief overview of commands used to Configure, Display Configurations, Reset to Default, and take simple backups.

 

 

 

  • The SHOW command gives current settings for RMAN utility to the associate target database.
  • The CLEAR command resets to RMAN defaults.
  • The following command allows for three backup copies of all data files and control files. the forth oldest will be considered obsolete and deleted. default is 1.
    • RMAN> configure retention policy to redundancy 3;
  • The following ensures that backup window of recovery is at least 7 days in the past, backups will be kept to allow for this regardless of redundancy policy.
    • RMAN> configure retention policy to recovery window of 7 days;
  • The following changes the default device type to tape, the default is disk.
    • RMAN> configure default device type to sbt;
  • Regardless of default device type, you can perform backup to specific backup with ‘device type’ clause.
    • RMAN> backup device type sbt database;
    • RMAN> backup device type disk database;
  • RMAN can backup as an image copy or backup set.
    • RMAN> configure device type disk backup type to backupset;
    • RMAN> configure device type disk backup type to copy;
  • TAPE backups can only be backup sets.
  • binary compression can be used with backupsets with COMPRESSED option.
    • RMAN> configure device type disk backup type to compressed backupset;
    • RMAN> configure device type sbt backup type to compressed backupset;
  • An RMAN channel is a connection to db server process, use the configure channel command to create and change channel settings.
    • RMAN> configure channel device type disk maxpiecesize 1g;
    • RMAN> configure channel device type disk format /tmp/%U;
  • By default RMAN allocates a single disk channel for all operations, you can specify a distinct file name for a channel, but RMAN does not create a backup in the fast recovery area.
    • RMAN> configure channel device type disk format ‘/u01/oradata/orcl_df%t_s%s_s%p’;
    • RMAN> configure channel device type disk format ‘+dgroup1’;
  • You can perform parallel backups by defining multiple channels for use.
    • RMAN> RUN
    • {
    • allocate channel u01 device type disk format ‘/u01/%u’;
    • allocate channel u02 device type disk format ‘/u02/%u’;
    • backup database plus archivelog;
    • }
  • RMAN can be configured to autobackup control files and if in archivelog mode and a change occurs to controlfiles, they will be automatically backed up.
    • RMAN> configure controlfile autobackup on;
    • RMAN> configure controlfile autobackup off;
  • RMAN configuration can be reset to default values by using the CLEAR option.
    • RMAN> configure default device type clear;
    • RMAN> configure retention policy clear;
    • RMAN> configure controlfile autobackup clear;
  • When RMAN optimization is enabled, it will skip files that have not changed since the last backup set. RMAN determines this by:
    • Datafile must have same DBID, checkpoint SCN, creation SCN, resetlogs scn and time as one already in backup set.
    • Datafile must be offline, read-only or closed.
    • Archived log – must have same DBID, thread, sequence number, resetlogs scn and time.
    • Backup Set – must have the same DBID, backup set record id, and stamp.
  • RMAN will still take a backup of retention policy requires and if TO DESTINATION is used with BACKUP RECOVERY AREA or BACKUP RECOVERY FILES.
  • Turn RMAN optimization on and off with:
    • RMAN> configure backup optimization on;
  • Once optimization is enabled, backup will not be performed, if nothing has changed since the last valid backup.
  • Backup optimization can be overridden by the FORCE option.
    • RMAN> backup database force;
    • RMAN> backup archivelog all force;

 

 

 

Larry Catt

OCP

Oracle 12c – Use the Redo Logfile Size Advisor

Sizing of the redo logs has a large impact on database performance because the redo log size has a heavy impact on the behavior of DBW and ARCH processes.  Generally, large redo logs redo provide better performance by decreasing the amount of check points.   However, the parameter FAST_START_MTTR_TARGET is used to limit the amount of time required to recover the database and more frequent checkpoints make for a shorter recovery time, thus it is a balance between recovery time and performance.

 

V$INSTANCE_RECOVERY view column OPTIMAL_LOGFILE_SIZE shows the optimal size of the redo log file.  This info is also available in Redo Log Group page of OEM.  As a general rule, redo logs should switch once every 20 minutes.  NOTE:  the initialization parameter FAST_START_MTTR_TARGET must be set to have this column populated.

 

SQL> select optimal_logfile_size from v$instance_recovery;

 

OPTIMAL_LOGFILE_SIZE

——————–

               41425

 

SQL>

 

 

Larry Catt

OCP

Oracle 12c – Use Table enhancements

You can now make columns within a table invisible and general access will only display visible tables.  The following queries will not display invisible columns:

  1. Select * from
  2. Describe command
  3. %ROWTYPE declaration in PL/SQL
  4. Describe on OCI

 

Invisible columns will be displayed if they are explicitly called by column name and you can insert data by explicitly naming the column, but if insert does not list column names you cannot insert into invisible columns.  Columns can be made invisible during table creation, adding columns, or modifying them.  Virtual columns can be invisible also.  You can use an invisible column as a partition key.

 

Invisible columns have the following restrictions.

  1. External, cluster, and temporary tables cannot have invisible columns.
  2. Attributes of user-defined types cannot be invisible.

 

 

Example of Column invisibility using SCOTT.EMP table.

 

 

  1. Logon to SQLPLUS as the user SCOTT

 

[oracle@linux2 ~]$ sqlplus scott/password

SQL*Plus: Release 12.1.0.2.0 Production on Thu Dec 29 14:14:06 2016

Copyright (c) 1982, 2014, Oracle.  All rights reserved.

Last Successful login time: Thu Dec 29 2016 13:47:09 -05:00

 

Connected to:

Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 – 64bit Production

With the Partitioning, OLAP, Advanced Analytics, Real Application Testing

and Unified Auditing options

 

SQL>

 

  1. select table_name, column_name, hidden_column from USER_TAB_COLS.

 

SQL>  column table_name format a10

SQL> column column_name  format a10

SQL> select table_name, column_name, hidden_column from user_tab_cols where table_name=’EMP’;

 

TABLE_NAME COLUMN_NAM HID

———- ———- —

EMP        EMPNO      NO

EMP        ENAME      NO

EMP        JOB        NO

EMP        MGR        NO

EMP        HIREDATE   NO

EMP        SAL        NO

EMP        COMM       NO

EMP        DEPTNO     NO

 

8 rows selected.

 

SQL>

 

 

NOTE:  None of the columns are hidden.

 

  1. Now select the first three rows from table SCOTT.EMP.

 

SQL> set linesize 200

SQL>  select * from scott.emp where rownum<4;

 

     EMPNO ENAME      JOB              MGR HIREDATE         SAL       COMM     DEPTNO

———- ———- ——— ———- ——— ———- ———- ———-

      7369 SMITH      CLERK           7902 17-DEC-80        800                    20

      7499 ALLEN      SALESMAN        7698 20-FEB-81       1600        300         30

      7521 WARD       SALESMAN        7698 22-FEB-81       1250        500         30

 

SQL>

 

  1. Now alter the table SCOTT.EMP and make column HIRDATE, SAL, COMM invisible.

 

alter table scott.emp modify hiredate invisible;

alter table scott.emp modify sal invisible;

alter table scott.emp modify comm invisible;

 

SQL> alter table scott.emp modify hiredate invisible;

alter table scott.emp modify sal invisible;

alter table scott.emp modify comm invisible;

 

Table altered.

SQL>

Table altered.

SQL>

Table altered.

SQL>

 

  1. Select the first 3 rows of table SCOTT.EMP.

 

SQL>  select * from scott.emp where rownum<4;

 

     EMPNO ENAME      JOB              MGR     DEPTNO

———- ———- ——— ———- ———-

      7369 SMITH      CLERK           7902         20

      7499 ALLEN      SALESMAN        7698         30

      7521 WARD       SALESMAN        7698         30

SQL>

 

NOTE:  You no longer see the columns HIREDATE, SAL, or COMM

 

 

  1. Now desc the table SCOTT.EMP.

 

SQL> desc scott.emp;

 Name                                Null?                        Type

 ————                           ——–                   ——————————————-

 EMPNO                             NOT NULL             NUMBER(4)

 ENAME                                                          VARCHAR2(10)

 JOB                                                                 VARCHAR2(9)

 MGR                                                               NUMBER(4)

 DEPTNO                                                         NUMBER(2)

SQL>

 

NOTE:  You no longer see the columns HIREDATE, SAL, or COMM

 

 

 

  1. Now select the first 3 values but explicitly request the columns, NOTE they are still there but need to be explicitly queried.

 

SQL> select EMPNO, ENAME, JOB, MGR, HIREDATE, SAL, COMM, DEPTNO from scott.emp where rownum<4;

 

     EMPNO ENAME      JOB              MGR HIREDATE         SAL       COMM     DEPTNO

———- ———- ——— ———- ——— ———- ———- ———-

      7369 SMITH      CLERK           7902 17-DEC-80        800                    20

      7499 ALLEN      SALESMAN        7698 20-FEB-81       1600        300         30

      7521 WARD       SALESMAN        7698 22-FEB-81       1250        500         30

SQL>

 

  1. Additionally the hidden_columns value in user_tab_cols will also be updated accordingly.

 

SQL> column table_name format a10

column column_name  format a10

select table_name, column_name, hidden_column from user_tab_cols where table_name=’EMP’;

SQL> SQL>

TABLE_NAME COLUMN_NAM HID

———- ———- —

EMP        EMPNO      NO

EMP        ENAME      NO

EMP        JOB        NO

EMP        MGR        NO

EMP        HIREDATE   YES

EMP        SAL        YES

EMP        COMM       YES

EMP        DEPTNO     NO

8 rows selected.

SQL>

 

  1. This completes using invisible columns in Oracle 12c.

 

Larry Catt

OCP

Oracle 12c – Real-Time Database Operation Monitoring

Oracle 12c provides the ability to monitor PL/SQL operations within the database in real-time.  Database operations are either simple or composite.   Simple operations are single SQL or PL/SQL procedure/function and Composite operations are activity between two points in time.  A session doing multiple transactions, a given session can only be involved in one composite operation at a time.  This article outlines the basics involved in real-time database operation monitoring.

 

 

  1. Real time SQL monitoring was introduced in 11g but only supported simple operations,12c supports composite operation monitoring, which allows you the ability to monitor a logical grouping of actions to support a particular business requirement.
  2. Real-time Monitoring starts automatically when SQL statements run in parallel or consume more than 5 seconds of CPU or I/O time.
  3. Real-Time monitoring can be viewed via Cloud Control on Monitor SQL Execution page which is the preferred method, allowing you to drill down. It can also be monitored via the data dictionary views, or DBMS_SQL_MONITOR package.
  4. Data Dictionary views:
    1. V$SQL_MONITOR
    2. V$SQL_MONITOR_SESSTAT
    3. V$SQL_PLAN_MONITOR

 

  1. DBMS_SQL_MONITOR package provides the following functions and procedure
    1. REPORT_SQL_MONITOR – gives detailed report.
    2. BEGIN_OPERATION – starts monitoring a session’s performance.
    3. END_OPERATION – ends monitoring a session’s performance

 

  1. SQL Monitoring is automatic when STATISTICS_LEVEL is set to TYPICAL or ALL and Oracle will begin monitoring long running queries automatically.
  2. The init parameter CONTROL_MANAGEMENT_PACK_ACCESS must be set to default of DIAGNOSTIC+TUNING to use this feature.
  3. Hints of MONITOR and NO_MONITOR can be used to force or stop monitoring.

 

SELECT /*+MONITOR*/ first_name from emp;

 

  1. Use the BEGIN_OPERATION and END_OPERATION function of DBMS_SQL_MONITOR package to monitor entire session.

 

 

Larry Catt

OCP

Oracle 12c – Perform daily administration tasks

Oracle 12c does not eliminate the need for daily administrative tasks of a database administrator, however it does have many enhancement that can aid in the identification of problems/sub-par performance.    Additionally, there exist two camps on monitoring the health of a database:  One wanting to automate all monitoring tasks and let the database tell you when something is wrong; and One that wants tasks to remain manual where you keep a closer contact with database structures and are able to determine trends.  Regardless of how you perform your monitoring, the following list of daily DBA tasks is a good general guideline.   NOTE:   This list is not limited to just error checking, a DBA job covers both error correction and error avoidance.

 

  1. Check for any database errors in alert and trace.
  2. Check for any networking errors in listener alert. (other network connectivity logs)
  3. Check for errors in Operating System log files for database servers.
  4. Check for errors in Storage Area Network log files.
  5. Check Space allocation for database storage. (database tablespaces)
  6. Check for Space availability at Operating System Layer.
  7. Check any Application Layer error logs.
  8. Installing, Upgrading, and Patching Oracle Database server software (OS) and application tools. (Test installing, upgrading, and Patching before production implementations)
  9. Allocation of system storage and planning future storage.
  10. Creating primary database storage structure (tablespaces)
  11. Create primary database objects (tables, views, indexes)
  12. Planning backup and recovery procedure.
  13. Consult oracle technical support
  14. Ensure compliance with Oracle license agreement.
  15. Modify database structures.
  16. Managing users and maintain security.
  17. Controlling and Monitoring user activity and privileges.
  18. Monitor and optimize performance.
  19. Maintain archive tape backup/recovery devices (other type of backup device).
  20. Backup and restore database. (including test recovery at least twice a year)

 

Larry Catt

OCP

 

 

 

Oracle 12c – Use Secure File LOBs

SecureFile LOBs were added to Oracle 11g to provide better performance over the legacy LOB format of BasicFile LOBs.

New features of SecureFile LOBs:

  1. Intelligent LOB compression allows user to compress file.
  2. Intelligent LOB encryption in place and allows for random reads and writes.
  3. Deduplication option allows for duplicate data to only be stored once.
  4. LOB data path optimization allows for logical cache above storage level, read prefetching, new caching modes, vectored IO

 

In Oracle 12c the initialization parameter of DB_SECUREFILE determines use of LOB type with the following options:

ALWAYS – Attempts to use SecureFile LOBS but uses BasicFile LOB if ASSM is not in use.

PERMITTED – Allows SecureFile LOBs to be created.

PREFERRED – All LOBs are SecureFile unless BasicFile is specified.  When PREFERRED is sent inherited                                type from partition and columns are ignored.

NEVER – Disallows use of SecureFile LOBs, attempts to create SecureFile LOBs will be created as BasicFile.

IGNORE – SECUREFILE keyword and all options are ignored.

 

Online redefinition can be performed at table/partition level and does not require the table or partition to be taken offline. However redefinition will require storage equal to double current LOB and global indexes will have to be rebuilt.  Redefined SecureFiles inherit LOB column settings for deduplication, encryption, and compression made at original BasicFile LOB.

 

DBMS_LOB package has several options for redefine:

DBMS_LOB.GETOPTIONS – give current settings of SecureFile LOB.

DBMS_LOB.SETOPTIONS – allows to change current settings.

DBMS_LOB.IISECUREFILE – Determines if it is SECUREFILE LOB or not.

DBMS_SPECE.SPACE_USAGE  – Procedure returns amount of space used in blocks by all LOBs and can only be used if auto segment space management is in use.

 

 

Larry Catt

OCP

Use ILM feature: Heat Maps

Oracle Information Lifecycle Management (ILM) is the processes by which we can manage data from creation to deletion.    It allows us a method to increase speed of access and to acquire metadata about use.    The two features which support ILM in Oracle 12c are Heat Maps and Automatic Data Optimization.    This procedure will cover the use of Heat Maps within a 12c RDBMS.   Heat Maps track use information about data at the row and segment level.   NOTE:  Heat Maps are not supported in CDB multitenant databases.

 

  1. Logon to your Oracle server as the Oracle software owner and logon to SQLPLUS

 

[root@linux2 oracle]# su – oracle

Last login: Wed Sep  7 14:47:35 EST 2016 on pts/1

Enter database to use:

1 – ORCL

2 – CDB1

Option >

1

[oracle@linux2 ~]$ sqlplus / as sysdba

 

SQL*Plus: Release 12.1.0.2.0 Production on Wed Sep 7 14:50:11 2016

Copyright (c) 1982, 2014, Oracle.  All rights reserved.

Connected to:

Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 – 64bit Production

With the Partitioning, OLAP, Advanced Analytics and Real Application Testing options

 

SQL>

 

 

  1. Check to see if Heat Maps is enabled for your database and if not turn it on with the command: “alter system set heat_map=on;”

 

SQL> show parameter heat_map

NAME                                 TYPE        VALUE

———————————— ———– ——————————

heat_map                             string      OFF

SQL> alter system set heat_map=on;

System altered.

 

SQL> show parameter heat_map

NAME                                 TYPE        VALUE

———————————— ———– ——————————

heat_map                             string      ON

SQL>

 

  1. Create user test with default tablespace of users.

 

create user test identified by test

default tablespace users quota unlimited on users;

grant dba to test;

 

 

  1. Create table test_hm with column col_a and col_b.

 

create table test.test_hm(col_a number,

col_b varchar2(10))

partition by range (col_a)

(partition less_then_50 values less than (‘50000000’)

tablespace users);

 

  1. Insert 20 million records to test_hm with the following pl/sql block.

 

 

Declare

 

val_a number:=1;

val_b varchar2(10):=’a’;

 

begin

 

while val_a<20000001

loop

insert into test.test_hm(col_a, col_b)

values(val_a, val_b);

 

val_a:=val_a+1;

if val_b=’z’

then

val_b:=’a’;

else

val_b:=chr(ascii(val_b) + 1);

end if;

 

end loop;

commit;

end;

/

 

 

  1. Check records for current heat maps in the view

 

column NAME format a10

column SUB_NAME format a15

column WRITE format a14

column READ format a14

select object_name Name,

                SUBOBJECT_NAME SUB_NAME,

   to_char(segment_write_time,’DD-MON HH:MI’) write,

   to_char(segment_read_time,’DD-MON HH:MI’) read

   from dba_heat_map_segment where object_name=’TEST_HM’;

 

SQL> SQL> column NAME format a10

SQL> column SUB_NAME format a15

SQL> column WRITE format a14

SQL> column READ format a14

SQL> select object_name Name,

  2     SUBOBJECT_NAME SUB_NAME,

  3     to_char(segment_write_time,’DD-MON HH:MI’) write,

  4     to_char(segment_read_time,’DD-MON HH:MI’) read

  5     from dba_heat_map_segment where object_name=’TEST_HM’;

 

NAME       SUB_NAME        WRITE          READ

———- ————— ————– ————–

TEST_HM    LESS_THEN_50    13-SEP 01:54

 

SQL>

 

  1. Create sub_partitions for table test_hm for col_a values ( <5 million, < 10 million, < 15 million, and < 20 million)

 

ALTER TABLE test.test_hm split PARTITION less_then_50 at (5000000) into

  (PARTITION less_than_5, PARTITION greater_than_5);

 

ALTER TABLE test.test_hm split PARTITION greater_than_5 at (10000000) into

  (PARTITION less_than_10, PARTITION greater_than_10);

 

ALTER TABLE test.test_hm split PARTITION greater_than_10 at (15000000) into

  (PARTITION less_than_15, PARTITION greater_than_15);

 

ALTER TABLE test.test_hm split PARTITION greater_than_15 at (20000000) into

  (PARTITION less_than_20, PARTITION greater_than_20);

 

 

  1. No perform a select on data where a sort operation would be require, we used the below statement.

 

select * from test.test_hm where col_a between 12000000 and 19000000 order by col_b;

 

 

  1. Now execute the statement from step 6 to see heat map information about the scans which are occurring in our table.

 

SQL> column NAME format a10

SQL> column SUB_NAME format a15

SQL> column WRITE format a14

SQL> column READ format a14

SQL> select object_name Name,

  2     SUBOBJECT_NAME SUB_NAME,

   to_char(segment_write_time,’DD-MON HH:MI’) write,

   to_char(segment_read_time,’DD-MON HH:MI’) read

  3    4    5     from dba_heat_map_segment where object_name=’TEST_HM’;

 

NAME       SUB_NAME        WRITE          READ

———- ————— ————– ————–

TEST_HM    LESS_THAN_20

TEST_HM    LESS_THAN_15

TEST_HM    LESS_THAN_5     13-SEP 02:02

 

SQL>

 

  1. This completes our coverage of Heat Maps in Oracle 12c

 

Larry Catt

OCP

Oracle 12c – Implement real-time database operation monitoring

This procedure outlines the steps of performing real-time database operation monitoring via the sqlplus console using the package DBMS_SQL_MONITOR.

 

  1. Start SQLPLUS and connect as a user with the appropriate privileges.

 

[oracle@linux2 ~]$ sqlplus / as sysdba

SQL*Plus: Release 12.1.0.2.0 Production on Tue Jul 20 08:00:16 2016

Copyright (c) 1982, 2014, Oracle.  All rights reserved.

 

Connected to:

Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 – 64bit Production

With the Partitioning, OLAP, Advanced Analytics, Real Application Testing

and Unified Auditing options

SQL>

 

  1. Create user test and table test_tab, than insert 10 miliion records into test.test_tab for monitoring test.

 

create user test identified by test

default tablespace users quota unlimited on users;

 

grant dba to test;

 

create table test.test_tab(col_a number,

col_b varchar2(10));

 

 

Jullare

val_a number:=1;

val_b varchar2(10):=’a’;

begin

while val_a<20000001

loop

insert into test.test_tab(col_a, col_b)

values(val_a, val_b);

val_a:=val_a+1;

if val_b=’z’

then

val_b:=’a’;

else

val_b:=chr(ascii(val_b) + 1);

end if;

end loop;

commit;

end;

/

 

 

Execution:

 

SQL> create user test identified by test

default tablespace users quota unlimited on users;

  2

User created.

 

SQL> grant dba to test;

 

Grant succeeded.

 

SQL> create table test.test_tab(col_a number,

col_b varchar2(10));

  2

Table created.

 

SQL> Jullare

val_a number:=1;

  2    3  val_b varchar2(10):=’a’;

  4  begin

  5  while val_a<20000001

  6  loop

  7  insert into test.test_tab(col_a, col_b)

  8  values(val_a, val_b);

  9  val_a:=val_a+1;

 10  if val_b=’z’

 11  then

 12  val_b:=’a’;

 13  else

 14  val_b:=chr(ascii(val_b) + 1);

 15  end if;

 16  end loop;

 17  commit;

 18  end;

 19  /

PL/SQL procedure successfully completed.

 

SQL>

 

 

 

  1. Define a variable to hold the execution ID.

 

var opid NUMBER

 

  1. Begin the database operation.

 

EXEC :opid := DBMS_SQL_MONITOR.BEGIN_OPERATION(‘op_test’);

 

  1. Run the queries in the operation.

 

SELECT col_a FROM test.test_tab order by col_a;

SELECT col_b FROM test.test_tab order by col_a;

 

  1. End the database operation.

 

EXEC DBMS_SQL_MONITOR.END_OPERATION(‘op_test’, :opid);

 

  1. Confirm that the database operation completed.

 

SQL> SELECT dbop_name, status FROM v$sql_monitor WHERE dbop_name = ‘op_test’;

DBOP_NAME                      STATUS

—————————— ——————-

rtsm_op                        DONE

SQL>

 

  1. This completes manual execution of real_time database operation monitoring with DBMS_SQL_MONITOR.

 

Larry Catt

OCP

Oracle 12c – Use Resource Manager to manage resources

Oracle Database Resource Manager is designed to optimize resource allocation among concurrent database sessions.   It prevents from the OS making resource decisions during high overhead periods without awareness of database needs.  Resource Manager gives the database more control over resource allocation and gives the ability to place sessions into groups and allocated resources to those groups, through resource plans.    Oracle 12c comes with the following Resource Plans by default:

  • DEFAULT_MAINTENANCE_PLAN – default plan for maintenance windows.
  • DEFAULT_PLAN – Default gives priority to SYS_GROUP and gives minimal resources to maintenance and diagnostics operations.
  • DSS_PLAN – for data warehouse gives priority to DDS queries and less to non-DDS and ETL operations.
  • ETL_CRITICAL_PLAN – for data warehouse gives priority to ETL over DDS.
  • INTERNAL_QUIESCE – quiescing the database, must be done manually with QUIESCE command.
  • MIXED_WORKLOAD_PLAN – prioritized interactive processes over batch.

Three elements of Resource Management are:

  • Resource Consumer Group – group of sessions based on resource needs.
  • Resource Plan – directives that detail how resources are allocated to group.
  • Resource Plan Directive – Associates resource consumer group with a particular plan and how resources are allocated to consumer group.

Resource plan directives can limit CPU and I/O for sessions in the group.   This is done by a processes call switching, which specifies an action to take when a call exceeds the limit.  Resource plan directive attribute SWITCH_GROUP determines which action to take.  If the attribute is a consumer group name action 1 will be taken, if the attribute is KILL_SESSION action 2, and if attribute is CANCEL_SQL action 3.

The possible actions are:

  • Session is switched to a consumer group with lower resource allocation.
  • Session is killed.
  • Sessions current SQL is aborted.

Attributes which control I/O and CPU are as follow:   NOTE: unlimited means no limit.

  • SWITCH_TIME – CPU time in seconds before switch
  • SWITCH_IO_MEGABYTES – amount of I/O read and writes before switch.
  • SWITCH_IO_REQS – number of I/O requests before switch.

Two attributes that can modify behavior of resource plan switching:

  • SWITCH_ESTIMATE – If TRUE – database estimate execution time of each call. if it exceeds SWITCH_TIME attribute, the session is moved to    Default is FALSE.
  • SWITCH_FOR_CALL – If TRUE – session switched because of exceeding resource is returned to original group once completed. Default is NULL.

 

Larry Catt

OCP