Using Amazon Backup and Oracle RMAN for backup/restore of Oracle databases on Amazon EC2: Part 2

海外精选
海外精选的内容汇集了全球优质的亚马逊云科技相关技术内容。同时,内容中提到的“AWS” 是 “Amazon Web Services” 的缩写,在此网站不作为商标展示。
0
0
{"value":"Customers running Oracle databases on [Amazon Elastic Compute Cloud (Amazon EC2)](https://aws.amazon.com/ec2/) often take database and schema backups using Oracle native tools like Data Pump and Recovery Manager (RMAN) to satisfy data protection, disaster recovery (DR), and compliance requirements. A priority is to reduce backup time as the data grows exponentially and recover sooner in case of failure/disaster.\n\nIn [Part 1 ](https://aws.amazon.com/blogs/architecture/using-aws-backup-and-oracle-rman-for-backup-restore-of-oracle-databases-on-amazon-ec2-part-1/)of this two-part series, we explain how we can use[ AWS Backup](https://aws.amazon.com/backup/) and Amazon Simple Storage Service (Amazon S3) bucket to perform the backup and restore of an Oracle Database on AWS EC2.\n\nIn Part 2, we provide a mechanism to use AWS Backup to create a full backup of the EC2 instance, including the OS image, Oracle binaries, logs, and data files. The mechanism also uses Oracle RMAN to perform archived redo log backup to Amazon Elastic File System (Amazon EFS). Then, we demonstrate the steps to restore a database to a specific point-in-time using AWS Backup and Oracle RMAN.\n\n\n### **Solution overview**\n\n\nFigure 1 demonstrates the workflow:\n\n1. Oracle database on Amazon EC2 configured with [Oracle Secure Backup.](https://docs.oracle.com/cd/E16926_01/doc.121/e16563/intro.htm#OBINS101)\n2. AWS Backup service to backup EC2 instance at regular intervals.\n3. Amazon EFS for storing Oracle RMAN archive log backups.\n\n![image.png](https://dev-media.amazoncloud.cn/2709fa8fa179408d86d2c67215c0570d_image.png)\n\nFigure 1. Oracle Database in Amazon EC2 using AWS Backup and EFS for backup and restore\n\n\n### **Prerequisites**\n\n\n1. An AWS account\n2. Oracle database and AWS CLI in an EC2 instance\n3. Access to configure AWS Backup\n4. Access to configure EFS to store the Oracle RMAN archive log backups\n\n#### **1. Configure AWS Backup**\n\nConfigure AWS Backup as detailed in Step 1 of [Part 1.](https://aws.amazon.com/blogs/architecture/using-aws-backup-and-oracle-rman-for-backup-restore-of-oracle-databases-on-amazon-ec2-part-1/)\n\n*Oracle RMAN archive log backup*\n\nWhile AWS Backup is now creating a daily backup of the EC2 instance, we also want to make sure we backup the archived log files to a protected location. This will let us do point-in-time restores and restore to more recent times than just the last daily EC2 backup. Below we provide the steps to backup archive log using RMAN to Amazon EFS.\n\n*Backup/restore archive logs to/from Amazon EFS*\n\nBacking up the [Oracle Archive](https://www.oracle.com/cloud/storage/archive-storage/) logs is an important part of the process. In this section, we will describe how you can backup their Oracle archive logs to Amazon EFS. One advantage of this option (as compared with using Oracle Secure Backup [detailed in [Part 1](https://aws.amazon.com/blogs/architecture/using-aws-backup-and-oracle-rman-for-backup-restore-of-oracle-databases-on-amazon-ec2-part-1/) of this series]) is that it does not require any additional Oracle licensing.\n\n#### **2. Configure Amazon EFS**\n\na. [Create an Amazon EFS file system ](https://docs.aws.amazon.com/efs/latest/ug/gs-step-two-create-efs-resources.html)that will be used to store Oracle RMAN Archive log backups. The image below details the steps involved in creation of an Amazon EFS. Consider that a sample file system ID: ```fs-0123abcdef012345```\nis created and will be used to store RMAN archive log backup.\n\n![image.png](https://dev-media.amazoncloud.cn/846896a4d7ec404abe60270f724034a9_image.png)\n\n![image.png](https://dev-media.amazoncloud.cn/2bed675bef45486f8ae71981c37257de_image.png)\n\n![image.png](https://dev-media.amazoncloud.cn/bca01ab01f464154adc3ded383e2c456_image.png)\n\nFigure 2. Configure Amazon EFS which is used to store Oracle RMAN archive log backups\n\nb. Install the [Amazon EFS Client](https://docs.aws.amazon.com/efs/latest/ug/installing-amazon-efs-utils.html) and follow instructions to install EFS client on RHEL EC2 instance. Note: next steps were tested on RHEL 7.9.\n\nBash\n\n```\nsudo yum -y install git\nsudo yum -y install rpm-build\ngit clone https://github.com/aws/efs-utils\ncd efs-utils/\nsudo yum -y install make\nsudo make rpm\nsudo yum -y install ./build/amazon-efs-utils*rpm\n```\n\nc.[ Mount the EFS file system ](https://docs.aws.amazon.com/efs/latest/ug/efs-mount-helper.html#mounting-fs-mount-helper-ec2-linux)on your EC2 instance. In this example, we show the steps to mount EFS filesystem on EC2 Instance (if the command requests to upgrade [stunnel](https://www.stunnel.org/), refer to [Upgrading stunnel](https://docs.aws.amazon.com/efs/latest/ug/upgrading-stunnel.html). Ensure that the EC2 instance profile attached has necessary policies to access EFS. ```/rman```\n for mount point and file system ID: ```fs-0123abcdef012345```\n are examples for EFS file system.\n\nBash\n\n```\nsudo mkdir /rman\nsudo mount -t efs -o tls,iam fs-0123abcdef012345 /rman\n```\n\nd. To mount EFS file system automatically on EC2 instance reboot, add an entry in ```/etc/fstab```\n. This example is for RHEL EC2 instance:\n\nBash\n\n```\nfs-0123abcdef012345:/ /rman efs _netdev,tls,iam 0 0\n```\n\n##### **3. Configure RMAN backup to Amazon EFS**\n\nWith Amazon EFS mounted on EC2 instance, we can configure Oracle RMAN archive log backups to EFS. In below commands ```oratst ```\nis used as an example of your ```ORACLE_SID```.\n\na. Configure RMAN repository to take control file backup to Amazon EFS automatically.\n\nBash\n\n```\nCONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '/rman/ctrl-D_%d_%F';\nCONFIGURE CONTROLFILE AUTOBACKUP ON;\n```\n\nb. Create a script (for example, rman_archive.sh) with below commands and schedule using crontab (example entry: ```*/5 * * * * rman_archive.sh```) to run every 5 minutes. This will ensure that Oracle Archive logs are backed up to Amazon EFS (```/rman```) frequently, ensuring an [recovery point objective (RPO) ](https://docs.aws.amazon.com/wellarchitected/latest/reliability-pillar/plan-for-disaster-recovery-dr.html)of 5 minutes.\n\nBash\n\n```\ndt=`date +%Y%m%d_%H%M%S`\n\nrman target / log=/rman/rman_arch_bkup_oratst_${dt}.log <<EOF\n\nRUN\n{\n allocate channel c1_efs device type disk format '/rman/arch-D-%d_%T_s%s_p%p' MAXPIECESIZE 10G;\n BACKUP ARCHIVELOG ALL delete all input;\n release channel c1_efs;\n}\n\nEOF\n```\n\n##### **4. Perform database point-in-time recovery**\n\nIn event of a database crash/corruption, we can use AWS Backup service and Oracle RMAN archive log backup to recover database to a specific point-in-time.\n\na. Typically, you would pick the most recent Recovery Point completed before the time to which you wish to recover. Using AWS Backup, identify the Recovery point ID to restore by following the steps from [Restoring an Amazon EC2 instance](https://docs.aws.amazon.com/aws-backup/latest/devguide/restoring-ec2.html). Note: when following the steps, be sure to set the “User data” settings as described in the next bulleted item.\n\nAfter the EBS volumes are created from the snapshot, there is no need to wait for all of the data to transfer from Amazon S3 to your Amazon EBS volume before your attached instance can start accessing the volume. Amazon EBS Snapshots implement lazy loading, so that you can begin using them right away.\n\nb. Ensure that database does not start automatically after restoring the EC2 instance, by renaming ```/etc/oratab```\n. Use below command in “User data” section while restoring EC2 instance. After database recovery, we can rename it back to ```/etc/oratab```.\n\nBash\n\n```\n#!/usr/bin/sh\nsudo su - \nmv /etc/oratab /etc/oratab_bk\n```\n\nc. Login to the EC2 instance once it is up and execute the RMAN recovery commands mentioned below. Identify the```DBID```from RMAN logs saved in the EFS. Below commands use database ```oratst ```as an example.\n\nBash\n\n```\nrman target /\n\nRMAN> startup nomount\n\nRMAN> set dbid DBID\n\n\n# Below command is to restore the controlfile from autobackup\n\nRMAN> RUN\n{\n set controlfile autobackup format for device type disk to '/rman/ctrl-D_%d_%F';\n RESTORE CONTROLFILE FROM AUTOBACKUP;\n alter database mount;\n}\n\n\n#Identify the recovery point (sequence_number) by listing the backups available in catalog.\n\nRMAN> list backup;\n```\n\nIn Figure 3, the most recent archive log backed up is 460, so you can use this sequence number in the next set of RMAN commands.\n\nBash\n\n```\nRMAN> RUN\n{\n allocate channel c1_efs device type disk format '/rman/arch-D-%d_%T_s%s_p%p'; \n recover database until sequence sequence_number;\n ALTER DATABASE OPEN RESETLOGS;\n release channel c1_efs;\n}\n```\n\n![image.png](https://dev-media.amazoncloud.cn/ea0c847cb28d4ceeb709e6535720191b_image.png)\n\nFigure 3. Sample output of Oracle RMAN “list backup” command\n\nd. To avoid performance issues due to lazy loading, after the database is open, you can run below command to force a faster restoration of the blocks from S3 bucket to EBS volumes (below example allocates two channels and validates the entire database).\n\n```\nBashRMAN> RUN\n{\n ALLOCATE CHANNEL c1 DEVICE TYPE DISK;\n ALLOCATE CHANNEL c2 DEVICE TYPE DISK;\n VALIDATE database section size 1200M;\n}\n\n```\n\ne. This completes the recovery of database, and we can let the database to auto start by renaming file back to ```/etc/oratab.```\n\nBash\n\n```\nmv /etc/oratab_bk /etc/oratab\n```\n\n##### **5. Backup retention**\n\nEnsure that the [AWS Backup Lifecycle policy](https://docs.aws.amazon.com/aws-backup/latest/devguide/creating-a-backup-plan.html#plan-options-and-configuration) match Oracle archive log backup [](). Also, follow documentation to configure Oracle backup [retention retention ](https://docs.oracle.com/en/database/oracle/oracle-database/19/admqs/performing-backup-and-recovery.html#GUID-48AD8DE1-B7F4-4909-939E-A0951C118AE8)and deleting [expired ](https://docs.oracle.com/en/database/oracle/oracle-database/19/admqs/performing-backup-and-recovery.html#GUID-83CED39F-DC23-4539-9668-32C89676904E)backup. Below is a sample command for Oracle backup retention.\n\nBash\n\n```\nCONFIGURE BACKUP OPTIMIZATION ON;\nCONFIGURE RETENTION POLICY TO RECOVERY WINDOW OF 31 DAYS; \n\nRMAN> RUN\n{\n allocate channel c1_efs device type disk format '/rman/arch-D-%d_%T_s%s_p%p';\n\n crosscheck backup;\n delete noprompt obsolete;\n delete noprompt expired backup;\n \n release channel c1_efs;\n}\n```\n\n\n### **Cleanup**\n\n\nFollow below instructions to remove or cleanup the setup:\n\n1. [Delete the backup plan](https://docs.aws.amazon.com/aws-backup/latest/devguide/deleting-a-backup-plan.html) created in Step 1.\n2. Remove the cron entry from the EC2 instance configured in Step 3b.\n3. [Delete the EFS](https://docs.aws.amazon.com/efs/latest/ug/delete-efs-fs.html) that was created in Step 2 to store Oracle RMAN archive log backups.\n\n\n### **Conclusion**\n\n\nIn this post, we demonstrated the use for AWS Backup for EC2 snapshot and EFS as storage for Oracle RMAN archive log backups. With this strategy for backup, Oracle Database running on EC2 can be restored and recovered to a point-in-time faster than oracle native backup and recovery strategies. Also, by using EFS for Oracle RMAN archive log backups, we can avoid the additional licensing required to use [Oracle Secure Backup](https://docs.oracle.com/cd/E16926_01/doc.121/e16563/intro.htm#OBINS101), explained in [Part 1](https://aws.amazon.com/blogs/architecture/using-aws-backup-and-oracle-rman-for-backup-restore-of-oracle-databases-on-amazon-ec2-part-1/). You can leverage this solution to facilitate restoring copies of your production database for development or testing purposes and to Recover from a user error that removes data or corrupts existing data.\n\nTo learn more about AWS Backup, refer to the [AWS Backup Documentation.](https://docs.aws.amazon.com/aws-backup/)\n\n![image.png](https://dev-media.amazoncloud.cn/44bbe51d8bfc41e29025110f79a3c712_image.png)\n\n### **Jeevan Shetty**\n\nJeevan Shetty is a Consultant with the AWS Proserve Team. He has been supporting and enabling customers to migrate their database from OnPrem data center to AWS cloud and also in migration from commercial database engines to open source database in Amazon.\n\n![image.png](https://dev-media.amazoncloud.cn/af9ee01adaf64bfb80baed8785ea75b4_image.png)\n\n### **Bhanu Ganesh Gudivada**\n\nBhanu Ganesh Gudivada is a Database Consultant with the Professional Services team at AWS and specializes in database migrations. He has been supporting and enabling customers to build high-available, cost-effective database solutions and migrate their commercial engines to AWS cloud. Bhanu is curious to learn and implement new technologies around the databases and orchestrate migrations through automation.\n\n![image.png](https://dev-media.amazoncloud.cn/a4fd3469c03c423eaddbe6e82c027042_image.png)\n\n### **Santhosh Kumar Adapa**\n\nSanthosh Kumar Adapa is a Database Consultant with the Professional Services team at AWS. He works as a database migration specialist to help Amazon customers in design and implementing scalable, secure, performant, and robust database solutions on the cloud.\n\n![image.png](https://dev-media.amazoncloud.cn/85baca12b5674af19be909cd0814f57e_image.png)\n\n### **Srini Ramaswamy**\n\nSrini Ramaswamy is a Consultant with the AWS Proserve Team. He has been supporting and enabling customers to migrate their database from OnPrem data center to AWS cloud and also in migration from commercial database engines to open source database in Amazon.","render":"<p>Customers running Oracle databases on <a href=\"https://aws.amazon.com/ec2/\" target=\"_blank\">Amazon Elastic Compute Cloud (Amazon EC2)</a> often take database and schema backups using Oracle native tools like Data Pump and Recovery Manager (RMAN) to satisfy data protection, disaster recovery (DR), and compliance requirements. A priority is to reduce backup time as the data grows exponentially and recover sooner in case of failure/disaster.</p>\n<p>In <a href=\"https://aws.amazon.com/blogs/architecture/using-aws-backup-and-oracle-rman-for-backup-restore-of-oracle-databases-on-amazon-ec2-part-1/\" target=\"_blank\">Part 1 </a>of this two-part series, we explain how we can use<a href=\"https://aws.amazon.com/backup/\" target=\"_blank\"> AWS Backup</a> and Amazon Simple Storage Service (Amazon S3) bucket to perform the backup and restore of an Oracle Database on AWS EC2.</p>\n<p>In Part 2, we provide a mechanism to use AWS Backup to create a full backup of the EC2 instance, including the OS image, Oracle binaries, logs, and data files. The mechanism also uses Oracle RMAN to perform archived redo log backup to Amazon Elastic File System (Amazon EFS). Then, we demonstrate the steps to restore a database to a specific point-in-time using AWS Backup and Oracle RMAN.</p>\n<h3><a id=\"Solution_overview_7\"></a><strong>Solution overview</strong></h3>\n<p>Figure 1 demonstrates the workflow:</p>\n<ol>\n<li>Oracle database on Amazon EC2 configured with <a href=\"https://docs.oracle.com/cd/E16926_01/doc.121/e16563/intro.htm#OBINS101\" target=\"_blank\">Oracle Secure Backup.</a></li>\n<li>AWS Backup service to backup EC2 instance at regular intervals.</li>\n<li>Amazon EFS for storing Oracle RMAN archive log backups.</li>\n</ol>\n<p><img src=\"https://dev-media.amazoncloud.cn/2709fa8fa179408d86d2c67215c0570d_image.png\" alt=\"image.png\" /></p>\n<p>Figure 1. Oracle Database in Amazon EC2 using AWS Backup and EFS for backup and restore</p>\n<h3><a id=\"Prerequisites_21\"></a><strong>Prerequisites</strong></h3>\n<ol>\n<li>An AWS account</li>\n<li>Oracle database and AWS CLI in an EC2 instance</li>\n<li>Access to configure AWS Backup</li>\n<li>Access to configure EFS to store the Oracle RMAN archive log backups</li>\n</ol>\n<h4><a id=\"1_Configure_AWS_Backup_29\"></a><strong>1. Configure AWS Backup</strong></h4>\n<p>Configure AWS Backup as detailed in Step 1 of <a href=\"https://aws.amazon.com/blogs/architecture/using-aws-backup-and-oracle-rman-for-backup-restore-of-oracle-databases-on-amazon-ec2-part-1/\" target=\"_blank\">Part 1.</a></p>\n<p><em>Oracle RMAN archive log backup</em></p>\n<p>While AWS Backup is now creating a daily backup of the EC2 instance, we also want to make sure we backup the archived log files to a protected location. This will let us do point-in-time restores and restore to more recent times than just the last daily EC2 backup. Below we provide the steps to backup archive log using RMAN to Amazon EFS.</p>\n<p><em>Backup/restore archive logs to/from Amazon EFS</em></p>\n<p>Backing up the <a href=\"https://www.oracle.com/cloud/storage/archive-storage/\" target=\"_blank\">Oracle Archive</a> logs is an important part of the process. In this section, we will describe how you can backup their Oracle archive logs to Amazon EFS. One advantage of this option (as compared with using Oracle Secure Backup [detailed in <a href=\"https://aws.amazon.com/blogs/architecture/using-aws-backup-and-oracle-rman-for-backup-restore-of-oracle-databases-on-amazon-ec2-part-1/\" target=\"_blank\">Part 1</a> of this series]) is that it does not require any additional Oracle licensing.</p>\n<h4><a id=\"2_Configure_Amazon_EFS_41\"></a><strong>2. Configure Amazon EFS</strong></h4>\n<p>a. <a href=\"https://docs.aws.amazon.com/efs/latest/ug/gs-step-two-create-efs-resources.html\" target=\"_blank\">Create an Amazon EFS file system </a>that will be used to store Oracle RMAN Archive log backups. The image below details the steps involved in creation of an Amazon EFS. Consider that a sample file system ID: <code>fs-0123abcdef012345</code><br />\nis created and will be used to store RMAN archive log backup.</p>\n<p><img src=\"https://dev-media.amazoncloud.cn/846896a4d7ec404abe60270f724034a9_image.png\" alt=\"image.png\" /></p>\n<p><img src=\"https://dev-media.amazoncloud.cn/2bed675bef45486f8ae71981c37257de_image.png\" alt=\"image.png\" /></p>\n<p><img src=\"https://dev-media.amazoncloud.cn/bca01ab01f464154adc3ded383e2c456_image.png\" alt=\"image.png\" /></p>\n<p>Figure 2. Configure Amazon EFS which is used to store Oracle RMAN archive log backups</p>\n<p>b. Install the <a href=\"https://docs.aws.amazon.com/efs/latest/ug/installing-amazon-efs-utils.html\" target=\"_blank\">Amazon EFS Client</a> and follow instructions to install EFS client on RHEL EC2 instance. Note: next steps were tested on RHEL 7.9.</p>\n<p>Bash</p>\n<pre><code class=\"lang-\">sudo yum -y install git\nsudo yum -y install rpm-build\ngit clone https://github.com/aws/efs-utils\ncd efs-utils/\nsudo yum -y install make\nsudo make rpm\nsudo yum -y install ./build/amazon-efs-utils*rpm\n</code></pre>\n<p>c.<a href=\"https://docs.aws.amazon.com/efs/latest/ug/efs-mount-helper.html#mounting-fs-mount-helper-ec2-linux\" target=\"_blank\"> Mount the EFS file system </a>on your EC2 instance. In this example, we show the steps to mount EFS filesystem on EC2 Instance (if the command requests to upgrade <a href=\"https://www.stunnel.org/\" target=\"_blank\">stunnel</a>, refer to <a href=\"https://docs.aws.amazon.com/efs/latest/ug/upgrading-stunnel.html\" target=\"_blank\">Upgrading stunnel</a>. Ensure that the EC2 instance profile attached has necessary policies to access EFS. <code>/rman</code><br />\nfor mount point and file system ID: <code>fs-0123abcdef012345</code><br />\nare examples for EFS file system.</p>\n<p>Bash</p>\n<pre><code class=\"lang-\">sudo mkdir /rman\nsudo mount -t efs -o tls,iam fs-0123abcdef012345 /rman\n</code></pre>\n<p>d. To mount EFS file system automatically on EC2 instance reboot, add an entry in <code>/etc/fstab</code><br />\n. This example is for RHEL EC2 instance:</p>\n<p>Bash</p>\n<pre><code class=\"lang-\">fs-0123abcdef012345:/ /rman efs _netdev,tls,iam 0 0\n</code></pre>\n<h5><a id=\"3_Configure_RMAN_backup_to_Amazon_EFS_88\"></a><strong>3. Configure RMAN backup to Amazon EFS</strong></h5>\n<p>With Amazon EFS mounted on EC2 instance, we can configure Oracle RMAN archive log backups to EFS. In below commands <code>oratst </code><br />\nis used as an example of your <code>ORACLE_SID</code>.</p>\n<p>a. Configure RMAN repository to take control file backup to Amazon EFS automatically.</p>\n<p>Bash</p>\n<pre><code class=\"lang-\">CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '/rman/ctrl-D_%d_%F';\nCONFIGURE CONTROLFILE AUTOBACKUP ON;\n</code></pre>\n<p>b. Create a script (for example, rman_archive.sh) with below commands and schedule using crontab (example entry: <code>*/5 * * * * rman_archive.sh</code>) to run every 5 minutes. This will ensure that Oracle Archive logs are backed up to Amazon EFS (<code>/rman</code>) frequently, ensuring an <a href=\"https://docs.aws.amazon.com/wellarchitected/latest/reliability-pillar/plan-for-disaster-recovery-dr.html\" target=\"_blank\">recovery point objective (RPO) </a>of 5 minutes.</p>\n<p>Bash</p>\n<pre><code class=\"lang-\">dt=`date +%Y%m%d_%H%M%S`\n\nrman target / log=/rman/rman_arch_bkup_oratst_${dt}.log &lt;&lt;EOF\n\nRUN\n{\n allocate channel c1_efs device type disk format '/rman/arch-D-%d_%T_s%s_p%p' MAXPIECESIZE 10G;\n BACKUP ARCHIVELOG ALL delete all input;\n release channel c1_efs;\n}\n\nEOF\n</code></pre>\n<h5><a id=\"4_Perform_database_pointintime_recovery_121\"></a><strong>4. Perform database point-in-time recovery</strong></h5>\n<p>In event of a database crash/corruption, we can use AWS Backup service and Oracle RMAN archive log backup to recover database to a specific point-in-time.</p>\n<p>a. Typically, you would pick the most recent Recovery Point completed before the time to which you wish to recover. Using AWS Backup, identify the Recovery point ID to restore by following the steps from <a href=\"https://docs.aws.amazon.com/aws-backup/latest/devguide/restoring-ec2.html\" target=\"_blank\">Restoring an Amazon EC2 instance</a>. Note: when following the steps, be sure to set the “User data” settings as described in the next bulleted item.</p>\n<p>After the EBS volumes are created from the snapshot, there is no need to wait for all of the data to transfer from Amazon S3 to your Amazon EBS volume before your attached instance can start accessing the volume. Amazon EBS Snapshots implement lazy loading, so that you can begin using them right away.</p>\n<p>b. Ensure that database does not start automatically after restoring the EC2 instance, by renaming <code>/etc/oratab</code><br />\n. Use below command in “User data” section while restoring EC2 instance. After database recovery, we can rename it back to <code>/etc/oratab</code>.</p>\n<p>Bash</p>\n<pre><code class=\"lang-\">#!/usr/bin/sh\nsudo su - \nmv /etc/oratab /etc/oratab_bk\n</code></pre>\n<p>c. Login to the EC2 instance once it is up and execute the RMAN recovery commands mentioned below. Identify the<code>DBID</code>from RMAN logs saved in the EFS. Below commands use database <code>oratst </code>as an example.</p>\n<p>Bash</p>\n<pre><code class=\"lang-\">rman target /\n\nRMAN&gt; startup nomount\n\nRMAN&gt; set dbid DBID\n\n\n# Below command is to restore the controlfile from autobackup\n\nRMAN&gt; RUN\n{\n set controlfile autobackup format for device type disk to '/rman/ctrl-D_%d_%F';\n RESTORE CONTROLFILE FROM AUTOBACKUP;\n alter database mount;\n}\n\n\n#Identify the recovery point (sequence_number) by listing the backups available in catalog.\n\nRMAN&gt; list backup;\n</code></pre>\n<p>In Figure 3, the most recent archive log backed up is 460, so you can use this sequence number in the next set of RMAN commands.</p>\n<p>Bash</p>\n<pre><code class=\"lang-\">RMAN&gt; RUN\n{\n allocate channel c1_efs device type disk format '/rman/arch-D-%d_%T_s%s_p%p'; \n recover database until sequence sequence_number;\n ALTER DATABASE OPEN RESETLOGS;\n release channel c1_efs;\n}\n</code></pre>\n<p><img src=\"https://dev-media.amazoncloud.cn/ea0c847cb28d4ceeb709e6535720191b_image.png\" alt=\"image.png\" /></p>\n<p>Figure 3. Sample output of Oracle RMAN “list backup” command</p>\n<p>d. To avoid performance issues due to lazy loading, after the database is open, you can run below command to force a faster restoration of the blocks from S3 bucket to EBS volumes (below example allocates two channels and validates the entire database).</p>\n<pre><code class=\"lang-\">BashRMAN&gt; RUN\n{\n ALLOCATE CHANNEL c1 DEVICE TYPE DISK;\n ALLOCATE CHANNEL c2 DEVICE TYPE DISK;\n VALIDATE database section size 1200M;\n}\n\n</code></pre>\n<p>e. This completes the recovery of database, and we can let the database to auto start by renaming file back to <code>/etc/oratab.</code></p>\n<p>Bash</p>\n<pre><code class=\"lang-\">mv /etc/oratab_bk /etc/oratab\n</code></pre>\n<h5><a id=\"5_Backup_retention_205\"></a><strong>5. Backup retention</strong></h5>\n<p>Ensure that the <a href=\"https://docs.aws.amazon.com/aws-backup/latest/devguide/creating-a-backup-plan.html#plan-options-and-configuration\" target=\"_blank\">AWS Backup Lifecycle policy</a> match Oracle archive log backup <a href=\"\" target=\"_blank\"></a>. Also, follow documentation to configure Oracle backup <a href=\"https://docs.oracle.com/en/database/oracle/oracle-database/19/admqs/performing-backup-and-recovery.html#GUID-48AD8DE1-B7F4-4909-939E-A0951C118AE8\" target=\"_blank\">retention retention </a>and deleting <a href=\"https://docs.oracle.com/en/database/oracle/oracle-database/19/admqs/performing-backup-and-recovery.html#GUID-83CED39F-DC23-4539-9668-32C89676904E\" target=\"_blank\">expired </a>backup. Below is a sample command for Oracle backup retention.</p>\n<p>Bash</p>\n<pre><code class=\"lang-\">CONFIGURE BACKUP OPTIMIZATION ON;\nCONFIGURE RETENTION POLICY TO RECOVERY WINDOW OF 31 DAYS; \n\nRMAN&gt; RUN\n{\n allocate channel c1_efs device type disk format '/rman/arch-D-%d_%T_s%s_p%p';\n\n crosscheck backup;\n delete noprompt obsolete;\n delete noprompt expired backup;\n \n release channel c1_efs;\n}\n</code></pre>\n<h3><a id=\"Cleanup_228\"></a><strong>Cleanup</strong></h3>\n<p>Follow below instructions to remove or cleanup the setup:</p>\n<ol>\n<li><a href=\"https://docs.aws.amazon.com/aws-backup/latest/devguide/deleting-a-backup-plan.html\" target=\"_blank\">Delete the backup plan</a> created in Step 1.</li>\n<li>Remove the cron entry from the EC2 instance configured in Step 3b.</li>\n<li><a href=\"https://docs.aws.amazon.com/efs/latest/ug/delete-efs-fs.html\" target=\"_blank\">Delete the EFS</a> that was created in Step 2 to store Oracle RMAN archive log backups.</li>\n</ol>\n<h3><a id=\"Conclusion_238\"></a><strong>Conclusion</strong></h3>\n<p>In this post, we demonstrated the use for AWS Backup for EC2 snapshot and EFS as storage for Oracle RMAN archive log backups. With this strategy for backup, Oracle Database running on EC2 can be restored and recovered to a point-in-time faster than oracle native backup and recovery strategies. Also, by using EFS for Oracle RMAN archive log backups, we can avoid the additional licensing required to use <a href=\"https://docs.oracle.com/cd/E16926_01/doc.121/e16563/intro.htm#OBINS101\" target=\"_blank\">Oracle Secure Backup</a>, explained in <a href=\"https://aws.amazon.com/blogs/architecture/using-aws-backup-and-oracle-rman-for-backup-restore-of-oracle-databases-on-amazon-ec2-part-1/\" target=\"_blank\">Part 1</a>. You can leverage this solution to facilitate restoring copies of your production database for development or testing purposes and to Recover from a user error that removes data or corrupts existing data.</p>\n<p>To learn more about AWS Backup, refer to the <a href=\"https://docs.aws.amazon.com/aws-backup/\" target=\"_blank\">AWS Backup Documentation.</a></p>\n<p><img src=\"https://dev-media.amazoncloud.cn/44bbe51d8bfc41e29025110f79a3c712_image.png\" alt=\"image.png\" /></p>\n<h3><a id=\"Jeevan_Shetty_247\"></a><strong>Jeevan Shetty</strong></h3>\n<p>Jeevan Shetty is a Consultant with the AWS Proserve Team. He has been supporting and enabling customers to migrate their database from OnPrem data center to AWS cloud and also in migration from commercial database engines to open source database in Amazon.</p>\n<p><img src=\"https://dev-media.amazoncloud.cn/af9ee01adaf64bfb80baed8785ea75b4_image.png\" alt=\"image.png\" /></p>\n<h3><a id=\"Bhanu_Ganesh_Gudivada_253\"></a><strong>Bhanu Ganesh Gudivada</strong></h3>\n<p>Bhanu Ganesh Gudivada is a Database Consultant with the Professional Services team at AWS and specializes in database migrations. He has been supporting and enabling customers to build high-available, cost-effective database solutions and migrate their commercial engines to AWS cloud. Bhanu is curious to learn and implement new technologies around the databases and orchestrate migrations through automation.</p>\n<p><img src=\"https://dev-media.amazoncloud.cn/a4fd3469c03c423eaddbe6e82c027042_image.png\" alt=\"image.png\" /></p>\n<h3><a id=\"Santhosh_Kumar_Adapa_259\"></a><strong>Santhosh Kumar Adapa</strong></h3>\n<p>Santhosh Kumar Adapa is a Database Consultant with the Professional Services team at AWS. He works as a database migration specialist to help Amazon customers in design and implementing scalable, secure, performant, and robust database solutions on the cloud.</p>\n<p><img src=\"https://dev-media.amazoncloud.cn/85baca12b5674af19be909cd0814f57e_image.png\" alt=\"image.png\" /></p>\n<h3><a id=\"Srini_Ramaswamy_265\"></a><strong>Srini Ramaswamy</strong></h3>\n<p>Srini Ramaswamy is a Consultant with the AWS Proserve Team. He has been supporting and enabling customers to migrate their database from OnPrem data center to AWS cloud and also in migration from commercial database engines to open source database in Amazon.</p>\n"}
目录
亚马逊云科技解决方案 基于行业客户应用场景及技术领域的解决方案
联系亚马逊云科技专家
亚马逊云科技解决方案
基于行业客户应用场景及技术领域的解决方案
联系专家
0
目录
关闭
contact-us