Oracle Standby Recovery using incremental backup taken based on SCN with Logs

Step 1: Take a note of Current SCN of DRC
Select current_scn from V$database;
C:\Users\Administrator>sqlplus sys@testdbdr as sysdba

SQL*Plus: Release 11.2.0.1.0 Production on Thu Nov 19 20:37:57 2015

Copyright (c) 1982, 2010, Oracle.  All rights reserved.

Enter password:
Connected to an idle instance.

SQL> select name, open_mode from v$database;
select name, open_mode from v$database
*
ERROR at line 1:
ORA-01034: ORACLE not available
Process ID: 0
Session ID: 0 Serial number: 0


SQL> shut immediate
ORA-01034: ORACLE not available
ORA-27101: shared memory realm does not exist
SQL> startup nomount
ORACLE instance started.

Total System Global Area 1.3696E+10 bytes
Fixed Size                  2188768 bytes
Variable Size            7381977632 bytes
Database Buffers         6274678784 bytes
Redo Buffers               37044224 bytes
SQL> Alter database mount standby database;

Database altered.

SQL> select name, open_mode from v$database;

NAME      OPEN_MODE
--------- --------------------
testdbdr  MOUNTED

SQL> select name, open_mode, database_role from v$database;

NAME      OPEN_MODE            DATABASE_ROLE
--------- -------------------- ----------------
testdbdr  MOUNTED              PHYSICAL STANDBY

