DBA Tips Archive for Oracle |
Using RMAN Incremental Backups to Roll Forward a Physical Standby Database - (10g)
by Jeff Hunter, Sr. Database Administrator
There are several scenarios that can occur in an Oracle Data Guard configuration which renders a physical standby database as either unusable or invalid. For example, an extended network failure can occur between the primary and standby machines which cause the standby database to fall significantly far behind the primary database. If the necessary archived redo log files needed to synchronize the physical standby database with the primary database are no longer available, log gap resolution will be unable to resolve the gap in the redo stream to catch up the standby.
Another popular scenario exists when a DML or DDL operation is performed on the primary database using the NOLOGGING or UNRECOVERABLE clause and the FORCE LOGGING database option is not enabled on the primary. If the FORCE LOGGING database option is not enabled, then Oracle will not log the entire operation in the redo log and thus, never send the modified data to the standby database for recovery. While this doesn't necessarily render the entire standby database as unusable, it does invalidate the standby for those tables affected and may require substantial DBA administrative activities to repair. Although you can specify the ALTER DATABASE FORCE LOGGING statement on the primary database to override the NOLOGGING clause and prevent this type of damage to occur in the future, this statement will not repair a standby database that has already been invalidated.
In each of the scenarios listed above, one solution would be to simply delete and formally re-create the physical standby database to enter it back into the Data Guard configuration. Depending on the size of the database, rebuilding the standby database could be an expensive operation as it would potentially involve a lot of time and resources making this a nonviable option.
This guide presents a quick and efficient alternative to rebuilding a physical standby database in Oracle Database 10g Release 2 by using RMAN incremental backups to roll forward and resynchronize a physical standby database with the primary database. Using the RMAN BACKUP INCREMENTAL FROM SCN command, you can create an incremental backup on the primary database that starts at the standby database's current SCN, which can then be used to roll the standby database forward in time.
It is assumed that a primary and one physical standby database is already configured in order to perform the steps described in this guide. The examples used in this guide will make use of the Oracle Data Guard configuration described in the article below:
In cases where a physical standby database is far behind the primary database, an RMAN incremental backup can be used to roll the standby database forward faster than redo log apply. The steps in this section can also be used to resolve problems if a physical standby database has lost or corrupted archived redo data or has an unresolvable archive gap. In this procedure, the RMAN BACKUP INCREMENTAL FROM SCN command is used to create an incremental backup on the primary database that starts at the current SCN of the standby and is used to roll forward the standby database.
On the physical standby database, stop the managed recovery process (MRP):
|
On the physical standby database, find the SCN which will be used for the incremental backup at the primary database, as the backup must be created from this SCN forward.
|
Record the SCN returned from the above query for the next step.
Using RMAN, connect to the primary database and create an incremental backup from the SCN derived in the previous step.
|
Using an OS remote copy utility, transfer all backup sets created on the primary system to the physical standby machine. Note that there may be more than one backup file created and that all backup pieces of the incremental backup must be manually copied to the physical standby database before you catalog them. For example, to scp the RMAN incremental backup sets from the primary database machine vmlinux1 to the physical standby database running on machine vmlinux2, you would run the following command:
|
After copying the incremental backup pieces to the physical standby machine, connect to the physical standby database using RMAN and catalog those incremental backup pieces. Then recover the standby database with the cataloged incremental backup pieces.
|
Connect to the primary database using RMAN and create a standby control file backup.
|
Using an OS remote copy utility, transfer the standby control file backup created on the primary system to the physical standby database machine. For example, to scp the standby control file backup from the primary database machine vmlinux1 to the physical standby database running on machine vmlinux2, you would run the following command:
|
Shut down the physical standby database and startup nomount:
|
Connect to the physical standby database using RMAN and restore the standby control file.
|
Shut down the physical standby database again and startup mount:
|
If the primary and standby database data file directories are identical, skip to step 12. If the primary and standby database data file directories are different, then in RMAN, connect to the physical standby database, catalog all standby data files, and switch the standby database to use the just-cataloged data files.
For example, if the primary database data file directory is /u02/oradata/MODESTO/datafile/ and the standby database data file directory is /u02/oradata/TURLOCK/datafile/, then run the following statement in RMAN to catalog all standby data files while connected to the physical standby database:
|
If the standby database has other database data files not included in the directory specified above, they too will need to be cataloged. In this particular example, I had standby database data files not only in the /u02/oradata/TURLOCK/datafile/ directory (above), but also in the /u05/oradata/TURLOCK directory. Every database data file will need to be cataloged in order to create recoverable copies. Attempting to switch the standby database without cataloging every data file will result in an error. For example,
|
After all standby database data file copies have been cataloged, switch the standby database to use the just-cataloged data files.
|
The same situation exists with the redo log files that existed with the data file directories. If the primary and standby database redo log directories are identical, skip to step 13. Otherwise, on the standby database, use an OS utility or the asmcmd utility (if it is an ASM-managed database) to remove all online and standby redo logs from the standby directories. For example,
|
In addition, ensure that the LOG_FILE_NAME_CONVERT initialization parameter has been set to convert the directory paths. As an example, you would include the following in your parameter file on the physical standby database to convert the directory paths from MODESTO to TURLOCK:
LOG_FILE_NAME_CONVERT='/MODESTO/','/TURLOCK/'
On the standby database, clear all of the online redo log and standby redo log groups.
|
Verify the new online redo log and standby redo log members were successfully created on the physical standby.
|
After successfully clearing all standby redo log groups, re-enable Flashback database on the physical standby database.
|
Finally, on the physical standby database, restart the managed recovery process (MRP).
|
An often asked question is what are the consequences of running a DML or DDL operation on a primary database in a Data Guard configuration using the NOLOGGING clause and the FORCE LOGGING database option is not enabled on the primary. When a user submits a NOLOGGING operation, although a redo log record does get written to the redo log of the primary, there is no data associated with this record. In this type of scenario, if the FORCE LOGGING database option is not enabled, then Oracle will not log the entire operation in the redo log and thus, never send the modified data to the standby database for recovery. While this doesn't necessarily render the entire standby database as unusable, it does invalidate the standby for those tables affected and may require substantial DBA administrative activities to repair. For example, the NOLOGGING operation will render the data blocks on the standby database as logically corrupt because of the missing or incomplete redo log entries. If the standby database is ever opened in read only mode or worse yet, switches to the primary role, errors will occur when trying to access those objects (data blocks) that were previously written with the NOLOGGING option. Attempting to access logically corrupt data blocks on the standby database will throw an error similar to the following:
|
Although you can specify the ALTER DATABASE FORCE LOGGING statement on the primary database to override the NOLOGGING clause and prevent this type of damage to occur in the future, this statement will not repair a standby database that has already been invalidated.
This section provides step-by-step instructions to roll forward a physical standby database for which NOLOGGING changes have been applied to a small subset of the database. First though, let's logically corrupt the physical standby database which will be used as a test case to perform those recovery steps.
|
Use the following steps to roll forward the logically corrupt physical standby database.
List the files that have had NOLOGGING changes applied by querying the V$DATAFILE view on the physical standby database. For example:
|
Stop Redo Apply on the physical standby database.
|
On the physical standby database, offline the datafiles (recorded in step 1) that have had NOLOGGING changes. Taking these datafiles offline ensures redo data is not skipped for the corrupt blocks while the incremental backups are performed.
|
Start Redo Apply on the physical standby database.
|
Connect to the primary database as the RMAN target, create an incremental backup for each datafile listed in the FIRST_NONLOGGED_SCN column (recorded in step 1). For example:
|
Using an OS remote copy utility, transfer all backup sets created on the primary system to the physical standby machine. Note that there may be more than one backup file created and that all backup pieces of the incremental backups must be manually copied to the physical standby database before you catalog them. For example, to scp the RMAN incremental backup sets from the primary database machine vmlinux1 to the physical standby database running on machine vmlinux2, you would run the following command:
|
After copying the incremental backup pieces to the physical standby machine, connect to the physical standby database using RMAN and catalog those incremental backup pieces.
|
Stop Redo Apply on the physical standby database.
|
Online the datafiles on the standby database that were taken offline in step 3.
|
While connected to the physical standby database as the RMAN target, apply the incremental backup sets.
|
Re-query the V$DATAFILE view on the standby database to verify there are no datafiles with nologged changes. The following query should return zero rows:
|
Remove the incremental backups from the physical standby system.
|
Manually remove the incremental backups from the primary system. Remember that RMAN does not consider this type of independent incremental backup as part of a backup strategy at the source database and thus, does no catalog it. For example, the following example uses the Linux rm command:
|
Start Redo Apply on the physical standby database.
|
Use the following steps to roll forward a logically corrupt physical standby database for which NOLOGGING changes have been applied to a large portion of the database.
Query the V$DATAFILE view on the standby database to record the lowest FIRST_NONLOGGED_SCN.
|
Stop Redo Apply on the physical standby database.
|
Connect to the primary database as the RMAN target, create an incremental backup from the lowest FIRST_NONLOGGED_SCN (recorded in step 1). For example:
|
Using an OS remote copy utility, transfer all backup sets created on the primary system to the physical standby machine. Note that there may be more than one backup file created and that all backup pieces of the incremental backup must be manually copied to the physical standby database before you catalog them. For example, to scp the RMAN incremental backup sets from the primary database machine vmlinux1 to the physical standby database running on machine vmlinux2, you would run the following command:
|
After copying the incremental backup pieces to the physical standby machine, connect to the physical standby database using RMAN and catalog those incremental backup pieces.
|
While connected to the physical standby database as the RMAN target, apply the incremental backups
|
Re-query the V$DATAFILE view on the standby database to verify there are no datafiles with nologged changes. The following query should return zero rows:
|
Remove the incremental backups from the physical standby system.
|
Manually remove the incremental backups from the primary system. Remember that RMAN does not consider this type of independent incremental backup as part of a backup strategy at the source database and thus, does no catalog it. For example, the following example uses the Linux rm command:
|
Start Redo Apply on the physical standby database.
|
Jeffrey Hunter is an Oracle Certified Professional, Java Development Certified Professional, Author, and an Oracle ACE. Jeff currently works as a Senior Database Administrator for The DBA Zone, Inc. located in Pittsburgh, Pennsylvania. His work includes advanced performance tuning, Java and PL/SQL programming, developing high availability solutions, capacity planning, database security, and physical / logical database design in a UNIX, Linux, and Windows server environment. Jeff's other interests include mathematical encryption theory, programming language processors (compilers and interpreters) in Java and C, LDAP, writing web-based database administration tools, and of course Linux. He has been a Sr. Database Administrator and Software Engineer for over 18 years and maintains his own website site at: http://www.iDevelopment.info. Jeff graduated from Stanislaus State University in Turlock, California, with a Bachelor's degree in Computer Science.
Copyright (c) 1998-2012 Jeffrey M. Hunter. All rights reserved.
All articles, scripts and material located at the Internet address of http://www.idevelopment.info is the copyright of Jeffrey M. Hunter and is protected under copyright laws of the United States. This document may not be hosted on any other site without my express, prior, written permission. Application to host any of the material elsewhere can be made by contacting me at jhunter@idevelopment.info.
I have made every effort and taken great care in making sure that the material included on my web site is technically accurate, but I disclaim any and all responsibility for any loss, damage or destruction of data or any other property which may arise from relying on it. I will in no case be liable for any monetary damages arising from such loss, damage or destruction.
Last modified on
Thursday, 19-Jan-2012 01:09:21 EST
Page Count: 8008