AWS Database Blog
Create a centralized repository for Oracle AWR reports using Amazon EFS integration for Amazon RDS for Oracle
You can use the managed database offerings in the Amazon Relational Database Service (Amazon RDS) portfolio to remove much of the undifferentiated heavy lifting from day-to-day activities. With Amazon RDS for Oracle, you can significantly reduce the administrative overhead of managing and maintaining an Oracle database.
Oracle Automatic Workload Repository (AWR) provides a comprehensive view of the performance and resource usage of an Oracle database. Oracle AWR collects and maintains performance statistics and information about database resource usage over time, which can be used to diagnose and troubleshoot performance issues. You can control the AWR snapshots using the retention period. The retention period is the length of time that AWR data is kept in the SYSAUX tablespace. After this period, the data is deleted automatically. If the retention period is too high, more AWR statistics will be retained and the SYSAUX tablespace may grow faster than expected. Truncating objects in the SYSAUX tablespace could potentially cause severe database problems, such as data corruption, loss of important metadata, and instability of the entire database. Therefore, Amazon RDS for Oracle is a managed service that doesn’t allow users to truncate objects in the SYSAUX tablespace to prevent such problems from occurring.
To resolve these issues, having a centralized repository for AWR reports can be helpful to maintain historical performance data. This post demonstrates how to create a centralized repository for AWR reports when you would like to use a high retention period. For this solution, we use Amazon Elastic Compute Cloud (Amazon EC2), Amazon Elastic File System (Amazon EFS), and its integration with RDS for Oracle instances.
Solution overview
The Oracle AWR Warehouse is a central repository configured for long-term AWR data retention. It stores AWR snapshots from multiple database sources. Increasing AWR retention in the production systems would typically increase the overhead and cost of mission-critical databases. Therefore, offloading the AWR snapshots to a central repository is a better idea. Unlike the AWR default retention period of 8 days, the AWR Warehouse default retention period is forever. However, you can configure it for weeks, months, or years.
The following diagram illustrates our solution architecture.
A centralized repository for AWR reports offers the following benefits:
- You can store performance data over time, providing a historical perspective on database performance. You can use this data to identify performance trends and issues, and perform root cause analysis on performance problems.
- By analyzing the data stored in the AWR repository, you can identify resource-intensive SQL statements and database objects, as well as monitor resource utilization over time. This can help you plan for future resource needs and make informed decisions about database capacity.
- You can perform trend analysis on database performance over time. By comparing performance data from different time periods, you can identify performance trends and take proactive steps to address potential performance problems before they become critical.
- An AWR centralized repository provides a centralized location for storing performance data, which you can use to generate reports on database performance. You can use these reports to communicate performance information to management, stakeholders, and other teams.
- Managing and administrating of the SYSAUX tablespace is straightforward.
To monitor the growth in the SYSAUX tablespace, you can query the V$SYSAUX_OCCUPANTS
view to see which components are using the most space:
Prerequisites
Before getting started, make sure you have the following prerequisites for this solution:
- You need an AWS account with AWS Identity and Access Management (IAM) permissions to create and manage keys, Amazon RDS, Amazon EC2, and VPC-related resources.
- You need an Oracle database on an EC2 instance.
- AWR reports are included with Oracle Database Enterprise Edition. This functionality requires Enterprise Edition and the Diagnostics and Tuning option. You should ensure you have the correct licensing before using this functionality.
- Because Amazon RDS is a managed service, Amazon RDS for Oracle doesn’t support
DBMS_SWRF_INTERNAL.AWR_LOAD
as of this writing. Therefore, for this demo, we create a centralized repository on Oracle hosted on Amazon EC2. - The database user should have privileges for exporting and importing the AWR reports.
In the following sections, we provide a step-by-step guide for setting up a centralized repository for AWR reports.
Create an EFS file system in your AWS account
To create an EFS file system, open the Amazon EFS console and choose Create file system. Choose the appropriate settings such as the performance mode and throughput capacity. This is the location where the AWR reports will be stored.
Mount the EFS file system on Amazon EC2
Install the necessary Oracle software on your EC2 instances, including creating the database and the EFS mount helper. The EFS mount helper is a tool provided by AWS that makes it easy to mount an EFS file system on an EC2 instance. See the following code:
Create an Oracle directory on Amazon RDS for Oracle
To transfer files between an RDS for Oracle instance and an EFS file system, you must create an Oracle directory on Amazon RDS for Oracle:
For more information, refer to Integrate Amazon RDS for Oracle with Amazon EFS.
Extract AWR data
To extract AWR data into a dump file manually, use the rdsadmin.rdsadmin_diagnostic_util.awr_extract
procedure. The following example code extracts the snapshot range 84344–84345 manually:
The output dump file is generated with file nameawrextract_84344_84345.dmp
in the non-default database directory named DATA_PUMP_DIR_RDS
. Verify the extract fileawrextract_84344_84345.dmp
was created on the shared EFS file system.
Alternatively, to extract the most recent snapshot dynamically, create a scheduler using the DBMS_SCHEDULER
package:
Create an Oracle directory on Oracle hosted on Amazon EC2
Create an Oracle directory called DATA_PUMP_DIR_EC2
pointing to the EFS file system mounted on the EC2 instance:
Import the AWR report into a centralized repository
Import the AWR report into a centralized database using the awrload.sql
procedure:
You can also do it manually using the following procedure:
Now you should see database ID 659205682 of the database snapshot that was imported. You can query to retrieve the snapshot IDs and their corresponding start and end times for all database IDs that currently exist in the database:
Generate an AWR report from the centralized repository hosted on Amazon EC2
We use the awrrpti.sql
script to generate a specific instance-level AWR report for a specified time range. Run the script on the centralized Oracle instance using SQL*Plus, providing the necessary parameters such as the database ID, begin and end snapshots, and output format:
We have successfully generated the AWR reportawrrpt_1_84344_84345.html
from the centralized database.
Clean up
Delete the resources created along this post should you no longer need them.
Conclusion
In this post, we showed how to create a centralized repository for Oracle AWR reports. By implementing centralized AWR reports, administrators can improve performance, reduce the time and effort required to access performance data, and ensure that performance issues are addressed before they become critical.
If you have any questions or suggestions about this post, leave a comment.
About the authors
Sudhakar Darse is a Database Specialist Solutions Architect at AWS. He works with AWS customers to provide guidance and technical assistance on database services, helping them with database migrations to the AWS Cloud and improving the value of their solutions when using AWS.
Sarabjeet Singh is a Database Specialist Solutions Architect at Amazon Web Services. He works with our customers to provide guidance and technical assistance on database projects, helping them improve the value of their solutions when using AWS.
Robert Daly is a Senior Database Specialist Solutions architect at AWS, focusing on Amazon RDS, Amazon Aurora, and AWS DMS. He has helped multiple enterprise customers move their databases to AWS, providing assistance on performance and best practices. Robert enjoys helping customers build technical solutions to solve business problems.