RSS

Tag Archives: RMAN gap resolve

Gaps Resolving in DataGuard Physical Standby Using RMAN Incremental Backup

1) defer log transfer from Primary Database
SQL>alter system set log_archive_dest_state_2=’DEFER’ scope=MEMORY;

2) record last sequence from Primary and Standby
SQL> archive log list;
or use sql:
SQL> SELECT ARCH.THREAD# “Thread”, ARCH.SEQUENCE# “Last Sequence Received”, APPL.SEQUENCE# “Last Sequence Applied”, (ARCH.SEQUENCE# – APPL.SEQUENCE#) “Difference” FROM (SELECT THREAD# ,SEQUENCE# FROM V$ARCHIVED_LOG WHERE (THREAD#,FIRST_TIME ) IN (SELECT THREAD#,MAX(FIRST_TIME) FROM V$ARCHIVED_LOG GROUP BY THREAD#))ARCH, (SELECT THREAD# ,SEQUENCE# FROM V$LOG_HISTORY WHERE (THREAD#,FIRST_TIME ) IN (SELECT THREAD#,MAX(FIRST_TIME) FROM V$LOG_HISTORY GROUP BY THREAD#)) APPL WHERE ARCH.THREAD# = APPL.THREAD# ORDER BY 1;

3) record last SCN
SQL> select to_char(current_scn) from v$database;
e.g.:
Primary==> 5973814619607
Standby==> 5973624753925

you can also know when the gap happens by:
SQL>select scn_to_timestamp(5973624753925) from dual;

4) stop log apply on Standby
SQL>alter database recover managed standby database cancel;

5)Perform Rman Incremental backup from Primary database to backup the gap starting from Standby SCN
RMAN>run {
allocate channel c1 type disk format ‘/tmp/gapresolve/%U.rmb’;
backup incremental from scn 5973624753925 database;
}

6) Take a buckup from the current Primary Control file
SQL>alter database create standby controlfile as ‘/tmp/gapresolve_standby.ctl’;
7) transfer the backup spices and control file to Standby machine
$scp file user@machine:/directory
$scp /tmp/gapresolve/*.rmb oracle@sdbypc:/tmp/gapresolve/

8)start Standby db
SQL>startup nomount

9) allocate Standby database control file
SQL>show parameter control_files
==> /oracle_home/dbs/stdbycontrol.dbf

10)replace it with Primary backed up control file
$cp /tmp/gapresolve_standby.ctl /oracle_home/dbs/stdbycontrol.dbf
10) mount Standy database in standby state
SQL>alter database mount standby database;

11)start rman on standby
$rman target=/

12)catalog backup spices
RMAN>catalog start with ‘/tmp/gapresolve’;

13) recover the database
RMAN>recover database;

14) in some new created datafile need to be restored first, so a error massage came:
RMAN-03002: failure of recover command at 08/23/2014 12:41:19
RMAN-06094: datafile 61 must be restored
so just restore that file by:
RMAN>restore datafile 61;

15) rman recovery ends with and error that requesting current log file, we can ignore this error

16) on Standby database, check the current SCN
SQL> select to_char(current_scn) from v$database;

17) on Standby database, resume log apply
SQL> alter database recover managed standby database disconnect from session;

18) on Primary, resume log transfer
alter system set log_archive_dest_state_2=’ENABLE’ scope=MEMORY;

19)frequently check the scn
SQL> select to_char(current_scn) from v$database;

 
 

Tags: , , , , ,