AWS Database Blog
Integrate HAQM RDS for Oracle with HAQM EFS
As customers migrate their Oracle databases to the HAQM Relational Database Service for Oracle, they may often benefit from a shared file system to be available on their Oracle database systems. This is either to share files between the database and application servers or to act as a staging location to keep backups, data loads, and more. HAQM RDS for Oracle now supports integration with HAQM Elastic File System (HAQM EFS), which provides a simple, serverless, set-and-forget elastic file system that lets you share file data without provisioning or managing storage. It’s built to scale on demand to petabytes without disrupting applications.
HAQM RDS for Oracle with HAQM EFS is well-suited to support a broad spectrum of use cases, such as the following:
- Share a file system between applications and multiple database servers
- Use it as an upload location for the native dumps and backups required for migration
- Store and share RMAN backup and recovery logs without the allocation of additional storage space on the server
- Use Oracle utilities such as
UTL_FILE
to read and write files
Benefits of integrating an HAQM RDS for Oracle instance with HAQM EFS
Once HAQM RDS for Oracle has been integrated with HAQM EFS, you can transfer files between your HAQM RDS for Oracle DB instance and an HAQM EFS file system. This integration provides the following benefits:
- You can export/import Oracle Data Pump files to and from HAQM EFS to your HAQM RDS for Oracle DB instance. You don’t need to copy the dump files onto HAQM RDS for Oracle storage. These operations are performed directly from the HAQM EFS file system.
- Faster migration of data as compared to migration over database link. You can use HAQM EFS file system mounted on HAQM RDS for Oracle DB instances as a landing zone for various Oracle files required for migration or data transfer.
- Using it as a landing zone helps to save the allocation of extra storage space on the HAQM RDS instance to hold the files.
- The HAQM EFS file systems can automatically scale from gigabytes to petabytes of data without needing to provision storage.
- There are no minimum fees or setup costs, and you pay only for what you use.
In this post, we walk through a step-by-step configuration to set up HAQM EFS on an HAQM RDS for Oracle database instance. We also talk about the benefits of this integration, and the best practices to consider while doing so. Before starting, review the requirements and restrictions of HAQM EFS integration with Oracle Database.
Create an HAQM EFS file system
Your first step is to create an HAQM EFS file system:
- On the HAQM EFS console, choose Create file system.
- For Name, enter a name for your file system.
- For HAQM Virtual Private Cloud (HAQM VPC), choose the VPC in which you have an HAQM RDS for Oracle instance deployed.
- For Storage class, select Standard.
- Choose Create. (by default, it will inherit the default security group, so make sure to select appropriate security group under customize while creating)
Configure HAQM EFS file system permissions
After you create a new HAQM EFS file system, by default only the root user (UID 0) has read, write, and run permissions. For other users to modify the file system, the root user must explicitly grant them access. You must mount the HAQM EFS file system locally on your HAQM Elastic Compute Cloud (HAQM EC2) instance and set up fine-grained permissions to allow HAQM RDS instances to read and write files from and to the HAQM EFS file system. For example, you can run chmod 777
against the HAQM EFS file system root to grant other users the permission to write to this directory. Complete the following steps:
- Select the security group of the HAQM EC2 instance where HAQM EFS file system will be mounted.
- Edit the inbound rules and add port 2049 (default port for NFS) and click Save rules
- Now attach this security group to the HAQM EFS mount point in each AZ. On the Network tab for the HAQM EFS, select your mount point and choose Manage.
- Connect to the HAQM EC2 instance and mount your file system on the HAQM EC2 instance:
Please ensure NFS Client is installed on your HAQM EC2 instance (please refer to Step 3.2).
Add an entry to /etc/fstab
to make it persistent across reboots.
- Create a directory on the mounted EFS file system
- Change permissions so that HAQM RDS for Oracle can write to this directory:
Create an option group
Now you create an HAQM RDS option group:
- On the HAQM RDS console, choose Option groups in the navigation pane.
- Choose Create group.
- For Name, enter a name for your group (for example,
efs-integration-option-grp
). - For Description, enter a brief description (for example, EFS integration with RDS Oracle).
- For Engine, choose oracle-ee.
- For Major Engine Version, choose 19.
- Choose Create.
- On the Option groups page, select the option group that you created and choose Add option.
- For Option name, choose EFS_INTEGRATION.
- Under Option settings, for EFS_ID, enter the ID of the file system that you created earlier.
- Choose Add option.
Add the option group to your HAQM RDS for Oracle instance
To add the option group to your HAQM RDS for Oracle instance, complete the following steps:
- On the HAQM RDS console, choose Databases in the navigation pane.
- Select your instance and choose Modify.
- For Option group, choose the option group that you created
- Choose Continue and check the summary of modifications
- Choose Modify DB instance and select Apply immediately.
Configure network and security group permissions for HAQM RDS for Oracle integration with HAQM EFS
For HAQM RDS for Oracle to integrate with HAQM EFS, your DB instance must have network access to an HAQM EFS file system. Your VPC should have the enableDnsSupport
attribute enabled. To allow access to the HAQM EFS file system for your DB instance, make sure the HAQM EFS file system has a mount target in each Availability Zone (AZ) and that the security group attached to the mount targets has an inbound rule allowing the HAQM RDS instance to make a TCP connection to the NFS port 2049 and receive return traffic.
- On the HAQM RDS console, select your HAQM RDS for Oracle instance. Under Connectivity & Security click on the security group.
- Select the security group for your HAQM RDS for Oracle instance and on the Actions menu, choose Edit inbound rules.
- Add a rule allowing access on port 2049. ( default NFS port).
- Choose Save.
- Now attach this security group to the HAQM EFS mount point in each AZ. On the Network tab for the HAQM EFS, select your mount point and choose Manage.
- Add the security group for HAQM RDS for Oracle to the mount point in each AZ.
- Choose Save.
Transfer files between HAQM RDS for Oracle and an HAQM EFS file system
To transfer files between an HAQM RDS for Oracle instance and an HAQM EFS file system, you must create an Oracle directory on HAQM RDS for Oracle. See the following code.
Example commands are run by admin user, other users may need proper privileges to run these commands. Note that file system path must begin with /rdsefs-
1. Use DATAPUMP to export a table
The following PL/SQL code example shows how to export the table EMP
in the HR_USER
schema, and the dump file is created in the Oracle directory DATA_PUMP_DIR_EFS
, which is on HAQM EFS:
declare
This creates the file hr_user.dmp
in the Oracle directory ‘DATA_PUMP_DIR_EFS
‘ and you can check from HAQM EC2 where HAQM EFS is mounted.
2. Use UTL_FILE to write and read from files
To write and read from files, use the following code:
You can check from the HAQM EC2 instance that the file was created.
3. Use Oracle RMAN to back up your HAQM RDS for Oracle database to the shared EFS file system
The following section lists steps to perform the backup of your HAQM RDS for Oracle database using Oracle Recovery Manager (RMAN) and store the backup pieces in the HAQM EFS file system
- Create a directory on the OS and change permissions from the HAQM EC2 server where you have mounted the HAQM EFS
- Create Oracle Directory.
This will create the database directory name RMAN_DIR_EFS
to store the RMAN Backups. The file system path value for the p_path_on_efs
parameter is prefixed with the string “/rdsefs- <EFS FILE SYSTEM ID>”.
- Make sure the archive logs are retained on the RDS database server as long as the Oracle RMAN tool requires them. In our example we have used 2 hours as retention of archive logs.
- Run the RMAN Backup for the HAQM RDS for Oracle instance. Note that the backup location is specified as the Oracle Directory pointing to HAQM EFS File system. Refer to this document for common RMAN tasks related to the backup.
- Check the RMAN backup logs.
RMAN log files are stored in the bdump
directory. Use the following query to get the logfile name:
Run the following query to open the log file and check for any errors. Replace the file name obtained from the previous query and add it in the next query.
- Log in to the EC2 instance where the same HAQM EFS file system is mounted. The RMAN Backup pieces are stored in the HAQM EFS file system.
Conclusion
In this post, we showed how to integrate and configure HAQM EFS with HAQM RDS for Oracle. You can use this feature to share data between databases and application servers and among database servers. We demonstrated use cases where you can also use it when performing RMAN backups and native Data Pump from HAQM RDS for Oracle without consuming database storage on the RDS instance.
For more information about this feature, refer to HAQM EFS integration.
About the Authors
Devinder Singh is an SA Manager with AWS. He has over 25 years of experience working with various database and storage technologies. Devinder focuses on helping customers on their journey to AWS and helping them architect highly available and scalable database solutions based on various relational and NoSQL AWS Database services. When not working with customers, you can always find Devinder enjoying long hikes or biking.
Manash Kalita is an AWS Senior Database Specialist Solutions Architect for APJ, having extensive experience in Enterprise Cloud Architecture.
Arnab Saha is a Senior Database Specialist Solutions Architect at AWS. Arnab specializes in HAQM RDS, HAQM Aurora and HAQM Elastic Block Store. He provides guidance and technical assistance to customers thus enabling them to build scalable, highly available and secure solutions in AWS Cloud.