Sunday, January 27, 2019

Roll Forward a standby database using RMAN incremental backups


If a physical standby database has lost or corrupted archived redo data or has an unresolvable archive gap which could also due to archive logs getting missed out on the primary database or the archives getting corrupted and there would be no valid backups to recover.

If archive exist on primary, Troubleshoot the issue, it will automatically be shipped if the archive is not corrupted.

 If archive is corrupted at OS level and if we do have backup, then restore archive log from Backup.
If above both options don’t work, then we can recover standby with Incremental SCN for standby/ Roll Forward.




How does it work ::
================
Using the RMAN BACKUP INCREMENTAL FROM SCN command, you can create a backup on the primary database that starts at the standby database's current SCN, which can then be used to roll the standby database forward in time.

Record the SCN gap between Standby and Source i.e., production database.
SQL> select status,instance_name,database_role from v$database,v$instance;

STATUS       INSTANCE_NAME    DATABASE_ROLE
------------ ---------------- ----------------
MOUNTED      PSTLI            PHYSICAL STANDBY

SQL> SELECT to_char(CURRENT_SCN) FROM V$DATABASE;
CURRENT_SCN
-------------
5997422841600

Primary::
SQL> select status,instance_name,database_role from v$database,v$instance;
STATUS       INSTANCE_NAME    DATABASE_ROLE
------------ ---------------- ----------------
OPEN          PSTLI             PRIMARY

SQL> SELECT to_char(CURRENT_SCN) FROM V$DATABASE;
CURRENT_SCN

-------------
5997428587053

Take the incremental SCN backup that starts at the standby database's current SCN and create the standby control file backup.

rman target /

RMAN>BACKUP INCREMENTAL FROM SCN 5997422841600 DATABASE FORMAT '/u01/***/stage/TEMP/DBDR_%U' tag 'ArchiveGap';
Starting backup at 25-MAR-18

channel ORA_DISK_1: starting full datafile backup set

channel ORA_DISK_1: specifying datafile(s) in backup set

including current control file in backup set

channel ORA_DISK_1: starting piece 1 at 25-MAR-18

channel ORA_DISK_1: finished piece 1 at 25-MAR-18

piece handle=/u01/**/stage/TEMP/ DBDR123.bak tag= ArchiveGap comment=NONE

channel ORA_DISK_1: backup set complete, elapsed time: 00:00:03

Finished backup at 25-MAR-18

Step 2: create the standby controlfile backup on primary.
RMAN> backup current controlfile for standby format ='/u01/**/stage/TEMP/standby_control.bctl';
Step 3: Transfer the backups from the Primary Server to the Standby and catalog them.
Step 4: On Standby database.
  rman target /

Recovery Manager: Release 11.2.0.1.0 - Production on Sun Mar 2515:51:02 2012
Copyright (c) 1982, 2009, Oracle and/or its affiliates.  All rights reserved.
connected to target database: PSTLI (DBID=431934829, not open)

RMAN> catalog start with ‘/u01/archives/stage/temp/’;  
This will catalog all the backup pieces and our control file.
Now Recover the standby database with the cataloged incremental backup pieces.
RMAN> RECOVER DATABASE NOREDO;
Shutdown the physical standby database, start it in nomount stage and restore the standby controlfile backup that we had taken from the primary database.
RMAN> shutdown immediate
database dismounted
Oracle instance shut down

RMAN> startup nomount
connected to target database (not started)
Oracle instance started

Total System Global Area     659730432 bytes
Fixed Size                     2216264 bytes

Variable Size                398462648 bytes

Database Buffers             255852544 bytes

Redo Buffers                   3198976 bytes

RMAN> restore standby controlfile from ‘/u01/archives/stage/temp/standby_control.bctl’; 

Finished restore at 25-MAR-18

Shutdown the standby database and mount the standby database, so that the standby database would be mounted with the new control file that was restored in the previous step.

Now standby database is in sync with the Primary Database


Thanks.
Sreeharsha











No comments:

Post a Comment