Let's see all the required steps to practice this recovery operation:
DEFER
command to defer the log destination in the primary database, and execute the following operation that will generate redo in the primary database:SQL> ALTER SYSTEM SET LOG_ARCHIVE_DEST_STATE_2 = 'DEFER';
SQL> ALTER DATABASE RECOVER MANAGED STANDBY DATABASE CANCEL;
SQL> SELECT MIN(FHSCN) FROM X$KCVFH; MIN(FHSCN) ---------------- 20606344
RMAN> BACKUP INCREMENTAL FROM SCN 20606344 DATABASE FORMAT '/tmp/Standby_Inc_%U' tag 'STANDBY_INC'; Starting backup at 20-DEC-12 using target database control file instead of recovery catalog allocated channel: ORA_DISK_1 channel ORA_DISK_1: SID=165 device type=DISK backup will be obsolete on date 27-DEC-12 archived logs will not be kept or backed up channel ORA_DISK_1: starting full datafile backup set channel ORA_DISK_1: specifying datafile(s) in backup set input datafile file number=00001 name=/u01/app/oracle2/datafile/ORCL/system01.dbf ... input datafile file number=00007 name=/u01/app/oracle2/datafile/ORCL/system03.dbf channel ORA_DISK_1: starting piece 1 at 20-DEC-12 channel ORA_DISK_1: finished piece 1 at 20-DEC-12 piece handle=/tmp/Standby_Inc_03nt9u0v_1_1 tag=STANDBY_INC comment=NONE channel ORA_DISK_1: backup set complete, elapsed time: 00:01:15 using channel ORA_DISK_1 including current control file in backup set channel ORA_DISK_1: starting piece 1 at 20-DEC-12 channel ORA_DISK_1: finished piece 1 at 20-DEC-12 piece handle=/tmp/Standby_Inc_04nt9u3a_1_1 tag=STANDBY_INC comment=NONE channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01 Finished backup at 20-DEC-12
scp /tmp/Standby_Inc_* standbyhost:/tmp/
CATALOG
command, so that we'll be able to recover the standby database using these backup files:RMAN> CATALOG START WITH '/tmp/Standby_Inc'; using target database control file instead of recovery catalog searching for all files that match the pattern /tmp/Standby_Inc List of Files Unknown to the Database ===================================== File Name: /tmp/Standby_Inc_03nt9u0v_1_1 File Name: /tmp/Standby_Inc_04nt9u3a_1_1 Do you really want to catalog the above files (enter YES or NO)? YES cataloging files... cataloging done List of Cataloged Files ======================= File Name: /tmp/Standby_Inc_03nt9u0v_1_1 File Name: /tmp/Standby_Inc_04nt9u3a_1_1
RECOVER
statement. The Recovery operation will use the incremental backup by default as we have already registered the backup files:RMAN> RECOVER DATABASE NOREDO; Starting recover at 20-DEC-12 allocated channel: ORA_DISK_1 channel ORA_DISK_1: SID=1237 device type=DISK channel ORA_DISK_1: starting incremental datafile backup set restore channel ORA_DISK_1: specifying datafile(s) to restore from backup set destination for restore of datafile 00001: /u01/app/oracle2/datafile/INDIAPS/system01.dbf ... destination for restore of datafile 00007: /u01/app/oracle2/datafile/INDIAPS/system03.dbf channel ORA_DISK_1: reading from backup piece /tmp/Standby_Inc_03nt9u0v_1_1 channel ORA_DISK_1: piece handle=/tmp/Standby_Inc_03nt9u0v_1_1 tag=STANDBY_INC channel ORA_DISK_1: restored backup piece 1 channel ORA_DISK_1: restore complete, elapsed time: 00:00:01 Finished recover at 20-DEC-12
In the primary database you will see the following command lines:
RMAN> BACKUP CURRENT CONTROLFILE FOR STANDBY FORMAT '/tmp/Standby_CTRL.bck'; scp /tmp/Standby_CTRL.bck standbyhost:/tmp/
In the standby database you will see the following command lines:
RMAN> SHUTDOWN; RMAN> STARTUP NOMOUNT; RMAN> RESTORE STANDBY CONTROLFILE FROM '/tmp/Standby_CTRL.bck'; RMAN> SHUTDOWN; RMAN> STARTUP MOUNT;
If OMF is being used, execute the following commands:
RMAN> CATALOG START WITH '+DATA/mystd/datafile/'; RMAN> SWITCH DATABASE TO COPY;
We will determine if any files have been added to the primary database, as the standby current SCN will run the following query:
SQL>SELECT FILE#, NAME FROM V$DATAFILE WHERE CREATION_CHANGE# > 20606344;
ON
in the standby database, turn it off and on again:SQL> ALTER DATABASE FLASHBACK OFF; SQL> ALTER DATABASE FLASHBACK ON;
SQL> ALTER DATABASE CLEAR LOGFILE GROUP 4; SQL> ALTER DATABASE CLEAR LOGFILE GROUP 5; SQL> ALTER DATABASE CLEAR LOGFILE GROUP 6; SQL> ALTER DATABASE CLEAR LOGFILE GROUP 7;
SQL> ALTER DATABASE RECOVER MANAGED STANDBY DATABASE USING CURRENT LOGFILE DISCONNECT FROM SESSION;
We've recovered a Data Guard configuration where the standby database is behind the primary database because of a gap, and the necessary archived logfiles to recover the standby database are missing. We used the RMAN BACKUP INCREMENTAL FROM SCN
statement for this purpose.