Sunday, 20 November 2016

Resolving Archive gap Standby Database Using Incremental RMAN(using SCN)

Resolving Archive gap Standby Database Using Incremental RMAN(using SCN)

If you find huge gap between standby and primary, and your primary site does not have archives, your backup script deleted the archives.
In this scenario we can use SCN based incremental backup to sync the standby.

Standby site

Cancel the managed recovery operation on the standby site

SQL> alter database recover managed standby database cancel;
SQL> select current_scn from v$database;

CURRENT_SCN
-----------
     507189
SQL> shutdown immediate

Primary site

Switch to the primary site and change the log_archive_dest_2 initialization parameter and take an incremental backup of the database using the scn value that has been taken from the standby database:

Sql>alter system set LOG_ARCHIVE_DEST_STATE_2=defer;
System altered

RMAN> backup incremental from scn 507189 database format='/u02/rman_backup/incremental/incr_backup_%U';

Create the standby controlfile and switch the current redo log file:

SQL>alter database create standby controlfile as '/u01/rman_backup/standby_control.ctl';

SQL> alter system switch logfile;
System altered.

Copy the standby controlfile and incremental backup file to the standby side, start up the standby database in nomount modeand change the parameter file to make the instance use the standby controlfile:

Standby site

Assume we have copied to /u01/rman_backup/ Location

SQL> alter system set control_files='/u01/rman_backup/standby_control.ctl' scope=spfile;
System altered.

Alternate to above step, we can replace the existing controlfiles with the standby_control.ctl by renaming it to corresponding name.

SQL> shutdown immediate
SQL> startup nomount

Mount the standby database and catalog the incremental backup to its repository:

SQL> alter database mount standby database;

RMAN> catalog backuppiece'/u01/rman_backup/incr_backup_1mlfj8pq_1_1';

Now, recover the database using incremental backup:

RMAN> recover database;
channel ORA_DISK_1: starting incremental datafile backupset restore
channel ORA_DISK_1: reading from backup piece /u02/rman_backup/
incr_backup_1mlfj8pq_1_1
channel ORA_DISK_1: restored backup piece 1
piece handle=/u02/rman_backup/incr_backup_1mlfj8pq_1_1
tag=TAG20100606T224202
channel ORA_DISK_1: restore complete, elapsed time: 00:00:02

starting media recovery

archive log thread 1 sequence 58 is already on disk as file
/u01/oracle/product/10.2.0/db_1/flash_recovery_area/TEST/archivelog/
2010_06_07/o1_mf_1_58_60s4sjbc_.arc
archive log
filename=/u01/oracle/product/10.2.0/db_1/flash_recovery_area/TEST/
rchivelog/2010_06_07/o1_mf_1_58_60s4sjbc_.arc
thread=1 sequence=58
unable to find archive log
archive log thread=1 sequence=59
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of recover command at 06/07/2010 02:38:36
RMAN-06054: media recovery requesting unknown log: thread 1 seq 59 lowscn 508306
RMAN> exit

Now switch to the standby database and run the recover standby database command.  RMAN will look for the next archived redo log file and apply it automatically:

SQL> recover standby database;

Then query the current scn value on the standby database

SQL> select current_scn from v$database;

CURRENT_SCN
-----------
     511301

Now start redo apply process on standby

SQL>ALTER DATABASE RECOVER MANAGED STANDBY DATABASE DISCONNECT FROM SESSION;









No comments:

Post a Comment