Skip to main content

Dataguard Recovery with RMAN SCN

On Standby:
############

SQL> SELECT CHECKPOINT_CHANGE# FROM v$datafile_header;

CHECKPOINT_CHANGE#
==================
           7691499
           7691499
           7691499
           7691499
           7691499

SQL> select current_scn from v$database;

CURRENT_SCN
===========
    7691498

SQL>

SQL> SELECT ROUND((SYSDATE-MAX(FIRST_TIME))*24,2) "HOURS BEHIND" FROM V$LOG_HISTORY;

HOURS BEHIND
============
        5.5

SQL>




On Prod:
#########

SQL>  SELECT CHECKPOINT_CHANGE# FROM v$datafile_header;

CHECKPOINT_CHANGE#
------------------
           7699591
           7699591
           7699591
           7699591
           7699591

SQL> select current_scn from v$database;

CURRENT_SCN
-----------
    7700211

SQL>


######################################

Take RMAN backup from the SCN generated on the standby.
==========================================================


As per the above query on standby , the current SCN on standby is "7691498"


bash-4.1$ rman target /

Recovery Manager: Release 11.2.0.4.0 - Production on Mon Feb 8 23:07:08 2016

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

connected to target database: PROD (DBID=3428755917)

RMAN> BACKUP DEVICE TYPE DISK INCREMENTAL FROM SCN 7691498 DATABASE  FORMAT '/PRIMARY/arch/RMAN_BACKUP/incr_standby_%U';

Starting backup at 08-FEB-16
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=201 device type=DISK
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00002 name=/PRIMARY/arch/oradata/PROD/sysaux01.dbf
input datafile file number=00001 name=/PRIMARY/arch/oradata/PROD/system01.dbf
input datafile file number=00005 name=/PRIMARY/arch/oradata/PROD/example01.dbf
input datafile file number=00003 name=/PRIMARY/arch/oradata/PROD/undotbs01.dbf
input datafile file number=00004 name=/PRIMARY/arch/oradata/PROD/users01.dbf
channel ORA_DISK_1: starting piece 1 at 08-FEB-16
channel ORA_DISK_1: finished piece 1 at 08-FEB-16
piece handle=/PRIMARY/arch/RMAN_BACKUP/incr_standby_1nqteph1_1_1 tag=TAG20160208T230713 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:25
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 08-FEB-16
channel ORA_DISK_1: finished piece 1 at 08-FEB-16
piece handle=/PRIMARY/arch/RMAN_BACKUP/incr_standby_1oqtephq_1_1 tag=TAG20160208T230713 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
Finished backup at 08-FEB-16

RMAN> exit


Recovery Manager complete.
bash-4.1$

######################################
Change Backup File Permissions:
===============================

bash-4.1$ pwd
/PRIMARY/arch/RMAN_BACKUP
bash-4.1$

bash-4.1$ chmod 777 in*
bash-4.1$ ls -lrt
total 939082
-rwxrwxrwx 1 orPRIMARY dbPRIMARY  37543936 Feb  8  2016 incr_standby_1nqteph1_1_1
-rwxrwxrwx 1 orPRIMARY dbPRIMARY  10616832 Feb  8  2016 incr_standby_1oqtephq_1_1
bash-4.1$

######################################

Copy the backup files to standby server and change the file permissions:
========================================================================

bash-4.1$ pwd
/STANDBY/oracle/manualrecover
bash-4.1$
bash-4.1$ ls -lrt
total 919744
-rwxr-xr-x 1 orSTANDBY dbSTANDBY  37543936 Feb  8  2016 incr_standby_1nqteph1_1_1
-rwxr-xr-x 1 orSTANDBY dbSTANDBY  10616832 Feb  8  2016 incr_standby_1oqtephq_1_1
bash-4.1$
bash-4.1$
bash-4.1$ chmod 777 incr_standby_1*
bash-4.1$
bash-4.1$ ls -lrt
-rwxrwxrwx 1 orSTANDBY dbSTANDBY  37543936 Feb  8  2016 incr_standby_1nqteph1_1_1
-rwxrwxrwx 1 orSTANDBY dbSTANDBY  10616832 Feb  8  2016 incr_standby_1oqtephq_1_1
bash-4.1$

######################################
Catalog the backup files on Standby:
===================================

bash-4.1$ rman target /

Recovery Manager: Release 11.2.0.4.0 - Production on Mon Feb 8 23:09:58 2016

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

connected to target database: STANDBY (DBID=3428755917, not open)

RMAN> catalog start with '/STANDBY/oracle/manualrecover';

using target database control file instead of recovery catalog
searching for all files that match the pattern /STANDBY/oracle/manualrecover

List of Files Unknown to the Database
=====================================
File Name: /STANDBY/oracle/manualrecover/incr_standby_1nqteph1_1_1
File Name: /STANDBY/oracle/manualrecover/incr_standby_1oqtephq_1_1

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

