0% found this document useful (0 votes)
170 views

Daily Tasks in Oracle RDS

This document provides information on administering an Oracle database using the RDSADMIN stored procedures when using Amazon Relational Database Service (RDS) for Oracle. It describes how to perform common database administration tasks like disconnecting sessions, flushing buffers, enabling auditing, and managing online redo logs using the RDSADMIN procedures instead of standard Oracle commands. Administering an Oracle database on RDS requires using these specialized procedures to restrict direct access and control database operations.

Uploaded by

ganesh_24
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
170 views

Daily Tasks in Oracle RDS

This document provides information on administering an Oracle database using the RDSADMIN stored procedures when using Amazon Relational Database Service (RDS) for Oracle. It describes how to perform common database administration tasks like disconnecting sessions, flushing buffers, enabling auditing, and managing online redo logs using the RDSADMIN procedures instead of standard Oracle commands. Administering an Oracle database on RDS requires using these specialized procedures to restrict direct access and control database operations.

Uploaded by

ganesh_24
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 17

Amazon Oracle RDS deep dive

To deliver a managed service experience, Amazon RDS doesn't provide shell access to DB
instances, and restricts access to certain system procedures and tables that require
advanced privileges.
RDSADMIN is the user which has many stored procedures inbuilt which you need to run to
take care of most of the daily operations
Below are the possible ways to administer your Day to Day activities as a DBA working with
AWS RDS

Disconnecting a Session
begin
rdsadmin.rdsadmin_util.disconnect(
sid => sid,
serial => serial_number);
end;
/

Killing a Session
begin
rdsadmin.rdsadmin_util.kill(
sid => sid,
serial => serial_number);
end;
/

Canceling a SQL Statement in a Session


begin
rdsadmin.rdsadmin_util.cancel(
sid => sid,
serial => serial_number,
sql_id => sql_id);
end;
/

InfraXpertzz
For any exam certification related queries please reach out to [email protected]
Enabling and Disabling Restricted Sessions
/* Verify that the database is currently unrestricted. */

select LOGINS from V$INSTANCE;

LOGINS
-------
ALLOWED

/* Enable restricted sessions */

exec rdsadmin.rdsadmin_util.restricted_session(p_enable => true);

/* Verify that the database is now restricted. */

select LOGINS from V$INSTANCE;

LOGINS
----------
RESTRICTED

/* Disable restricted sessions */

exec rdsadmin.rdsadmin_util.restricted_session(p_enable => false);

/* Verify that the database is now unrestricted again. */

select LOGINS from V$INSTANCE;

LOGINS
-------
ALLOWED

Flushing the Shared Pool


exec rdsadmin.rdsadmin_util.flush_shared_pool;

Flushing the Buffer Cache


exec rdsadmin.rdsadmin_util.flush_buffer_cache;

InfraXpertzz
For any exam certification related queries please reach out to [email protected]
Granting SELECT or EXECUTE Privileges to SYS
Objects
The following example grants select privileges on an object named V_$SESSION to a user
named USER1.
begin
rdsadmin.rdsadmin_util.grant_sys_object(
p_obj_name => 'V_$SESSION',
p_grantee => 'USER1',
p_privilege => 'SELECT');
end;
/

The following example grants select privileges on an object named V_$SESSION to a user
named USER1 with the grant option.

begin
rdsadmin.rdsadmin_util.grant_sys_object(
p_obj_name => 'V_$SESSION',
p_grantee => 'USER1',
p_privilege => 'SELECT',
p_grant_option => true);
end;
/

The following example grants


the SELECT_CATALOG_ROLE and EXECUTE_CATALOG_ROLE to USER1. Since the with
admin option is used, USER1 can now grant access to SYS objects that have been
granted to SELECT_CATALOG_ROLE.

grant SELECT_CATALOG_ROLE to USER1 with admin option;


grant EXECUTE_CATALOG_ROLE to USER1 with admin option;

Revoking SELECT or EXECUTE Privileges on SYS


Objects

begin
rdsadmin.rdsadmin_util.revoke_sys_object(
p_obj_name => 'V_$SESSION',
p_revokee => 'USER1',
p_privilege => 'SELECT');
end;
/

InfraXpertzz
For any exam certification related queries please reach out to [email protected]
Granting Privileges to Non-Master Users

grant SELECT_CATALOG_ROLE to user1;


