recovering standby database when archive log is missing using rman

Upload: getsatya347

Post on 13-Jul-2015

107 views

Category:

Documents


0 download

TRANSCRIPT

Using RMAN Incremental SCN to recover Archive log

standby Database

with missing

Product : Database Version Affected Environments :

RDBMS 10g and Higher only Databases with DR / DG Corrupted/unavailable archived Redo log which is required to fill an archive gap in a DR environment

Issue Description :

Issue Detail: DR/DG is in an unrecoverable state as the archived redo log which is required to fill an archive gap is unavailable due to corruption or deletion. DR/DG has to be rebuilt from scratch from the backup to fix the issue. Solution: RMAN incremental backup from SCN was used to sync a DR/DG by backing up only the changed blocks on the source from the SCN of the missed archived redo log. This backup can then be applied on the DR/DG which will update all the block changes.

STEP 1 Find SCN at Source/Primary 1. Identify the sequence# of the missing redo log file from the primary database using the below SQL.

select thread#, sequence#, first_change#, NEXT_CHANGE# from v$archived_log where (thread#, sequence#) in (select thread#, max(sequence#) seq from gv$archived_log where NEXT_CHANGE# < (select FIRST_CHANGE# from v$archived_log where sequence#= and thread#= ) group by thread# )

1

If any issues with this sql, use the alert log to find the closest SCN. Make sure the SCN is older than the missing archived redo log, otherwise the backup will be of no use. You can also use the below sql to find the SCN for a specific time. Eg. if the archive file which is missing got generated on 01/02/2011 02:45, find the SCN which got generated at '01/02/2011 02:30:54' or before.

col scn format 999999999999999999999 select timestamp_to_scn(to_timestamp('01/02/2011 02:30:54','DD/MM/YYYY HH24:MI:SS')) as scn from dual;STEP 2 Run RMAN Incremental Backup at Source/Primary

1. Execute the RMAN Incremental backup at the source/primary from the SCN identified at STEP 1. rman target / run { allocate channel ch1 type disk format '/rman_%U_bpiece1.bak'; allocate channel ch2 type disk format '/rman_%U_bpiece2.bak'; ..... ..... BACKUP as compressed backupset INCREMENTAL FROM SCN DATABASE tag 'FORSTANDBY'; } Note: Decide the number of channels based on the CPU availability and the CPU utilization. Use the below sample Shell Script for RMAN Incremental Backup Please modify the script for setting the Environment according to the database.

#!/bin/ksh print "Starting at `date +%x_%X`" . /usr/local/bin/setdb PRODTEST2 rman target / control_file_record_keep_time=73

6. Start the DR/DG Database

startup nomount; alter database mount standby database;7. Create missing datafiles Create the missing datafiles that were added to production database after the was generated. Note: Run the following Query in Primary for finding the Creation_time. Compare the time with the timing of missing sequence and add the datafiles in DR/DG.

select t.name "TABLESPACE_NAME",f.name "DATAFILE" ,to_char(creation_time,'DD-MON-YYYY HH24:MI:SS') "CREATION_TIME", f.bytes/1024/1024/1000 "SIZE_IN_GB" from v$datafile f,v$tablespace t where f.ts#=t.ts# order by 3Run the Following in DR/DG after mounting the standby database :

ALTER SYSTEM SET standby_file_management='MANUAL' SCOPE=MEMORY; alter database create datafile ''8. Catalog the incremental backup Catalog the incremental backup taken at STEP 2 to the DR/DG database.

rman target /CATALOG START WITH '' ; Eg,

CATALOG START WITH '/oracle/dump/PRODTEST2/rman_incr_copied' ;

STEP 6 Recover DR/DG with the Incremental backup

Run the RMAN RECOVER command with the NOREDO option to apply the incremental backup to the DR/DG database. All the changed blocks are updated at the standby to make it, up to date with the primary/source database. rman target / { allocate channel ch1 type disk; allocate channel ch2 type disk; .. RECOVER DATABASE noredo; }

Use the below sample Script for RMAN Incremental recovery

#!/bin/ksh rman target /