List of Cataloged Files
=======================
File Name: /STANDBY/oracle/manualrecover/incr_standby_1nqteph1_1_1
File Name: /STANDBY/oracle/manualrecover/incr_standby_1oqtephq_1_1

######################################

Recover the database on standby:
=================================


     recover database;     ===> if archives are shipped from primary to standby
           OR
     recover database noredo; ===> if archives are no shipped from primary to standby.
     This will be inconsistent recovery. later on you need to recover the db with archives.


RMAN> recover database;

Starting recover at 08-FEB-16
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=10 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: /STANDBY/arch/oradata/DG/system01.dbf
destination for restore of datafile 00002: /STANDBY/arch/oradata/DG/sysaux01.dbf
destination for restore of datafile 00003: /STANDBY/arch/oradata/DG/undotbs01.dbf
destination for restore of datafile 00004: /STANDBY/arch/oradata/DG/users01.dbf
destination for restore of datafile 00005: /STANDBY/arch/oradata/DG/example01.dbf
channel ORA_DISK_1: reading from backup piece /STANDBY/oracle/manualrecover/incr_standby_1nqteph1_1_1
channel ORA_DISK_1: piece handle=/STANDBY/oracle/manualrecover/incr_standby_1nqteph1_1_1 tag=TAG20160208T230713
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:00:07

starting media recovery

archived log for thread 1 with sequence 407 is already on disk as file /STANDBY/arch/archives/1_407_899716368.dbf
archived log for thread 1 with sequence 408 is already on disk as file /STANDBY/arch/archives/1_408_899716368.dbf
archived log for thread 1 with sequence 409 is already on disk as file /STANDBY/arch/archives/1_409_899716368.dbf
archived log for thread 1 with sequence 410 is already on disk as file /STANDBY/arch/archives/1_410_899716368.dbf
archived log file name=/STANDBY/arch/archives/1_407_899716368.dbf thread=1 sequence=407
archived log file name=/STANDBY/arch/archives/1_408_899716368.dbf thread=1 sequence=408
archived log file name=/STANDBY/arch/archives/1_409_899716368.dbf thread=1 sequence=409
archived log file name=/STANDBY/arch/archives/1_410_899716368.dbf thread=1 sequence=410
unable to find archived log
archived log thread=1 sequence=411
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of recover command at 02/08/2016 23:10:47
RMAN-06054: media recovery requesting unknown archived log for thread 1 with sequence 411 and starting SCN of 7699218

RMAN> exit


Recovery Manager complete.
bash-4.1$


######################################

Check the "CHECKPOINT_CHANGE#" on Standby:
===========================================

SQL>  SELECT CHECKPOINT_CHANGE# FROM v$datafile_header;

CHECKPOINT_CHANGE#
------------------
           7699591
           7699591
           7699591
           7699591
           7699591

SQL>

It should be same as Primary Server or Prod

######################################

Startup the "MRP" process for auto apply of archives on standby:
==================================================================

SQL> RECOVER MANAGED STANDBY DATABASE PARALLEL 4 DISCONNECT FROM SESSION;
Media recovery complete.
SQL>

SQL> SELECT ROUND((SYSDATE-MAX(FIRST_TIME))*24,2) "HOURS BEHIND" FROM V$LOG_HISTORY;

HOURS BEHIND
------------
         .26

SQL>


######################################

Comments

Popular posts from this blog

CLSRSC-430: Failed to start rolling patch mode

############################################################ GRID PSU Failed on Node2: =========================== [root@server1 tmp]# /oracrs/oracle/product/12102/OPatch/opatchauto apply /path1/patches/23273629 -oh /oracrs/oracle/product/12102 -ocmrf /tmp/ocm.rsp OPatch Automation Tool Copyright (c)2014, Oracle Corporation. All rights reserved. OPatchauto Version : 12.1.0.1.10 OUI Version        : 12.1.0.2.0 Running from       : /oracrs/oracle/product/12102 opatchauto log file: /oracrs/oracle/product/12102/cfgtoollogs/opatchauto/23273629/opatch_gi_2016-11-25_06-13-44_deploy.log Parameter Validation: Successful Configuration Validation: Successful Patch Location: /path1/patches/23273629 Grid Infrastructure Patch(es): 21436941 23054246 23054327 23054341 DB Patch(es): 23054246 23054327 The following patch(es) are duplicate patches with patches installed in the Oracle Home.  [ 20299023] You hav...

SQL Plan Management [ SPM ]

============================================= SQL> SHOW parameter baselines NAME                                 TYPE        VALUE ------------------------------------ ----------- ------- optimizer_capture_sql_plan_baselines boolean     FALSE optimizer_use_sql_plan_baselines     boolean     TRUE SQL> ============================================= Connect as SPM user and create a table as follows. -------------------------------------------------- SQL> CREATE TABLE EMPLOYEE (code number,dept char(100),address char(1000)); Table created. SQL> ============================================= Populate some rows in the table =================================== declare c1 number; begin for c1 IN 1..10000 ...