grant EXECUTE_CATALOG_ROLE to user1;

Creating of non master users is the same process as we follow in non RDS
oracle database

The create_verify_function Procedure


The create_verify_function procedure is supported for Oracle version 11.2.0.4.v9
and later, Oracle version 12.1.0.2.v5 and later, all 12.2.0.1 versions, all 18.0.0.0
versions, and all 19.0.0 versions.

You can create a custom function to verify passwords by using the Amazon RDS
procedure rdsadmin.rdsadmin_password_verify.create_verify_function .

begin
rdsadmin.rdsadmin_password_verify.create_verify_function(
p_verify_function_name => 'CUSTOM_PASSWORD_FUNCTION',
p_min_length => 12,
p_min_uppercase => 2,
p_min_digits => 1,
p_min_special => 1,
p_disallow_at_sign => true);
end;
/

Changing the Global Name of a Database


select global_name from global_name;

In NON RDS :

ALTER DATABASE RENAME GLOBAL_NAME TO database.domain;

In RDS :

exec rdsadmin.rdsadmin_util.rename_global_name(p_new_global_name =>


'new_global_name');

InfraXpertzz
For any exam certification related queries please reach out to [email protected]
Creating and Sizing Tablespaces

Amazon RDS only supports Oracle Managed Files (OMF) for data files, log files, and control
files. When you create data files and log files, you can't specify the physical file names.
By default, tablespaces are created with auto-extend enabled, and no maximum size.
Because of these default settings, tablespaces can grow to consume all allocated storage.
By default, the tablespace created is a bigfile tablespace.
To create a smallfile tablespace, you need to mention the “smallfile” keyword after create in
your syntax.
create smallfile tablespace users2 datafile size 1G autoextend on maxsize
10G;

create temporary tablespace temp01;

Don't use smallfile tablespaces because you can't resize smallfile tablespaces with Amazon
RDS for Oracle. However, you can add a datafile to a smallfile tablespace.
alter tablespace users2 add datafile size 100000M autoextend on next 250m
maxsize UNLIMITED;

Setting the Default Tablespace


In Non RDS :
alter user username default tablespace tablespace_name;

In RDS :

exec rdsadmin.rdsadmin_util.alter_default_tablespace(tablespace_name =>


'users2');

Checkpointing a Database
In Non RDS :
ALTER SYSTEM CHECKPOINT
In RDS :

exec rdsadmin.rdsadmin_util.checkpoint;

Setting the Database Time Zone


InfraXpertzz
For any exam certification related queries please reach out to [email protected]
Change in option groups and attach it with RDS to make changes effective
The following example changes the time zone to UTC plus 3 hours.
exec rdsadmin.rdsadmin_util.alter_db_time_zone(p_new_tz => '+3:00');

The following example changes the time zone to the time zone of the Africa/Algiers region.
exec rdsadmin.rdsadmin_util.alter_db_time_zone(p_new_tz =>
'Africa/Algiers');

Generating an AWR Report


select * from dba_hist_snapshot;

The following example generates a AWR report for the snapshot range 101–106. The output
text file is named awrrpt_101_106.txt. You can access this report from the AWS
Management Console.
exec rdsadmin.rdsadmin_diagnostic_util.awr_report(101,106,'HTML');

The following example generates an HTML report for the snapshot range 63–65. The output
HTML file is named awrrpt_63_65.html. The procedure writes the report to the
nondefault database directory named AWR_RPT_DUMP.

exec
rdsadmin.rdsadmin_diagnostic_util.awr_report(63,65,'HTML','AWR_RPT_DUMP');

The following example extracts the snapshot range 101–106. The output dump file is
named awrextract_101_106.dmp.

exec rdsadmin.rdsadmin_diagnotic_util.awr_extract(101,106);

Generating an ADDM Report


exec rdsadmin.rdsadmin_diagnostic_util.addm_report(101,106);

The following example generates an ADDM report for the snapshot range 63–65. The output
text file is named addmrpt_63_65.txt. The file is stored in the nondefault database
directory named ADDM_RPT_DUMP.

exec rdsadmin.rdsadmin_diagnostic_util.addm_report(63,65,'ADDM_RPT_DUMP');

Enabling Auditing for the SYS.AUD$ Table


Enabling auditing is supported for Oracle DB instances running the following
versions:

