<<Back to Oracle DataGuard Main Page
How to Roll Forward a standby database using RMAN incremental backup oracle
to roll forward the standby database suing RMAN incremental backup from primary, the first thing which you have to find out is the correct SCN number to take the incremental backupStep1> Find the correct SCN from Standby for Incremental Backup
How to find the correct SCN for Incremental backup to Roll Forward a standby database
On Standby databaseSQL> select current_scn from v$database
CURRENT_SCN
------------------
52336213728
Check The minimum SCN from x$kcvfh
SQL> select min(fhscn) from x$kcvfh;
MIN(FHSCN)
----------------
52315851745
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)
----------------
52334553164
The lowest SCN from all 3 above is your target (in my case it is 52334553164). Just take this one and perform the incremental backup on primary database from this SCN. To cross verify you can optionally do following
Stop the managed recovery at standby database
SQL> recover managed standby database cancel;
Start the manual recovery to verify the SCN again
SQL> recover standby database;
ORA-00279: change 52334553164 generated at 12/11/2018 15:26:19 needed for
thread 2
ORA-00289: suggestion :
/u01/app/oracle/product/12.1.0.2/dbp1/dbs/arch2_1503_965052383.dbf
ORA-00280: change 52334553164 for thread 2 is in sequence #1503
As you can see the standby database is looking the redo from SCN 52334553164 which is exactly the SCN you identified above
Step2: Perform the Incremental Backup from the SCN identified above
connect to the PRIMARY database and create an incremental backup
$rman target /
RMAN > BACKUP INCREMENTAL FROM SCN 52334553164 DATABASE FORMAT '/tmp/ForStandby_%U' tag 'FORSTANDBY';
Step3: Transfer the backup pieces to standby database server
Transfer all backup sets created on the primary database server to the standby.
In my case I copied the backup pieces on standby at /u01/app/oracle/stage/bkp/bkp/ location
Step4: Catalog the backup pieces
On the STANDBY catalog the backup pieces:
$rman target /
RMAN> CATALOG START WITH '/u01/app/oracle/stage/bkp/bkp/';
using target database control file instead of recovery catalog
searching for all files that match the pattern /u01/app/oracle/stage/bkp/bkp/
List of Files Unknown to the Database
=====================================
File Name: /u01/app/oracle/stage/bkp/bkp/ForStandby_tntklsc0_1_1
File Name: /u01/app/oracle/stage/bkp/bkp/ForStandby_tmtklsbt_1_1
File Name: /u01/app/oracle/stage/bkp/bkp/ForStandby_trtklsce_1_1
File Name: /u01/app/oracle/stage/bkp/bkp/ForStandby_totklsc7_1_1
File Name: /u01/app/oracle/stage/bkp/bkp/ForStandby_tptklsca_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: /u01/app/oracle/stage/bkp/bkp/ForStandby_tntklsc0_1_1
File Name: /u01/app/oracle/stage/bkp/bkp/ForStandby_tmtklsbt_1_1
File Name: /u01/app/oracle/stage/bkp/bkp/ForStandby_trtklsce_1_1
File Name: /u01/app/oracle/stage/bkp/bkp/ForStandby_totklsc7_1_1
File Name: /u01/app/oracle/stage/bkp/bkp/ForStandby_tptklsca_1_1
Step5: Recover the STANDBY database with the incremental backup
RMAN>recover database noredo;
Starting recover at 13-DEC-18
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=479 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: +DG_DATA/TSTDB1PS/DATAFILE/system.265.994761941
destination for restore of datafile 00003: +DG_DATA/TSTDB1PS/DATAFILE/sysaux.264.994761941
..............................................................................................
..............................................................................................
channel ORA_DISK_1: reading from backup piece /u01/app/oracle/stage/bkp/bkp/ForStandby_tmtklsbt_1_1
channel ORA_DISK_1: piece handle=/u01/app/oracle/stage/bkp/bkp/ForStandby_tmtklsbt_1_1 tag=FORSTANDBY
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:00:01
Finished recover at 13-DEC-18
Step6: Backup the controlfile from Primary for Standby
RMAN> BACKUP CURRENT CONTROLFILE FOR STANDBY FORMAT '/tmp/ForStandbyCTRL.bck';
Step7: copy the controlfile backup from primary to standby database server
Step8: Restore the controlfile on standby database
SQL> shut immediate;
ORA-01109: database not open
Database dismounted.
ORACLE instance shut down.
SQL> startup nomount;
ORACLE instance started.
Total System Global Area 4026531840 bytes
Fixed Size 2931856 bytes
Variable Size 989856624 bytes
Database Buffers 3019898880 bytes
Redo Buffers 13844480 bytes
$ rman target /
RMAN>RESTORE STANDBY CONTROLFILE FROM '/u01/app/oracle/stage/bkp/bkp/ForStandbyCTRL.bck';
Starting restore at 13-DEC-18
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=12 device type=DISK
channel ORA_DISK_1: restoring control file
channel ORA_DISK_1: restore complete, elapsed time: 00:00:01
output file name=/u01/app/oracle/stage/bkp/bkp/stby.ctl
Finished restore at 13-DEC-18
Step9: Mount the standby database
SQL> shut immediate;
ORA-01507: database not mounted
ORACLE instance shut down.
SQL> startup mount;
ORACLE instance started.
Total System Global Area 4026531840 bytes
Fixed Size 2931856 bytes
Variable Size 989856624 bytes
Database Buffers 3019898880 bytes
Redo Buffers 13844480 bytes
Database mounted.
NOTE: If ASM is not in use jump directly on
In case ASM is used the datafile names between Primary can standby may be different and since we brought the controlfile from primary the data file at standby is not know to this control file and you must update the datafile name in control file with the actual data file name in standby
Step10: Rename the datafile in controlfile to pint to the actual data files
$ rman target /
RMAN> CATALOG START WITH '+DG_DATA/TSTDB1PS/DATAFILE/';
using target database control file instead of recovery catalog
searching for all files that match the pattern +DG_DATA/TSTDB1PS/DATAFILE/
List of Files Unknown to the Database
=====================================
File Name: +DG_DATA/TSTDB1PS/DATAFILE/sysaux.264.994761941
File Name: +DG_DATA/TSTDB1PS/DATAFILE/system.265.994761941
File Name: +DG_DATA/TSTDB1PS/DATAFILE/undotbs2.266.994761943
File Name: +DG_DATA/TSTDB1PS/DATAFILE/undotbs1.267.994761943
File Name: +DG_DATA/TSTDB1PS/DATAFILE/audit_data.268.994761943
File Name: +DG_DATA/TSTDB1PS/DATAFILE/users.269.994761943
Do you really want to catalog the above files (enter YES or NO)? yes
cataloging files...
cataloging done
List of Cataloged Files
=======================
File Name: +DG_DATA/TSTDB1PS/DATAFILE/sysaux.264.994761941
File Name: +DG_DATA/TSTDB1PS/DATAFILE/system.265.994761941
File Name: +DG_DATA/TSTDB1PS/DATAFILE/undotbs2.266.994761943
File Name: +DG_DATA/TSTDB1PS/DATAFILE/undotbs1.267.994761943
File Name: +DG_DATA/TSTDB1PS/DATAFILE/audit_data.268.994761943
File Name: +DG_DATA/TSTDB1PS/DATAFILE/users.269.994761943
RMAN> SWITCH DATABASE TO COPY;
datafile 1 switched to datafile copy "+DG_DATA/TSTDB1PS/DATAFILE/system.265.994761941"
datafile 3 switched to datafile copy "+DG_DATA/TSTDB1PS/DATAFILE/sysaux.264.994761941"
datafile 4 switched to datafile copy "+DG_DATA/TSTDB1PS/DATAFILE/undotbs1.267.994761943"
.......................................................................................
.......................................................................................
Step11: Start the Recovery
Start the MRP process on standby
SQL> RECOVER MANAGED STANDBY DATABASE DISCONNECT FROM SESSION;
Comments
Post a Comment