Recover Oracle Standby Dataguard with RMAN

Recover Standby dataguard database with RMAN

Data guard is configured in Oracle for Creating physical or logical standby Server for disaster recovery. If primary database is failed somehow the standby server is used to minimal the downtown for the application and users. Suppose if database is large enough then recover operation will take time during operation windows which may caused heavy lost. It reduce the downtime and switch to standby server for operations.

Check Gap with following SQL:

Select THREAD#,LOW_SEQUENCE#,HIGH_SEQUENCE# From V$ARCHIVE_GAP;

Resolve the archival gap between primary and standby database with help of RMAN. Otherwise rebuild the complete DR from Scratch.

1. Find the last SCN on primary and standby database.

PRIMARY
SQL> SELECT CURRENT_SCN FROM V$DATABASE;
CURRENT_SCN
-----------
3360225821

STANDBY
SQL> SELECT CURRENT_SCN FROM V$DATABASE;
CURRENT_SCN
-----------
3215410716

2. Stop log apply and transport services.

2.1 Stop redo sent on primary
alter system set log_archive_dest_state_2 ='defer' scope=both;

2.2 Stop redo apply on standby
ALTER DATABASE RECOVER MANAGED STANDBY DATABASE CANCEL;

3. Take Incremental backup of primary database from last applied SCN on standby database.
–for faster backup try with multi channel

run {
allocate channel ch1 device type disk;
allocate channel ch2 device type disk;
allocate channel ch3 device type disk;
BACKUP INCREMENTAL FROM SCN 3215410716 DATABASE FORMAT '/u05/db/backup/ForStandbyrecover_%U' tag 'FORSTANDBY';
release channel ch1;
release channel ch2;
release channel ch3;
}

4. Transfer backup to standby server.
Because the incremental backup was 1 TB size. I needed to separate under different mount points.
Don’t worry about keeping them in different folders. We will register them.

SOURCE FOLDER : /backup/
DEST FOLDER : /backupDG/

5. Register backup sets to standby database.
On Standby database:

RMAN target /
RMAN> CATALOG START WITH '/backupDG/ForStandbyrecover';

6. Start recover process for the standby database.
One important note:
Because this is a backup taken for only physical standby database with noredo keyword is required.
See Reference: http://download.oracle.com/docs/cd/B19306_01/backup.102/b14191/rcmdupdb.htm#sthref955

RMAN>
run {
allocate channel ch1 device type disk;
allocate channel ch2 device type disk;
allocate channel ch3 device type disk;
RECOVER DATABASE NOREDO;
release channel ch1;
release channel ch2;
release channel ch3;
}

7. Create new standby control file.
Before re-starting log apply service on standby database. create a new standby control file in primary database, copy it to standby. Creating a new control file is my suggestion because during non transferred and applied logs. Some change may be done affecting control file like adding redo members, adding datafile, adding new ,tablespaces…etc

7-1 Shutdown Standby database instance.

7-2 Create new standby control file move it to standby side destinations (generally 3).
SQL> alter database create standby controlfile as '/u05/stby.ctl'; --on primary
scp /u05/stby.ctl oracle@stdbyserver:/oradata/ctl/ctl.dbf

7-3 Start standby database in mount state
SQL> startup mount;

 
8. OPTIONAL – Transfer newly created files.
If new data files were added on primary database during the time that data-guard services is not working then you need to copy the newly created data files because it is not included in incremental backup set.

8-1 Determine all data files from database (remember we have just created a new control file , both primary and standby has same information)

On primary and standby:

SQL> select name from v$datafile;

Compare the datafiles if not matched then take backup of missing file which is not present in standby server
Support following file is not present in standby server:
/oradata/ORCL004.dbf : cannot open
/oradata/ORCL005.dbf : cannot open
Means we have to copy these 2 files to standby side.

8-2 Backup them as image copy in primary database and copy to standby side.
BACKUP AS COPY DATAFILE '/oradata/ORCL004.dbf' FORMAT '/tmp/ORCL004.dbf' TAG stdbyImgCopy;
BACKUP AS COPY DATAFILE '/oradata/ORCL005.dbf' FORMAT '/tmp/ORCL005.dbf' TAG stdbyImgCopy;

scp /tmp/ORCL004.dbf oracle@stdbyserver:/oradata/ORCL004.dbf
scp /tmp/ORCL005.dbf oracle@stdbyserver:/oradata/ORCL005.dbf

9. Restart log apply and transfer services.

9-1 Start redo sent on primary
alter system set log_archive_dest_state_2 ='enable' scope=both ;

9-2 Start redo apply on standby and start log apply service (Managed Recovery Process).
SQL> startup mount;
SQL>ALTER DATABASE RECOVER MANAGED STANDBY DATABASE DISCONNECT FROM SESSION;

9-3 check if for any problems; you may encounter problems. Check alert.log and status of processes
SQL> SELECT PROCESS, STATUS, THREAD#, SEQUENCE#, BLOCK#, BLOCKS FROM V$MANAGED_STANDBY;

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

w

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.