InfraXpertzz
For any exam certification related queries please reach out to [email protected]
• 11.2.0.4.v18 and later 11.2 versions
• 12.1.0.2.v14 and later 12.1 versions
• All 12.2.0.1 versions
• All 18.0.0.0 versions
• All 19.0.0.0 versions

Show parameter audit_trail

• The following commands enable audit of ALL on SYS.AUD$ BY ACCESS.



• exec rdsadmin.rdsadmin_master_util.audit_all_sys_aud_table;

• exec
rdsadmin.rdsadmin_master_util.audit_all_sys_aud_table(p_by_access =>
true);

Disabling Auditing for the SYS.AUD$ Table


exec rdsadmin.rdsadmin_master_util.noaudit_all_sys_aud_table;

Purging the Recycle Bin


exec rdsadmin.rdsadmin_util.purge_dba_recyclebin;

Setting Force Logging


In force logging mode, Oracle logs all changes to the database except changes in
temporary tablespaces and temporary segments (NOLOGGING clauses are ignored).

exec rdsadmin.rdsadmin_util.force_logging(p_enable => true);

Setting Supplemental Logging


Supplemental logging ensures that LogMiner and products that use LogMiner
technology have sufficient information to support chained rows and storage
arrangements such as cluster tables.

Oracle Database doesn't enable supplemental logging by default. To enable and disable
supplemental logging, use the Amazon RDS
procedure rdsadmin.rdsadmin_util.alter_supplemental_logging.

InfraXpertzz
For any exam certification related queries please reach out to [email protected]
The following example enables supplemental logging.
begin
rdsadmin.rdsadmin_util.alter_supplemental_logging(
p_action => 'ADD');
end;
/

Switching Online Log Files

exec rdsadmin.rdsadmin_util.switch_logfile;

Adding Online Redo Logs

An Amazon RDS DB instance running Oracle starts with four online redo logs, 128 MB each.
To add additional redo logs, use the Amazon RDS
procedure rdsadmin.rdsadmin_util.add_logfile.

exec rdsadmin.rdsadmin_util.add_logfile(p_size => '100M');


exec rdsadmin.rdsadmin_util.drop_logfile(grp => 3);

Resizing Online Redo Logs

/* Query V$LOG to see the logs. */


/* You start with 4 logs of 128 MB each. */

select GROUP#, BYTES, STATUS from V$LOG;

GROUP# BYTES STATUS


---------- ---------- ----------------
1 134217728 INACTIVE
2 134217728 CURRENT
3 134217728 INACTIVE
4 134217728 INACTIVE

/* Add four new logs that are each 512 MB */


InfraXpertzz
For any exam certification related queries please reach out to [email protected]
exec rdsadmin.rdsadmin_util.add_logfile(bytes => 536870912);
exec rdsadmin.rdsadmin_util.add_logfile(bytes => 536870912);
exec rdsadmin.rdsadmin_util.add_logfile(bytes => 536870912);
exec rdsadmin.rdsadmin_util.add_logfile(bytes => 536870912);

/* Query V$LOG to see the logs. */


/* Now there are 8 logs. */

select GROUP#, BYTES, STATUS from V$LOG;

GROUP# BYTES STATUS


---------- ---------- ----------------
1 134217728 INACTIVE
2 134217728 CURRENT
3 134217728 INACTIVE
4 134217728 INACTIVE
5 536870912 UNUSED
6 536870912 UNUSED
7 536870912 UNUSED
8 536870912 UNUSED

/* Drop each inactive log using the group number. */

exec rdsadmin.rdsadmin_util.drop_logfile(grp => 1);


exec rdsadmin.rdsadmin_util.drop_logfile(grp => 3);
exec rdsadmin.rdsadmin_util.drop_logfile(grp => 4);

/* Query V$LOG to see the logs. */


/* Now there are 5 logs. */

select GROUP#, BYTES, STATUS from V$LOG;

GROUP# BYTES STATUS


---------- ---------- ----------------
2 134217728 CURRENT
5 536870912 UNUSED
6 536870912 UNUSED
7 536870912 UNUSED
8 536870912 UNUSED

/* Switch logs so that group 2 is no longer current. */

exec rdsadmin.rdsadmin_util.switch_logfile;

/* Query V$LOG to see the logs. */


/* Now one of the new logs is current. */

