Time for action – fixing NOLOGGING changes on a standby database with incremental datafile backups

As a prerequisite for this exercise, first put the primary database in the no-force logging mode using the ALTER DATABASE NO FORCE LOGGING statement. Then perform some DML operations in the primary database using the NOLOGGING clause so that we can fix the issue in the standby database with the following steps:

  1. Run the following query to identify the datafiles that are affected by NOLOGGING changes:
    SQL> SELECT FILE#, FIRST_NONLOGGED_SCN FROM V$DATAFILE WHERE FIRST_NONLOGGED_SCN > 0;
    
    FILE#      FIRST_NONLOGGED_SCN
    ---------- -------------------
             4            20606544
    
  2. First we need to put the affected datafiles in the OFFLINE state in the standby database. For this purpose, stop Redo Apply in the standby database, execute the ALTER DATABASE DATAFILE ... OFFLINE statement, and start Redo Apply again:
    SQL> ALTER DATABASE RECOVER MANAGED STANDBY DATABASE CANCEL;
    SQL> ALTER DATABASE DATAFILE 4 OFFLINE FOR DROP;
    SQL> ALTER DATABASE RECOVER MANAGED STANDBY DATABASE USING CURRENT LOGFILE DISCONNECT;
    
  3. Now we'll take incremental backups of the related datafiles by using the FROM SCN keyword. SCN values will be the output of the execution of the queries in the first step. Connect to the primary database as an RMAN target and execute the following RMAN BACKUP statements:
    RMAN> BACKUP INCREMENTAL FROM SCN 20606544 DATAFILE 4 FORMAT '/data/Dbf_inc_%U' TAG 'FOR STANDBY';
    
  4. Copy the backup files from the primary site to the standby site with FTP or SCP:
    scp /data/Dbf_inc_* standbyhost:/data/
    
  5. Connect to the physical standby database as the RMAN target and catalog the copied backup files to the control file with the RMAN CATALOG command:
    RMAN> CATALOG START WITH '/data/Dbf_inc_';
    
  6. In order to put the affected datafiles in the ONLINE state, stop Redo Apply on the standby database, and run the ALTER DATABASE DATAFILE ... ONLINE statement:
    SQL> ALTER DATABASE RECOVER MANAGED STANDBY DATABASE CANCEL;
    SQL> ALTER DATABASE DATAFILE 4 ONLINE;
    
  7. Recover the datafiles by connecting the standby database as the RMAN target. RMAN will use the incremental backup automatically because those files were registered to the control file previously:
    RMAN> RECOVER DATAFILE 4 NOREDO;
    
  8. Now run the query from the first step again to ensure that there're no more datafiles with the NOLOGGING changes:
    SQL> SELECT FILE#, FIRST_NONLOGGED_SCN FROM V$DATAFILE WHERE FIRST_NONLOGGED_SCN > 0;
    
  9. Start Redo Apply on the standby database:
    SQL> ALTER DATABASE RECOVER MANAGED STANDBY DATABASE USING CURRENT LOGFILE DISCONNECT;
    

What just happened?

We've successfully recovered the standby database that didn't include the NOLOGGING changes performed in the primary database. We used the datafile incremental backup method because the number of affected datafiles was small. For a high number of affected datafiles, the method explained in the next section will be more suitable.

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

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