Lately I have found a description for recovering using incremental backup. Despite speeding up a standby recovery (assuming the number of archivelogs to apply is much beyond the amount of changed data blocks) this method is useful for example for recovery from lost archivelog.
I found some good articles on the topic above:
- http://dbakerber.wordpress.com/2011/12/20/incremental-recovery-of-standby-asm-and-rman/
- http://msutic.blogspot.com/2010/11/recover-from-incrementally-updated.html - this one is especially very precise
My personal goal was to speed up a standby recovery. I did it on the 11.2.0.2 version. I assume here disk channel, but tape is the same or even simpler as one do not need to transfer backup files from the primary to the standby host assuming centralized backup facility.
The receipt is as follows:
- make an incremental backup from SCN, at which our standby stopped (or actually it is better to backup slightly more then is needed, thus SCN should be a little lower then the really needed). This could be as simple as this:
BACKUP INCREMENTAL FROM SCN 60839640548 DATABASE TAG='SCN_BEFORE_60839650548';
Here a warning - this has to be a disk backup. In docs (at least for 10.2) there is stated that RMAN does not consider the incremental backup as part of a backup strategy at the source database.
It vanished in later versions of docs (or at least I can not find it, but after perfoming an incremental backup to tape we were not able to list it).
- make a copy of a current controlfile for standby:
# from rman
BACKUP CURRENT CONTROLFILE FOR STANDBY;
# or from sqlplus
ALTER DATABASE CREATE PHYSICAL STANDBY CONTROLFILE AS '/tmp/control01.ctl';
- transfer both backups to the standby - starting from here all
- restore control files with rman
RESTORE STANDBY CONTROLFILE FROM '[controlfile path]';
or simply replace existing control files if using sqlplus
cp [controlfile path] [CONTROL_FILES parameter value] # for every position in CONTROL_FILES parameter of course
- now mount the standby instance
STARTUP NOMOUNT
ALTER DATABASE MOUNT STANDBY DATABASE;
- set STANDBY_FILE_MANAGEMENT to MANUAL (if set to AUTO)
- catalog all the already existing on standby datafiles to control file
CATALOG START WITH '[datafile path]'; # for every datafile path
- add all non-existent datafiles with sqlplus or with help of command SQL of rman
ALTER DATABASE CREATE DATAFILE [file_id];
- now is the time for switching the database to cataloged copies of datafiles. The simplest way is to:
SWITCH DATABASE TO COPY;
but if there were some non-existent files, which had to be added in the previous step, this will do not work.
The source 2 provides a way to workaround it:
CHANGE COPY OF DATAFILE [file_id] UNCATALOG;
My way is to produce a script with a call to v$datafile:
spool switch_files.rmn
SELECT 'SWITCH DATAFILE '||file_id||' TO COPY;' rmn1 FROM v$datafile ORDER BY file#;
spool off
then execute it and edit the spooled content to remove unnecessary entries - among those also tries to switch lately created datafile stubs (stubs are already seen by the instance, so actually no need to switch to them).
- now almost finish - recover database with rman - NOREDO forces rman to not use archivelogs at all
RECOVER DATABASE NOREDO;
- the rest is possibly to fix some small issues with redologs, which means usually clear logfiles and to start managed standby recovery
And now we are with automatically running standby back again :-)
No comments:
Post a Comment