Wednesday, September 10, 2014

Using RMAN Incremental Backup to SYNC Standby Database

Using RMAN Incremental Backup to SYNC Standby Database

Step 1: Create the Incremental Backup
Create the needed incremental backup at the source database, using BACKUP with the INCREMENTAL FROM SCN clause.
Assume that the incremental backup to be used in updating the duplicate database is to be created on disk, with the filenames for backup pieces determined by the format /tmp/incr_for_standby/bkup_%U.

RMAN> BACKUP DEVICE TYPE DISK INCREMENTAL FROM SCN 750983 DATABASE
     FORMAT '/tmp/incr_for_standby/bkup_%U';

Step 2: Make the Incremental Backup Accessible at the Standby Database
Make the backup pieces containing the incremental backup available in some directory accessible on the system containing the standby database. For this example, assume that the destination directory is called /standbydisk1/incrback/ and ensure that it contains nothing besides the incremental backups from Step 1.

Step 3: Catalog the Incremental Backup Files at the Standby Database
Use the RMAN CATALOG command to register the backup sets in the RMAN repository at the duplicate. With an RMAN client connected to the standby database and the recovery catalog (if you use one at the standby), mount the standby and run the following command:
RMAN> CATALOG START WITH '/standbydisk1/incrback/';
The backups are now available for use in recovery of the standby.

Step 4: Apply the Incremental Backup to the Standby Database
Use the RMAN RECOVER command with the NOREDO option to apply the incremental backup to the standby database. All changed blocks captured in the incremental backup are updated at the standby database, bringing it up to date with the primary database. With an RMAN client connected to the standby database, run the following command:
RMAN> RECOVER DATABASE NOREDO;
run
{ allocate channel aux_ch1 device type disk format '/backup/oracle/PWHGVA20/rman/incr/bkup_%U';
    recover database noredo;
 }
Follow this step-by-step procedure to roll forward a physical standby database that has fallen far behind the primary database.
Note: 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 unresolveable archive gap.
select 'backup incremental from scn '||current_scn||'  database format "/backup/oracle/PWHRMN20/rman/INC_FOR_STANDBY_%U.bkp";' from v$database;

1.       On the standby database, query the V$DATABASE view and record the current SCN of the standby database:
SELECT CURRENT_SCN FROM V$DATABASE; CURRENT_SCN -----------      233995
2.       Stop Redo Apply on the standby database:
ALTER DATABASE RECOVER MANAGED STANDBY DATABASE CANCEL;
3.       Connect to the primary database as the RMAN target and create an incremental backup from the current SCN of the standby database that was recorded in step 1:
RMAN> BACKUP INCREMENTAL FROM SCN 233995 DATABASE FORMAT '/tmp/ForStandby_%U' tag 'FOR STANDBY';

Note:
RMAN does not consider the incremental backup as part of a backup strategy at the source database. Hence:
The backup is not suitable for use in a normal RECOVER DATABASE operation at the source database
The backup is not cataloged at the source database
The backup sets produced by this command are written to the /dbs location by default, even if the flash recovery area or some other backup destination is defined as the default for disk backups.
You must create this incremental backup on disk for it to be useful. When you move the incremental backup to the standby database, you must catalog it at the standby as described in Oracle Database Backup and Recovery Advanced User's Guide. Backups on tape cannot be cataloged.

   4. Transfer all backup sets created on the primary system to the standby system (note that there may be more than one backup file created):

      SCP /tmp/ForStandby_* standby:/tmp

   5. Connect to the standby database as the RMAN target, and catalog all incremental backup pieces:

      RMAN> CATALOG START WITH '/tmp/ForStandby_';

   6. Connect to the standby database as the RMAN target and apply incremental backups

      RMAN> RECOVER DATABASE NOREDO;

   7. Remove the incremental backups from the standby system:

      RMAN> DELETE BACKUP TAG 'FOR STANDBY';

   8. Manually remove the incremental backups from the primary system:

      rm /tmp/ForStandby_*

   9. Start Redo Apply on the physical standby database:

No comments:

Post a Comment