Friday, July 12, 2013

RMAN Incremental Backups to Roll Forward a Physical Standby Database (Lags far behind the primary database)

RMAN incremental backups can be used to sync a physical standby database with the primary database. We can use the RMAN BACKUP INCREMENTAL FROM SCN command to create a backup on the primary database that starts at the current SCN of the standby, which can then be used to roll the standby database forward in time.
So here are the steps,

Stop Redo Apply on the standby database:

SQL> ALTER DATABASE RECOVER MANAGED STANDBY DATABASE CANCEL;

On the standby database, get the SCN for the incremental backup.

SQL> SELECT CURRENT_SCN FROM V$DATABASE;

CURRENT_SCN
-----------
     255797

Connect to the primary database as the RMAN target and create an incremental backup from the current SCN

RMAN> BACKUP INCREMENTAL FROM SCN  255797 DATABASE FORMAT '/tmp/ForStandby_%U' tag 'FORSTANDBY';

The BACKUP commands shown generate datafile backups, as well as a control file backup

If the backup pieces are not on shared storage, then transfer all the backup pieces created on the primary to the standby:

scp /tmp/ForStandby_* standby:/tmp

Connect to the standby database as the RMAN target

RMAN> REPORT SCHEMA;

Connect to the standby database as the RMAN target and apply incremental backups by executing the following commands.

RMAN> STARTUP FORCE NOMOUNT;
RMAN> RESTORE STANDBY CONTROLFILE FROM TAG 'FORSTANDBY';
RMAN> ALTER DATABASE MOUNT;
RMAN> RECOVER DATABASE NOREDO;

Note that the RESTORE STANDBY CONTROLFILE FROM TAG command only works if you are connected to the recovery catalog for the entire process. Otherwise, you must use the RESTORE STANDBY CONTROLFILE FROM '<control file backup filename>' command.

If a recovery catalog is used, then the RMAN RECOVER command will fix the path names for datafiles in the standby control file. If no recovery catalog is used, then you must manually edit the file names in your standby control file or use the RMAN SET NEWNAME command to assign the datafile names.

Start Redo Apply on the physical standby database:

SQL> ALTER DATABASE RECOVER MANAGED STANDBY DATABASE -
> USING CURRENT LOGFILE DISCONNECT FROM SESSION;


ref: :http://docs.oracle.com/cd/E11882_01/server.112/e25608/rman.htm#SBYDB04700

No comments:

Post a Comment