SQL> SELECT ARCH.THREAD# "Thread", ARCH.SEQUENCE# "Last Sequence Received", APPL
.SEQUENCE# "Last Sequence Applied", (ARCH.SEQUENCE# - APPL.SEQUENCE#)
  2  "Difference" FROM (SELECT THREAD# ,SEQUENCE# FROM V$ARCHIVED_LOG WHERE (THR
EAD#,FIRST_TIME )
  3  IN (SELECT THREAD#,MAX(FIRST_TIME) FROM V$ARCHIVED_LOG GROUP BY THREAD#)) A
RCH, (SELECT THREAD# ,SEQUENCE#
  4  FROM V$LOG_HISTORY WHERE (THREAD#,FIRST_TIME ) IN (SELECT THREAD#,MAX(FIRST
_TIME) FROM V$LOG_HISTORY GROUP BY THREAD#)) APPL
  5  WHERE ARCH.THREAD# = APPL.THREAD# ORDER BY 1;

    Thread Last Sequence Received Last Sequence Applied Difference
---------- ---------------------- --------------------- ----------
         1                 131244                 76248      54996

SQL> Select to_char(current_scn,'9999999999999999999')  from V$database;

TO_CHAR(CURRENT_SCN,
--------------------
        896667980266

Note – This SCN will be used to take incremental backup from Primary.


Step 2 : Cancel MRP process
Alter database recover managed standby database cancel;
Step 3: On DC take the incremental SCN backup
DC Database:
Rman target  sys/password@orcl
RMAN > Backup incremental  from scn 919977552769 database format  ‘f:/inc_bkp1/stnd_backup_%U.back’;
Step 3

E:\app\Administrator\product\11.2.0\dbhome_2\BIN>set ORACLE_SID=testdbprd

E:\app\Administrator\product\11.2.0\dbhome_2\BIN>sqlplus / as sysdba

SQL*Plus: Release 11.2.0.1.0 Production on Thu Nov 19 20:48:02 2015

Copyright (c) 1982, 2010, Oracle.  All rights reserved.


Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL> select name, open_mode, database_role from v$database;

NAME      OPEN_MODE            DATABASE_ROLE
--------- -------------------- ----------------
testdbprd  READ WRITE           PRIMARY

SQL> Select to_char(current_scn,'9999999999999999999') from V$database;

TO_CHAR(CURRENT_SCN,
--------------------
        919173193631

E:\app\Administrator\product\11.2.0\dbhome_2\BIN>rman target /

Recovery Manager: Release 11.2.0.1.0 - Production on Thu Nov 19 20:45:25 2015

Copyright (c) 1982, 2009, Oracle and/or its affiliates.  All rights reserved.

connected to target database: testdbprm (DBID=184840561)

RMAN> Backup incremental  from scn 896667980266 database format "f:/inc_bkp_test/
stnd_backup_%U.back";

Starting backup at 19-NOV-15

using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=151 device type=DISK
backup will be obsolete on date 26-NOV-15
archived logs will not be kept or backed up
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
-------
-------
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:03
Finished backup at 20-NOV-15

Steps  4: Connect to Dc and create a standby control file backup
Rman> backup current controlfile for standby format “f:/std_ctl.ctl”;
RMAN> backup current controlfile for standby format "f:/test_std_ctl.ctl";

Starting backup at 20-NOV-15
using channel ORA_DISK_1
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
including standby control file in backup set
channel ORA_DISK_1: starting piece 1 at 20-NOV-15
channel ORA_DISK_1: finished piece 1 at 20-NOV-15
piece handle=F:\test_STD_CTL.CTL tag=TAG20151120T154849 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:15
Finished backup at 20-NOV-15

Starting Control File and SPFILE Autobackup at 20-NOV-15
piece handle=F:\RMAN_BKP_test\AUTOBACKUP_CONTROL_FILEC-184840561-20
151120-00 comment=NONE
Finished Control File and SPFILE Autobackup at 20-NOV-15


Steps 5: Transfer the backup from DC to DRC (Same location) (‘u01/bkp’)
Steps 6 : DRC database:
Rman target  sys/password@
RMAN> catalog start with “f:/inc_bkp”;
Steps 7: Recover the standby database with the cataloged incremental backup pieces.
RMAN> recover database noredo;
Step 6 & 7

C:\Users\Administrator>rman target sys@testdbdr

Recovery Manager: Release 11.2.0.1.0 - Production on Fri Nov 20 18:00:52 2015

Copyright (c) 1982, 2009, Oracle and/or its affiliates.  All rights reserved.

target database Password:
connected to target database: testdbdr (DBID=184840561, not open)

RMAN> catalog start with "f:/inc_bkp_test";

using target database control file instead of recovery catalog
searching for all files that match the pattern f:/inc_bkp_test

List of Files Unknown to the Database
=====================================
File Name: F:\inc_bkp_test\STND_BACKUP_A1QMMAQM_10_1.BACK
File Name: F:\inc_bkp_ test \STND_BACKUP_A1QMMAQM_11_1.BACK
File Name: F:\inc_bkp_test\STND_BACKUP_A1QMMAQM_12_1.BACK
File Name: F:\inc_bkp_test\STND_BACKUP_A1QMMAQM_13_1.BACK
File Name: F:\inc_bkp_test\STND_BACKUP_A1QMMAQM_14_1.BACK
File Name: F:\inc_bkp_test\STND_BACKUP_A1QMMAQM_15_1.BACK
File Name: F:\inc_bkp_test\STND_BACKUP_A1QMMAQM_16_1.BACK
File Name: F:\inc_bkp_test\STND_BACKUP_A1QMMAQM_17_1.BACK
File Name: F:\inc_bkp_test\STND_BACKUP_A1QMMAQM_1_1.BACK
File Name: F:\inc_bkp_test\STND_BACKUP_A1QMMAQM_2_1.BACK
File Name: F:\inc_bkp_test\STND_BACKUP_A1QMMAQM_3_1.BACK
File Name: F:\inc_bkp_test\STND_BACKUP_A1QMMAQM_4_1.BACK
File Name: F:\inc_bkp_test\STND_BACKUP_A1QMMAQM_5_1.BACK
File Name: F:\inc_bkp_test\STND_BACKUP_A1QMMAQM_6_1.BACK
File Name: F:\inc_bkp_test\STND_BACKUP_A1QMMAQM_7_1.BACK
File Name: F:\inc_bkp_test\STND_BACKUP_A1QMMAQM_8_1.BACK
File Name: F:\inc_bkp_test\STND_BACKUP_A1QMMAQM_9_1.BACK
File Name: F:\inc_bkp_test\STND_BACKUP_A2QMMV52_1_1.BACK

Do you really want to catalog the above files (enter YES or NO)? y
cataloging files...
cataloging done

List of Cataloged Files
=======================
File Name: F:\inc_bkp_test\STND_BACKUP_A1QMMAQM_10_1.BACK
File Name: F:\inc_bkp_test\STND_BACKUP_A1QMMAQM_11_1.BACK
File Name: F:\inc_bkp_test\STND_BACKUP_A1QMMAQM_12_1.BACK
File Name: F:\inc_bkp_test\STND_BACKUP_A1QMMAQM_13_1.BACK
File Name: F:\inc_bkp_test\STND_BACKUP_A1QMMAQM_14_1.BACK
File Name: F:\inc_bkp_test\STND_BACKUP_A1QMMAQM_15_1.BACK
File Name: F:\inc_bkp_test\STND_BACKUP_A1QMMAQM_16_1.BACK
File Name: F:\inc_bkp_test\STND_BACKUP_A1QMMAQM_17_1.BACK
File Name: F:\inc_bkp_test\STND_BACKUP_A1QMMAQM_1_1.BACK
File Name: F:\inc_bkp_test\STND_BACKUP_A1QMMAQM_2_1.BACK
File Name: F:\inc_bkp_test\STND_BACKUP_A1QMMAQM_3_1.BACK
File Name: F:\inc_bkp_test\STND_BACKUP_A1QMMAQM_4_1.BACK
File Name: F:\inc_bkp_test\STND_BACKUP_A1QMMAQM_5_1.BACK
File Name: F:\inc_bkp_test\STND_BACKUP_A1QMMAQM_6_1.BACK
File Name: F:\inc_bkp_test\STND_BACKUP_A1QMMAQM_7_1.BACK
File Name: F:\inc_bkp_test\STND_BACKUP_A1QMMAQM_8_1.BACK
File Name: F:\inc_bkp_test\STND_BACKUP_A1QMMAQM_9_1.BACK
File Name: F:\inc_bkp_test\STND_BACKUP_A2QMMV52_1_1.BACK

RMAN> recover database noredo;

Starting recover at 20-NOV-15
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=8 device type=DISK
channel ORA_DISK_1: starting incremental datafile backup set restore
channel ORA_DISK_1: specifying datafile(s) to restore from backup set
destination for restore of datafile 00001: E:\ORACLE\ORADATA\testdbdr\SYSTEM01
.DBF
--------
-------
channel ORA_DISK_1: reading from backup piece F:\INC_BKP_test\STND_BACKUP_A1QMMAQ
M_1_1.BACK
channel ORA_DISK_1: piece handle=F:\INC_BKP_test\STND_BACKUP_A1QMMAQM_1_1.BACK ta
g=TAG20151119T205113
channel ORA_DISK_1: restored backup piece 1
---------
---------
channel ORA_DISK_1: restored backup piece 17
channel ORA_DISK_1: restore complete, elapsed time: 02:06:27

Finished recover at 20-NOV-15

Steps 8: Shutdown the DRC database, start in nomount stage and restore the standby control file backup
DRC database :
RMAN>  shutdown immediate;
RMAN > startup nomount;
RMAN > restore standby controlfile from “f:/std_ctl.ctl”;
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   13695889408 bytes
Fixed Size                     2188768 bytes
Variable Size               7381977632 bytes
Database Buffers            6274678784 bytes
Redo Buffers                  37044224 bytes
RMAN> restore standby controlfile from "f:/test_std_ctl.ctl";
Starting restore at 20-NOV-15
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=63 device type=DISK
channel ORA_DISK_1: restoring control file
channel ORA_DISK_1: restore complete, elapsed time: 00:00:03
output file name=E:\ORACLE\ORADATA\testdbdr\STANDBY_CTL_test_01.CTL
output file name=E:\ORACLE\ORACLE_BASE\FLASH_RECOVERY_AREA\testdbdr\STANDBY_CT
L_CBNRTPRD_02.CTL
Finished restore at 20-NOV-15
Steps 9
RMAN> shutdown immediate;
RMAN> startup mount;




RMAN> shutdown immediate

Oracle instance shut down

RMAN> startup mount

connected to target database (not started)
Oracle instance started
database mounted

Total System Global Area   13695889408 bytes

Fixed Size                     2188768 bytes
Variable Size               7381977632 bytes
Database Buffers            6274678784 bytes
Redo Buffers                  37044224 bytes
For record type BACKUP PIECE RECIDS from 176 to 244 are re-used before resync
For record type DELETED OBJECT RECIDS from 7761 to 16591 are re-used before resy
nc


Step 10: MRP on and Check sync status
C:\Users\Administrator>sqlplus sys@testdbdr as sysdba

SQL*Plus: Release 11.2.0.1.0 Production on Fri Nov 20 20:20:42 2015

Copyright (c) 1982, 2010, Oracle.  All rights reserved.

Enter password:

Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL> SELECT ARCH.THREAD# "Thread", ARCH.SEQUENCE# "Last Sequence Received", APPL
.SEQUENCE# "Last Sequence Applied", (ARCH.SEQUENCE# - APPL.SEQUENCE#)
  2  "Difference" FROM (SELECT THREAD# ,SEQUENCE# FROM V$ARCHIVED_LOG WHERE (THR
EAD#,FIRST_TIME )
  3  IN (SELECT THREAD#,MAX(FIRST_TIME) FROM V$ARCHIVED_LOG GROUP BY THREAD#)) A
RCH, (SELECT THREAD# ,SEQUENCE#
  4  FROM V$LOG_HISTORY WHERE (THREAD#,FIRST_TIME ) IN (SELECT THREAD#,MAX(FIRST
_TIME) FROM V$LOG_HISTORY GROUP BY THREAD#)) APPL
  5  WHERE ARCH.THREAD# = APPL.THREAD# ORDER BY 1
  6  /

    Thread Last Sequence Received Last Sequence Applied Difference
---------- ---------------------- --------------------- ----------
         1                 131902                131713        189

SQL> alter database recover managed standby database disconnect from session;

Database altered.

Step 11: At DC  - Switch Logfile
E:\app\Administrator\product\11.2.0\dbhome_2\BIN>set ORACLE_SID=testdbprd

E:\app\Administrator\product\11.2.0\dbhome_2\BIN>sqlplus / as sysdba

SQL*Plus: Release 11.2.0.1.0 Production on Fri Nov 20 20:30:32 2015

Copyright (c) 1982, 2010, Oracle.  All rights reserved.


Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL> alter system switch logfile;

System altered.

SQL> /

System altered.

SQL> /

System altered.





Comments