Time for action – closing a gap with an RMAN incremental backup

Let's see all the required steps to practice this recovery operation:

  1. In this practice, assume that there are missing archived logs (gap) in the standby database, and we're not able to restore these archived logs. We'll synchronize Data Guard using the RMAN incremental backup. To represent this situation, execute the 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';
    
  2. Now we have a standby database behind the primary database, and we'll use RMAN to reflect the primary database's changes to the standby database. Stop Redo Apply in the standby database:
    SQL> ALTER DATABASE RECOVER MANAGED STANDBY DATABASE CANCEL;
    
  3. Query the current system change number (SCN) of the standby database that will be used as the limit for an incremental backup of the primary database. Run the following statement on the standby database:
    SQL> SELECT MIN(FHSCN) FROM X$KCVFH;
    
    MIN(FHSCN)
    ----------------
    20606344
    
  4. Run an RMAN incremental backup of the primary database by using the obtained SCN value.

    Tip

    This backup job will check all the blocks of the primary database and back up the blocks that have a higher SCN. So even if the backup size is small, it may take a long time.

    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
    
  5. Copy the backup files from the primary site to the standby site with FTP or SCP.
    scp /tmp/Standby_Inc_* standbyhost:/tmp/
    
  6. Register the backup files to the standby database control file with the RMAN 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
    
  7. Recover the standby database with the RMAN 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 
    
  8. In this step, we'll create a new standby control file in the primary database and open the standby database using this new control file. We've performed this process at the beginning of this chapter, so we won't be explaining it again; only the statements are given as follows:

    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; 
    
  9. If new datafiles were added during the time when Data Guard had been stopped, we will need to copy and register the newly created files to the standby system, as they were not included in the incremental backup set.

    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;
    
  10. If the flashback database is ON in the standby database, turn it off and on again:
    SQL> ALTER DATABASE FLASHBACK OFF; 
    SQL> ALTER DATABASE FLASHBACK ON;
    
  11. Clear all the standby redo log groups in the standby database:
    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;
    
  12. Start Redo Apply in the standby database:
    SQL> ALTER DATABASE RECOVER MANAGED STANDBY DATABASE USING CURRENT LOGFILE DISCONNECT FROM SESSION;
    

What just happened?

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.

Pop quiz – using a tape for SCN incremental backup

Is it possible to use tape backups in order to close a Data Guard gap with the RMAN incremental backup method?

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.148.107.254