Daily Tasks in Oracle RDS
Daily Tasks in Oracle RDS
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;
/
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. */
LOGINS
-------
ALLOWED
LOGINS
----------
RESTRICTED
LOGINS
-------
ALLOWED
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;
/
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
Creating of non master users is the same process as we follow in non RDS
oracle database
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;
/
In NON RDS :
In RDS :
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;
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;
In RDS :
Checkpointing a Database
In Non RDS :
ALTER SYSTEM CHECKPOINT
In RDS :
exec rdsadmin.rdsadmin_util.checkpoint;
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');
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);
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');
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
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;
/
exec rdsadmin.rdsadmin_util.switch_logfile;
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.switch_logfile;
InfraXpertzz
For any exam certification related queries please reach out to [email protected]
SQL>select GROUP#, BYTES, STATUS from V$LOG;
exec rdsadmin.rdsadmin_util.checkpoint;
begin
rdsadmin.rdsadmin_util.set_configuration(
name => 'archivelog retention hours',
value => '24');
end;
/
commit;
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.
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.
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
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
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;
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;
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;
/
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;
/
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;
/
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;
/
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;
/
InfraXpertzz
For any exam certification related queries please reach out to [email protected]
(rdsadmin.rds_file_util.listdir(p_directory =>
'product_descriptions'));
InfraXpertzz
For any exam certification related queries please reach out to [email protected]