Professional Documents
Culture Documents
Data Matters
What if your data centre did not All Posts About
measure up to future demands?
www.d atacraft-asia.com /datam a tters
Search
Ads by Google Backup Recovery Data Recovery Data Backup Disk Recovery
1620+of Jobs in
Oracle10g « Automatic Shared Memory Management in Oracle 10g How to migrate Oracle datafiles to ASM storage via RMAN »
Exp: 0 to 13
Yrs.Sal: 25k to
95k PM Apply How to perform Block Media Recovery using RMAN
Now & get Multiple Posted by Zahid on August 19, 2009.
Interviews
Ti mesJobs.com/Orac…
When you get some data blocks in the data files physically corrupt, then you will have to restore the full data file from backup
for the recovery of those few block, if you don't have RMAN backups. But if you do then you can take benefit of this very
Pay per use IT powerful feature of RMAN called BMR (BLOCK MEDIA RECOVERY). Using BMR only those blocks which are corrupt can be
Tata recovered from a backup instead of recovering whole file.
Communications
InstaCompute™ Lets see how its done.
Save money, save
time, start now create tablespace ts_corrupt
i aas.tatacom municat… datafile '/d01/apps/oradata/oraxpo/ts_corrupt01.dbf'
size 10m autoextend on next 5m
extent management local
Backup & Share segment space management auto
Photos /
Quickly store
1000s of pics Tablespace created.
online Safe,
Secure, Free. 10 create user usr_corrupt identified by usr_corrupt
GB Free Acct default tablespace ts_corrupt
www.cx.com/ShareP…
quota unlimited on ts_corrupt
/
Latest Cricket
Updates User created.
Get All The News
& Buzz On grant connect , resource to usr_corrupt
Cricket. Now /
Available Online
On YouTube! Grant succeeded.
www.youtube.com/
conn usr_corrupt/usr_corrupt
Zahid Karim Connected.
Table created.
SQL> exit
We have a tablespace ts_corrupt, which has a table named t_corrupt owned by the user usr_corrupt. Lets take a backup of
this tablespace using RMAN.
$ rman target /
RMAN> exit
$ sqlplus / as sysdba
SQL> exit
The header of the table is in block 11, so if the block 12 or so are corrupted we will get an error when we try to select data
from the table. Lets corrupt block 12 using the "dd" command in Linux.
DISCLAIMER: The dd command given below is just for learning purposes and should only be used on testing systems. I will
not take any responsibility of any consequences or loss of data caused by this command.
$ cd /d01/apps/oradata/oraxpo
$ dd of=ts_corrupt01.dbf bs=8192 conv=notrunc seek=12 << EOF
> Bingo! Corrupted.
> EOF
0+1 records in
0+1 records out
18 bytes (18 B) copied, 0.000487 seconds, 37.0 kB/s
After this command successfully executed block 12 in the data file "/d01/apps/oradata/oraxpo/ts_corrupt01.dbf" is corrupt.
$ sqlplus / as sysdba
System altered.
/*
We need to flush the buffer_cache because if the block 12 is
in the buffer_cache already it will not be read from the data file.
*/
SQL> exit
The error that we get due to a block corruption is very clear. It will tell you the file and block#.
Lets do BMR for data file 6 and block 12.
oracleflash.com/…/How-to-perform-Blo… 2/6
2/25/2011 Oracle 10g RMAN Block Media Recovery
$ rman target /
RMAN> exit
BLOCK MEDIA RECOVERY Complete we should now get the block 12 recovered back.
$ sqlplus usr_corrupt/usr_corrupt
COUNT(*)
----------
40688
SQL> exit
Lets now corrupt more then one blocks in the file and test BMR in a different way.
$ cd /d01/apps/oradata/oraxpo
$ dd of=ts_corrupt01.dbf bs=8192 conv=notrunc seek=13 << EOF
> A Messy Corruption.
> EOF
0+1 records in
0+1 records out
20 bytes (20 B) copied, 0.000382 seconds, 52.4 kB/s
$ sqlplus usr_corrupt/usr_corrupt
COUNT(*)
----------
40688
System altered.
/*
The table was in buffer_cache so when we did a select we got all
blocks from buffer_cache. Flush the buffer cache to read blocks
from file.
*/
SQL> exit
Having said that you have three blocks corrupt in your data file, your automated backup script started in the night somewhere
and took a backup of the file marking the blocks as corrupt. So you don't have these corrupt blocks in your latest backup.
When RMAN finds corrupt blocks in the data file it reports them in v$backup_corruption.
$ rman target /
RMAN> run {
set maxcorrupt for datafile 6 to 3;
/*
This will ignore 3 corruptions in the file 6 and mark
the blocks as corrupt.
*/
backup datafile 6;
}
RMAN> exit
$ sqlplus / as sysdba
SQL> exit
It tells us there are three blocks corrupted in data file 6. Now we can simply go to RMAN use the BLOCK RECOVER
oracleflash.com/…/How-to-perform-Blo… 4/6
2/25/2011 Oracle 10g RMAN Block Media Recovery
It tells us there are three blocks corrupted in data file 6. Now we can simply go to RMAN use the BLOCK RECOVER
command to recover all these blocks in one go from the backup we took before this corruption.
$ rman target /
/*
CORRUPTION LIST means all the blocks reported corrupt in
v$backup_corruption.
*/
RMAN> exit
$ sqlplus usr_corrupt/usr_corrupt
COUNT(*)
----------
40688
oracleflash.com/…/How-to-perform-Blo… 5/6
2/25/2011 Oracle 10g RMAN Block Media Recovery
SQL> exit
All blocks are recovered now. Before anything else happens you should quickly take another healthy backup of the data file.
$ rman target /
RMAN> exit
See also:
How to convert user managed copies into RMAN copies
Use DBMS_REPAIR to fix physically corrupt data block
oracleflash.com/…/How-to-perform-Blo… 6/6