- Make sure you stop the managed recovery process (MRP) before going ahead with further steps.
SQL> ALTER DATABASE RECOVER MANAGED STANDBY DATABASE CANCEL;
- On the STANDBY DATABASE, find the SCN which will be used for the incremental backup at the primary database. You need to use the ‘lowest SCN’ from the the 3 queries below :
SQL> SELECT CURRENT_SCN FROM V$DATABASE;
CURRENT_SCN
--------------
2551854
SQL> select min(fhscn) from x$kcvfh;
MIN(FHSCN)
----------------
2551855
SQL> select min(f.fhscn) from x$kcvfh f, v$datafile d
where f.hxfil =d.file#
and d.enabled != 'READ ONLY' ;
MIN(F.FHSCN)
----------------
2551855
- You need to use the ‘lowest SCN‘ from the the 3 queries,In RMAN, connect to the PRIMARY database and create an incremental backup from the SCN derived in the previous step;
RMAN> backup incremental from scn 2551854 database format '/backup/incr/inc_hmprd_%U';
Starting backup at 11-SEP-17
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=114 device type=DISK
backup will be obsolete on date 18-SEP-17
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
input datafile file number=00006 name=+DATA/hmprod_edc/datafile/mgmt_tablespace.270.854660305
input datafile file number=00001 name=+DATA/hmprod/datafile/system.260.854642671
input datafile file number=00002 name=+DATA/hmprod/datafile/sysaux.265.854642671
input datafile file number=00003 name=+DATA/hmprod/datafile/undotbs1.264.854642673
input datafile file number=00007 name=+DATA/hmprod_edc/datafile/mgmt_ad4j_ts.274.854660335
input datafile file number=00005 name=+DATA/hmprod_edc/datafile/mgmt_ecm_depot_ts.267.854660297
input datafile file number=00008 name=+DATA/hmprod_edc/datafile/btest.273.946830037
input datafile file number=00004 name=+DATA/hmprod/datafile/users.263.854642673
channel ORA_DISK_1: starting piece 1 at 11-SEP-17
channel ORA_DISK_1: finished piece 1 at 11-SEP-17
piece handle=/backup/incr/inc_hmprd_94se6sub_1_1 tag=TAG20170911T153329 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:09:38
using channel ORA_DISK_1
backup will be obsolete on date 18-SEP-17
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
including current control file in backup set
channel ORA_DISK_1: starting piece 1 at 11-SEP-17
channel ORA_DISK_1: finished piece 1 at 11-SEP-17
piece handle=/backup/incr/inc_hmprd_95se6tgs_1_1 tag=TAG20170911T153329 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:16
Finished backup at 11-SEP-17
RMAN-08591: WARNING: invalid archived log deletion policy
RMAN>
- Transfer all backup sets created on the primary system to the standby system using SCP or FTP .
- On the STANDBY catalog the backup pieces:
RMAN> catalog start with '/backup/incr/';
using target database control file instead of recovery catalog
searching for all files that match the pattern /backup/incr/
List of Files Unknown to the Database
=====================================
File Name: /backup/incr/inc_hmprd_94se6sub_1_1
File Name: /backup/incr/inc_hmprd_95se6tgs_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: /backup/incr/inc_hmprd_94se6sub_1_1
File Name: /backup/incr/inc_hmprd_95se6tgs_1_1
- Recover the STANDBY database with the cataloged incremental backup then shutdown database and open in nomount mode .
RMAN> recover database noredo;
Starting recover at 11-SEP-17
using channel ORA_DISK_1
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: +DATA/hmprod_ndc/datafile/system.256.854646189
destination for restore of datafile 00002: +DATA/hmprod_ndc/datafile/sysaux.272.854646191
destination for restore of datafile 00003: +DATA/hmprod_ndc/datafile/undotbs1.271.854646191
destination for restore of datafile 00004: +DATA/hmprod_ndc/datafile/users.270.854646191
destination for restore of datafile 00005: +DATA/hmprod_ndc/datafile/mgmt_ecm_depot_ts.264.854660485
destination for restore of datafile 00006: +DATA/hmprod_ndc/datafile/mgmt_tablespace.263.854660517
destination for restore of datafile 00007: +DATA/hmprod_ndc/datafile/mgmt_ad4j_ts.262.854660573
destination for restore of datafile 00008: +DATA/hmprod_ndc/datafile/btest.273.946849219
channel ORA_DISK_1: reading from backup piece /backup/incr/inc_hmprd_94se6sub_1_1
channel ORA_DISK_1: piece handle=/backup/incr/inc_hmprd_94se6sub_1_1 tag=TAG20170911T153329
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:08:36
Finished recover at 11-SEP-17
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 418484224 bytes
Fixed Size 1345352 bytes
Variable Size 335546552 bytes
Database Buffers 75497472 bytes
Redo Buffers 6094848 bytes
- In RMAN, connect to the PRIMARY database and create a standby control file backup and transfer to standby server using scp or ftp.
RMAN> BACKUP CURRENT CONTROLFILE FOR STANDBY FORMAT '/backup/incr/inc_hmprd_controlfile';
Starting backup at 11-SEP-17
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 11-SEP-17
channel ORA_DISK_1: finished piece 1 at 11-SEP-17
piece handle=/backup/incr/inc_hmprd_controlfile tag=TAG20170911T154741 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:03
Finished backup at 11-SEP-17
Starting Control File and SPFILE Autobackup at 11-SEP-17
piece handle=+DATA/autobackup/control_c-281670268-20170911-01 comment=NONE
Finished Control File and SPFILE Autobackup at 11-SEP-17
- Take a backup of location of datafile at standby in case the datafiles name/location are different than the primary.
SQL> spool datafile_names_step8.txt
set lines 200
col name format a60
select file#, name from v$datafile order by file# ;
spool off
- From RMAN, connect to STANDBY database and restore the standby control file , then stop database and start with mount .
RMAN> RESTORE STANDBY CONTROLFILE FROM '/backup/incr/inc_hmprd_controlfile';
Starting restore at 11-SEP-17
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=25 device type=DISK
channel ORA_DISK_1: restoring control file
channel ORA_DISK_1: restore complete, elapsed time: 00:00:01
output file name=+DATA/hmprod_ndc/controlfile/current.257.854646135
Finished restore at 11-SEP-17
RMAN> shutdown;
Oracle instance shut down
RMAN> STARTUP MOUNT;
connected to target database (not started)
Oracle instance started
database mounted
Total System Global Area 418484224 bytes
Fixed Size 1345352 bytes
Variable Size 335546552 bytes
Database Buffers 75497472 bytes
Redo Buffers 6094848 bytes
For record type BACKUP PIECE RECIDS from 5 to 82 are re-used before resync
- Since the controlfile is restored from PRIMARY, the datafile locations in STANDBY controlfile will be same as PRIMARY database, so catalog datafiles in STANDBY will do the necessary rename operations. Perform the below step in STANDBY for each diskgroup where the datafile directory structure between primary and standby are different.
RMAN> CATALOG START WITH '+DATA/HMPROD_NDC/DATAFILE/'
List of Files Unknown to the Database
=====================================
File Name: +data/spfilehmprod.ora
File Name: +data/HMPROD_NDC/TEMPFILE/TEMP.265.854647317
File Name: +data/HMPROD_NDC/ONLINELOG/group_1.261.854646417
File Name: +data/HMPROD_NDC/ONLINELOG/group_2.260.854646431
File Name: +data/HMPROD_NDC/ONLINELOG/group_3.259.854646441
File Name: +data/HMPROD_NDC/ONLINELOG/group_4.258.854646449
File Name: +data/HMPROD_NDC/ONLINELOG/group_5.267.854646461
File Name: +data/HMPROD_NDC/ONLINELOG/group_6.266.854646471
File Name: +data/HMPROD_NDC/DATAFILE/SYSTEM.256.854646189
File Name: +data/HMPROD_NDC/DATAFILE/SYSAUX.272.854646191
File Name: +data/HMPROD_NDC/DATAFILE/UNDOTBS1.271.854646191
File Name: +data/HMPROD_NDC/DATAFILE/USERS.270.854646191
File Name: +data/HMPROD_NDC/DATAFILE/MGMT_ECM_DEPOT_TS.264.854660485
File Name: +data/HMPROD_NDC/DATAFILE/MGMT_TABLESPACE.263.854660517
File Name: +data/HMPROD_NDC/DATAFILE/MGMT_AD4J_TS.262.854660573
File Name: +data/HMPROD_NDC/DATAFILE/BTEST.273.946849219
File Name: +data/HMPROD_NDC/CONTROLFILE/Current.269.854646135
Do you really want to catalog the above files (enter YES or NO)? YES
cataloging files...
cataloging done
List of Cataloged Files
=======================
File Name: +data/HMPROD_NDC/TEMPFILE/TEMP.265.854647317
File Name: +data/HMPROD_NDC/DATAFILE/SYSTEM.256.854646189
File Name: +data/HMPROD_NDC/DATAFILE/SYSAUX.272.854646191
File Name: +data/HMPROD_NDC/DATAFILE/UNDOTBS1.271.854646191
File Name: +data/HMPROD_NDC/DATAFILE/USERS.270.854646191
File Name: +data/HMPROD_NDC/DATAFILE/MGMT_ECM_DEPOT_TS.264.854660485
File Name: +data/HMPROD_NDC/DATAFILE/MGMT_TABLESPACE.263.854660517
File Name: +data/HMPROD_NDC/DATAFILE/MGMT_AD4J_TS.262.854660573
File Name: +data/HMPROD_NDC/DATAFILE/BTEST.273.946849219
- Switch the datafiles to its correct names at the standby site :
RMAN> SWITCH DATABASE TO COPY;
datafile 1 switched to datafile copy "+DATA/hmprod_ndc/datafile/system.256.854646189"
datafile 2 switched to datafile copy "+DATA/hmprod_ndc/datafile/sysaux.272.854646191"
datafile 3 switched to datafile copy "+DATA/hmprod_ndc/datafile/undotbs1.271.854646191"
datafile 4 switched to datafile copy "+DATA/hmprod_ndc/datafile/users.270.854646191"
datafile 5 switched to datafile copy "+DATA/hmprod_ndc/datafile/mgmt_ecm_depot_ts.264.854660485"
datafile 6 switched to datafile copy "+DATA/hmprod_ndc/datafile/mgmt_tablespace.263.854660517"
datafile 7 switched to datafile copy "+DATA/hmprod_ndc/datafile/mgmt_ad4j_ts.262.854660573"
datafile 8 switched to datafile copy "+DATA/hmprod_ndc/datafile/btest.273.946849219"
- On standby database, clear all standby redo log groups and start MRP .
SQL> ALTER DATABASE CLEAR LOGFILE GROUP [group no];
Database altered.
SQL> RECOVER MANAGED STANDBY DATABASE DISCONNECT FROM SESSION;
Media recovery complete.