This note explains how to use RMAN tocopy an ASM baseddatafile onto the file system. Once the datafileis on the file system,the OS command dd can be used to extract the block(s) from the datafile.
-- 注意,用dd 命令修复坏块 只适用与逻辑坏块。 物理坏块不适用。
The approach presented here may be used with any ASM redundancy. It should be noted that this method requires the free spaceon the file system equivalent to the size of datafile being extracted.
This method can be used for datafiles, datafile copies and archived redo log files stored within ASM.
Extracting Datafile Blocks From ASM
Lets look at an example of corruption reported on an ASM datafile with normal redundancy. The objective is to extract the corrupted block from the datafile, patch it and put it back into the database.
1. Corruption reported:
SQL>SELECTCOUNT(*)FROMT1;
SELECTCOUNT(*)FROMT1
*
ERRORatline1:
ORA-01578:ORACLEdatablockcorrupted(file#7,block#65)
ORA-01110:datafile7:'+GROUPA/aa10g/datafile/ts_bane.267.3'
2. Take the file offline, to make sure there are no further changes while the block is being examined/patched.
SQL>alterdatabasedatafile7offline;
Databasealtered.
3. Use RMAN 'BACKUP AS COPY DATAFILE' command to extract the datafile from ASM onto the file system:
RMAN>CONNECTTARGET;
connectedtotargetdatabase:AA10G(DBID=1449158500)
RMAN>BACKUPASCOPYDATAFILE7FORMAT'/tmp/df_%f';
Startingbackupat<date>
Uusingtargetdatabasecontrolfileinsteadofrecoverycatalog
allocatedchannel:ORA_DISK_1
channelORA_DISK_1:sid=215devtype=DISK
channelORA_DISK_1:startingdatafilecopy
inputdatafilefno=00007name=+GROUPA/aa10g/datafile/ts_bane.267.3
outputfilename=/tmp/df_7tag=TAG20041230T125410recid=7stamp=546267252
channelORA_DISK_1:datafilecopycomplete,elapsedtime:00:00:03
Finishedbackupat<date>
4. Now that the file is on the file system, theOS command dd can be used to extract the block from the copy of the datafile:
$ddif=df_7of=f7b65.ddcount=1skip=65bs=8192
5. Lets say that at this step the block has been examined and patched.
6. Put the patched block back into df_7:
$ddif=f7b65.ddof=df_7bs=8192seek=65count=1conv=notrunc
7. Restore the patched datafile from the file system back into ASM:
RMAN>CONNECTTARGET;
connectedtotargetdatabase:AA10G(DBID=1449158500)
RMAN>run{
RESTOREDATAFILE7FROMTAG'TAG20041230T125410';
RECOVERDATAFILE7;
SQL"ALTERDATABASEDATAFILE7ONLINE";
}
Startingrestoreat<date>
usingtargetdatabasecontrolfileinsteadofrecoverycatalog
allocatedchannel:ORA_DISK_1
channelORA_DISK_1:sid=213devtype=DISK
channelORA_DISK_1:restoringdatafile00007
inputdatafilecopyrecid=7stamp=546267252filename=/tmp/df_7
destinationforrestoreofdatafile00007:+GROUPA/aa10g/datafile/ts_bane.267.3
channelORA_DISK_1:copieddatafilecopyofdatafile00007
outputfilename=+GROUPA/aa10g/datafile/ts_bane.267.3recid=8stamp=546267683
Finishedrestoreat<date>
Startingrecoverat<date>
usingchannelORA_DISK_1
startingmediarecovery
mediarecoverycomplete
Finishedrecoverat<date>
sqlstatement:ALTERDATABASEDATAFILE7ONLINE
RMAN>
8. Once the patched datafile has been restored, select from table T1 works as expected:
SQL>SELECTCOUNT(*)FROMT1;
COUNT(*)
--------
1536
From Oracle
-------------------------------------------------------------------------------------------------------
Blog: http://blog.csdn.net/tianlesoftware
Email: [email protected]
DBA1 群:62697716(满); DBA2 群:62697977(满) DBA3 群:62697850(满)
DBA 超级群:63306533(满); DBA4 群: 83829929 DBA5群: 142216823
聊天 群:40132017 聊天2群:69087192
--加群需要在备注说明Oracle表空间和数据文件的关系,否则拒绝申请