InfraXpertzz
For any exam certification related queries please reach out to [email protected]
SQL>select GROUP#, BYTES, STATUS from V$LOG;

GROUP# BYTES STATUS


---------- ---------- ----------------
2 134217728 ACTIVE
5 536870912 CURRENT
6 536870912 UNUSED
7 536870912 UNUSED
8 536870912 UNUSED

/* If the status of log 2 is still "ACTIVE", issue a checkpoint to clear


it to "INACTIVE". */

exec rdsadmin.rdsadmin_util.checkpoint;

/* Query V$LOG to see the logs. */


/* Now the final original log is inactive. */

select GROUP#, BYTES, STATUS from V$LOG;

GROUP# BYTES STATUS


---------- ---------- ----------------
2 134217728 INACTIVE
5 536870912 CURRENT
6 536870912 UNUSED
7 536870912 UNUSED
8 536870912 UNUSED

# Drop the final inactive log.

exec rdsadmin.rdsadmin_util.drop_logfile(grp => 2);

/* Query V$LOG to see the logs. */


/* Now there are four 512 MB logs. */

select GROUP#, BYTES, STATUS from V$LOG;

GROUP# BYTES STATUS


---------- ---------- ----------------
5 536870912 CURRENT
6 536870912 UNUSED
7 536870912 UNUSED
8 536870912 UNUSED

Retaining Archived Redo Logs


InfraXpertzz
For any exam certification related queries please reach out to [email protected]
You can retain archived redo logs locally on your DB instance for use with products
like Oracle LogMiner (DBMS_LOGMNR). After you have retained the redo logs, you
can use LogMiner to analyze the logs.

begin
rdsadmin.rdsadmin_util.set_configuration(
name => 'archivelog retention hours',
value => '24');
end;
/
commit;

The following example shows the log retention time.


set serveroutput on
exec rdsadmin.rdsadmin_util.show_configuration;

RMAN TASKS

The following example validates the DB instance using the default values for the parameters.
exec rdsadmin.rdsadmin_rman_util.validate_database;

The following example validates the DB instance using the specified values for the
parameters.
BEGIN
rdsadmin.rdsadmin_rman_util.validate_database(
p_validation_type => 'PHYSICAL+LOGICAL',
p_parallel => 4,
p_section_size_mb => 10,
p_rman_to_dbms_output => FALSE);
END;
/

To view the files in the BDUMP directory, run the following SELECT statement.

SELECT * FROM table(rdsadmin.rds_file_util.listdir('BDUMP')) order by


mtime;

InfraXpertzz
For any exam certification related queries please reach out to [email protected]
To view the contents of a file in the BDUMP directory, run the following SELECT statement.

