Explanation and examples of RMAN Block-level Media Recovery
Block-Level Media Recovery
-----------------------------
Restriction:
The data file header block (block 1) cannot be recovered.
#
Block-level Media Recovery is most useful in situations where only a
small subset of blocks in a datafile need media recovery. Before Oracle9i if
a single block required recovery the DBA would need to restore the complete
datafile and apply all redo changes. Recovery time is reduced as only blocks
needing recovery need to be restored from backup and only the required set of
corrupt blocks undergo redo application.
Data blocks undergoing media recovery are inaccessible to queries or DML because
they are media corrupt, but the datafile itself remains online. This is a
significant availability improvement over file-level recovery, where the entire
datafile is offline for the duration of the recovery. Blocks undergoing recovery
are not visible to users until the recovery process is complete.
Recovery Manager Interface
RMAN will support BMR via the new BLOCKRECOVER command:
BLOCKRECOVER bmr_block_specifier_list bmr_option_list;
bmr_block_specifier_list: bmr_block_specifier |
bmr_block_specifier_list bmr_block_specifier
bmr_block_specifier: DATAFILE datafile_specifier BLOCK block_list |
TABLESPACE tablespace_specifier DBA dba_list
CORRUPTION LIST
datafile_specifier: text_string | integer
block_list: integer |
block_list , integer
tablespace_specifier: text_string
dba_list: integer |
dba_list , integer
bmr_option_list: bmr_option |
bmr_option_list | bmr_option
bmr_option: from backupset |
from datafilecopy |
from tag text_string |
restore until time_clause |
nofileupdate |
save final blocks |
save all blocks
time_clause: TIME date_string |
SCN integer |
LOGSEQ integer THREAD integer
This command will identify the backups from which to obtain the blocks to
recover. If the user has never used RMAN before with this database, and their
only existing backups are image copies taken with v7 methods, they should use
the catalog datafilecopy command to identify those files to RMAN prior to using
the blockrecover command.. The catalog archivelog command may also be required
to specify restored archives. In some cases it may be necessary for the
customer to first configure the catalog if they are not using RMAN at all.
% rman target
RMAN> catalog datafilecopy '<name>';
catalog archivelog '<name>';
See also :
Note 342972.1 HOW TO PERFORM BLOCK MEDIA RECOVERY (BMR) WHEN BACKUPS ARE NOT TAKEN BY RMAN
If the user has backups or archivelogs that need to be restored from tape,
they should allocate the required channel(s) before the blockrecover command.
Archivelog restores for BMR can be run in parallel on multiple channels, but
datafile/backupset scans and the recovery session must all run in the same
server session.
To allow selection of which backup will be used to select the desired blocks,
the blockrecover command supports options used in the restore command:
FROM BACKUPSET -- restore blocks from backupsets only
FROM DATAFILECOPY -- restore blocks from datafile copies only
FROM TAG -- restore blocks from tagged backup
RESTORE UNTIL TIME|SCN|LOGSEQ -- limit search to backups made at or before this time.
Starting from 9.0.1, a new view, V$DATABASE_BLOCK_CORRUPTION, will reflect the
blocks that were found to be corrupted since the last RMAN backup.
Examples:
How to identify blocks needing recovery:
SQL> select * from mine;
select * from mine
*
ERROR at line 1:
ORA-01578: ORACLE data block corrupted (file # 5, block # 114)
ORA-01110: data file 5: '/u02/oradata/DB1/users01.dbf'
Or use RMAN to populate the V$DATABASE_BLOCK_CORRUPTION view.
RMAN> run {BACKUP VALIDATE DATABASE;}
Starting backup at 09-MAY-01
using channel ORA_DISK_1
using channel ORA_DISK_2
channel ORA_DISK_1: starting full datafile backupset
channel ORA_DISK_1: specifying datafile(s) in backupset
input datafile fno=00002 name=/u02/oradata/DB1/undotbs01.dbf
input datafile fno=00003 name=/u02/oradata/DB1/indx01.dbf
input datafile fno=00005 name=/u02/oradata/DB1/users01.dbf
input datafile fno=00008 name=/u02/oradata/DB1/repcat01.dbf
input datafile fno=00004 name=/u02/oradata/DB1/tools01.dbf
channel ORA_DISK_2: starting full datafile backupset
channel ORA_DISK_2: specifying datafile(s) in backupset
including current controlfile in backupset
input datafile fno=00001 name=/u02/oradata/DB1/system01.dbf
input datafile fno=00006 name=/u02/oradata/DB1/joanes/joanes_1.dbf
input datafile fno=00007 name=/u02/oradata/DB1/joanes/joanes_test_1.dbf
channel ORA_DISK_1: backup set complete, elapsed time: 00:01:28
channel ORA_DISK_2: backup set complete, elapsed time: 00:01:54
Finished backup at 09-MAY-01
Result:
SQL> select * from V$backup_corruption;
RECID STAMP SET_STAMP SET_COUNT PIECE# FILE# BLOCK#
---------- ---------- ---------- ---------- ---------- ---------- ----------
BLOCKS CORRUPTION_CHANGE# MAR
---------- ------------------ ---
1 429201733 429201725 8 1 5 114
1 0 YES
Perform Block Level Recovery by either explicitly identifying the file and block to be recovered or use the corruption list - v$backup_corruption
Recovery using Explicit File/Block:
$ rman catalog rman/rman@DB2 target / log=rman1.log
RMAN> run {blockrecover datafile 5 block 114;}
RMAN> exit
Recovery Manager: Release 9.0.0.0.0 - Beta
(c) Copyright 2000 Oracle Corporation. All rights reserved.
connected to target database: DB1 (DBID=1021434286)
connected to recovery catalog database
RMAN>
Starting blockrecover at 08-MAY-01
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=8 devtype=DISK
allocated channel: ORA_DISK_2
channel ORA_DISK_2: sid=7 devtype=DISK
channel ORA_DISK_1: restoring block(s)
channel ORA_DISK_1: specifying block(s) to restore from backup set
restoring blocks of datafile 00005
channel ORA_DISK_1: restored block(s) from backup piece 1
piece handle=/u02/oradata/DB1/joanes/04cp9jk9_1_1 tag=null params=NULL
channel ORA_DISK_1: block restore complete
channel ORA_DISK_1: block restore complete
starting media recovery
media recovery complete
Finished blockrecover at 08-MAY-01
Alternatively, you can use Data Recovery Advisor (DRA):
RMAN> list failure;
List of Database Failures
=============
Failure ID Priority Status Time Detected Summary
---------- -------- --------- ------------- -------
441 HIGH OPEN 20-SEP-13 Datafile 4: '/u01/V112_oradata/users01.dbf' contains one or more corrupt blocks
RMAN> advise failure;
List of Database Failures
=============
Failure ID Priority Status Time Detected Summary
---------- -------- --------- ------------- -------
441 HIGH OPEN 20-SEP-13 Datafile 4: '/u01/V112_oradata/users01.dbf' contains one or more corrupt blocks
analyzing automatic repair options; this may take some time
using channel ORA_DISK_1
analyzing automatic repair options complete
Mandatory Manual Actions
============
no manual actions available
Optional Manual Actions
===========
no manual actions available
Automated Repair Options
============
Option Repair Description
------ ------------------
1 Perform block media recovery of block 520 in file 4
Strategy: The repair includes complete media recovery with no data loss
Repair script: /u02/app/oracle/diag/rdbms/v112/V112/hm/reco_4024241654.hm
RMAN> repair failure preview;
Strategy: The repair includes complete media recovery with no data loss
Repair script: /u02/app/oracle/diag/rdbms/v112/V112/hm/reco_4024241654.hm
contents of repair script:
- block media recovery
recover datafile 4 block 520;
RMAN> repair failure noprompt;
Strategy: The repair includes complete media recovery with no data loss
Repair script: /u02/app/oracle/diag/rdbms/v112/V112/hm/reco_4024241654.hm
contents of repair script:
- block media recovery
recover datafile 4 block 520;
executing repair script
Starting recover at 20-SEP-13
using channel ORA_DISK_1
channel ORA_DISK_1: restoring block(s)
channel ORA_DISK_1: specifying block(s) to restore from backup set
restoring blocks of datafile 00004
channel ORA_DISK_1: reading from backup piece /u01/temp/flash_areas/V112/V112/backupset/2013_09_20/o1_mf_nnndf_TAG20130920T092224_93rm0khr_.bkp
channel ORA_DISK_1: piece handle=/u01/temp/flash_areas/V112/V112/backupset/2013_09_20/o1_mf_nnndf_TAG20130920T092224_93rm0khr_.bkp tag=TAG20130920T092224
channel ORA_DISK_1: restored block(s) from backup piece 1
channel ORA_DISK_1: block restore complete, elapsed time: 00:00:01
starting media recovery
archived log for thread 1 with sequence 187 is already on disk as file /u01/temp/flash_areas/V112/V112/archivelog/2013_09_20/o1_mf_1_187_93rmnqwg_.arc
archived log for thread 1 with sequence 188 is already on disk as file /u01/temp/flash_areas/V112/V112/archivelog/2013_09_20/o1_mf_1_188_93rmq47g_.arc
archived log for thread 1 with sequence 189 is already on disk as file /u01/temp/flash_areas/V112/V112/archivelog/2013_09_20/o1_mf_1_189_93rn7994_.arc
archived log for thread 1 with sequence 190 is already on disk as file /u01/temp/flash_areas/V112/V112/archivelog/2013_09_20/o1_mf_1_190_93rnymmf_.arc
media recovery complete, elapsed time: 00:00:03
Finished recover at 20-SEP-13
repair failure complete
Recovery using Corruption list :
RMAN> run {blockrecover corruption list;}
Starting blockrecover at 08-MAY-01
using channel ORA_DISK_1
using channel ORA_DISK_2
channel ORA_DISK_1: restoring block(s)
channel ORA_DISK_1: specifying block(s) to restore from backup set
restoring blocks of datafile 00005
channel ORA_DISK_1: restored block(s) from backup piece 1
piece handle=/u02/oradata/DB1/joanes/08cpa69t_1_1 tag=null params=NULL
channel ORA_DISK_1: block restore complete
channel ORA_DISK_1: restoring block(s)
channel ORA_DISK_1: specifying block(s) to restore from backup set
restoring blocks of datafile 00005
channel ORA_DISK_1: restored block(s) from backup piece 1
piece handle=/u02/oradata/DB1/joanes/04cp9jk9_1_1 tag=null params=NULL
channel ORA_DISK_1: block restore complete
starting media recovery
media recovery complete
Finished blockrecover at 08-MAY-01
<span style="background-color: #ffffff;">**11.2 RMAN Block recovery syntax**In 11.2 you can use RMAN to:=========================1) validate all database files and archived redo log files for physical and logical corruption:BACKUP VALIDATE CHECK LOGICAL DATABASE ARCHIVELOG ALL;3) validate backup sets:2) to check individual data blocks, as shown in the following example:VALIDATE DATAFILE 4 BLOCK 10 TO 13;The following RMAN command recovers the corrupted blocks:VALIDATE BACKUPSET 3;You specify backup sets by primary key, which is shown in the output of the LIST BACKUP command.2) recover individual blocks, see eg:1) recover all corrupted blocks reported in v$database_block_corruptionRMAN> RECOVER CORRUPTION LIST;RMAN> RECOVER DATAFILE 1 BLOCK 233, 235 DATAFILE 2 BLOCK 100 TO 200;__**Restriction Note:**__</span>
o The data file header block (block 1) cannot be recovered !
- Example showing behaviour for a Corrupt File Header Block 1 using Blockrecover
Block 1 (datafile header) is phisycally corrupt in this example with some garbage.
The rman block recover command does not error out but alert log is updated:
RMAN> blockrecover datafile 7 block 1;
Starting recover at 19-MAR-13
using channel ORA_DISK_1
starting media recovery
media recovery complete, elapsed time: 00:00:00
Finished recover at 19-MAR-13
- There is no errors here but alert.log registers the problem:**
...
Corrupt block relative dba: 0x01c00001 (file 7, block 1)
Bad header found during kcvxfh v10
Data in bad block:
type: 99 format: 7 rdba: 0x0a747075
last change scn: 0x0000.00000000 seq: 0x1 flg: 0x04
spare1: 0x72 spare2: 0x72 spare3: 0x0
consistency value in tail: 0x00000b01
check value in block header: 0xf5c4
computed block checksum: 0xc4da
Reading datafile '/emea/bde/64bit/app/oracle/oradata/EMB11203/tc.dbf' for corruption at rdba: 0x01c00001 (file 7, block 1)
Reread (file 7, block 1) found same corrupt data (no logical check)
Tue Mar 19 13:31:46 2013
alter database recover datafile list clear
Completed: alter database recover datafile list clear
No comments:
Post a Comment