SELECT text FROM table(rdsadmin.rds_file_util.read_text_file('BDUMP','rds-


rman-validate-nnn.txt'));

Validating a Tablespace
To validate the files associated with a tablespace, use the Amazon RDS
procedure rdsadmin.rdsadmin_rman_util.validate_tablespace.

This procedure uses the following common parameters for RMAN tasks:

• p_validation_type
• p_parallel
• p_section_size_mb
• p_rman_to_dbms_output

Validating a Control File


To validate only the control file used by an Amazon RDS Oracle DB instance, use
the Amazon RDS
procedure rdsadmin.rdsadmin_rman_util.validate_current_controlfile.

This procedure uses the following common parameter for RMAN tasks:

• p_validation_type
• p_rman_to_dbms_output

Validating an SPFILE
To validate only the server parameter file (SPFILE) used by an Amazon RDS Oracle
DB instance, use the Amazon RDS
procedure rdsadmin.rdsadmin_rman_util.validate_spfile.

This procedure uses the following common parameter for RMAN tasks:

• p_validation_type
• p_rman_to_dbms_output

InfraXpertzz
For any exam certification related queries please reach out to [email protected]
Validating a Data File
To validate a data file, use the Amazon RDS
procedure rdsadmin.rdsadmin_rman_util.validate_datafile.

This procedure uses the following common parameters for RMAN tasks:

• p_validation_type
• p_parallel
• p_section_size_mb
• p_rman_to_dbms_output

Enabling and Disabling Block Change Tracking

To determine whether block change tracking is enabled for your DB instance, run the
following query.
SELECT status, filename FROM V$BLOCK_CHANGE_TRACKING;

Enable :
exec rdsadmin.rdsadmin_rman_util.enable_block_change_tracking;

Disable :
exec rdsadmin.rdsadmin_rman_util.disable_block_change_tracking;

Crosschecking Archived Redo Logs

The following example deletes the expired archived redo logs from the control file.
BEGIN
rdsadmin.rdsadmin_rman_util.crosscheck_archivelog(
p_delete_expired => FALSE,
p_rman_to_dbms_output => FALSE);
END;
/

InfraXpertzz
For any exam certification related queries please reach out to [email protected]
The following example retains 24 hours of redo logs.

begin
rdsadmin.rdsadmin_util.set_configuration(
name => 'archivelog retention hours',
value => '24');
end;
/
commit;

Backing Up Archived Redo Logs

BEGIN
rdsadmin.rdsadmin_rman_util.backup_archivelog_all(
p_owner => 'SYS',
p_directory_name => 'MYDIRECTORY',
p_parallel => 4,
p_rman_to_dbms_output => FALSE);
END;
/

Backing Up an Archived Redo Log from a Date Range

BEGIN
rdsadmin.rdsadmin_rman_util.backup_archivelog_date(
p_owner => 'SYS',
p_directory_name => 'MYDIRECTORY',
p_from_date => '03/01/2019 00:00:00',
p_to_date => '03/02/2019 00:00:00',
p_parallel => 4,
p_rman_to_dbms_output => FALSE);
END;
/

Backing Up an Archived Redo Log from an SCN Range

BEGIN
rdsadmin.rdsadmin_rman_util.backup_archivelog_scn(
InfraXpertzz
For any exam certification related queries please reach out to [email protected]
p_owner => 'SYS',
p_directory_name => 'MYDIRECTORY',
p_from_scn => 1533835,
p_to_scn => 1892447,
p_parallel => 4,
p_rman_to_dbms_output => FALSE);
END;
/

Backing Up an Archived Redo Log from a Sequence Number


Range
BEGIN
rdsadmin.rdsadmin_rman_util.backup_archivelog_sequence(
p_owner => 'SYS',
p_directory_name => 'MYDIRECTORY',
p_from_sequence => 11160,
p_to_sequence => 11160,
p_parallel => 4,
p_rman_to_dbms_output => FALSE);
END;
/

Performing a Full Database Backup


This procedure is supported for the following Amazon RDS for Oracle DB engine
versions:

• 11.2.0.4.v19 or higher 11.2 versions


• 12.1.0.2.v15 or higher 12.1 versions
• 12.2.0.1.ru-2019-01.rur-2019-01.r1 or higher 12.2 versions
• All 18.0.0.0 versions
• All 19.0.0.0 versions

BEGIN
rdsadmin.rdsadmin_rman_util.backup_database_full(
p_owner => 'SYS',
p_directory_name => 'MYDIRECTORY',
p_parallel => 4,
p_section_size_mb => 10,
p_rman_to_dbms_output => FALSE);
END;
/

InfraXpertzz
For any exam certification related queries please reach out to [email protected]
Performing an Incremental Database Backup

EGIN
rdsadmin.rdsadmin_rman_util.backup_database_incremental(
p_owner => 'SYS',
p_directory_name => 'MYDIRECTORY',
p_level => 1,
p_parallel => 4,
p_section_size_mb => 10,
p_rman_to_dbms_output => FALSE);
END;
/

Performing a Tablespace Backup

BEGIN
rdsadmin.rdsadmin_rman_util.backup_tablespace(
p_owner => 'SYS',
p_directory_name => 'MYDIRECTORY',
p_tablespace_name => MYTABLESPACE,
p_parallel => 4,
p_section_size_mb => 10,
p_rman_to_dbms_output => FALSE);
END;
/

Creating New Directories in the Main Data Storage


Space

exec rdsadmin.rdsadmin_util.create_directory(p_directory_name =>


'product_descriptions');

Listing Files in a DB Instance Directory

select * from table

InfraXpertzz
For any exam certification related queries please reach out to [email protected]
(rdsadmin.rds_file_util.listdir(p_directory =>
'product_descriptions'));

Reading Files in a DB Instance Directory

select * from table


(rdsadmin.rds_file_util.read_text_file(
p_directory => 'product_descriptions',
p_filename => 'rice.txt'));

InfraXpertzz
For any exam certification related queries please reach out to [email protected]

You might also like