利用RMAN修复坏块
下面为详细步骤:
1. 可以用UE找出Table T01的段头块进行破坏。
sys@ORCL> select segment_name, header_block from dba_segments where segment_name='T01';
SEGMENT_NAME HEADER_BLOCK
--------------------------------------------------------------------------------- ------------
T01 11
sys@ORCL> select to_char(11*8*1024, 'xxxxxxxxxxxxxxxxxxxxx') from dual;
TO_CHAR(11*8*1024,'XXX
----------------------
16000
sys@ORCL> select to_char(12*8*1024, 'xxxxxxxxxxxxxxxxxxxxx') from dual;
TO_CHAR(12*8*1024,'XXX
----------------------
18000
段头块是UE打开数据库文件如上图的16000h---18000h,破坏这之间的数据
sys@ORCL> select count(*) from t01;
COUNT(*)
----------
10000
破坏过后
sys@ORCL> select count(*) from t01;
select count(*) from t01
*
ERROR at line 1:
ORA-01578: ORACLE data block corrupted (file # 6, block # 11)
ORA-01110: data file 6: '/oracle/app/oradata/orcl/tbs01.dbf'
2.利用DBV检查坏块
[oracle@ora10g orcl]$ dbv file='/oracle/app/oradata/orcl/tbs01.dbf' blocksize=8192;
DBVERIFY: Release 10.2.0.4.0 - Production on Sun Aug 14 22:31:55 2011
Copyright (c) 1982, 2007, Oracle. All rights reserved.
DBVERIFY - Verification starting : FILE = /oracle/app/oradata/orcl/tbs01.dbf
Page 11 is marked corrupt
Corrupt block relative dba: 0x0180000b (file 6, block 11) 利用DBV检查出坏块
Bad header found during dbv:
Data in bad block:
type: 35 format: 1 rdba: 0x68666564
last change scn: 0x0000.6b616b6a seq: 0x3 flg: 0x04
spare1: 0x62 spare2: 0x63 spare3: 0x0
consistency value in tail: 0x6cdd2303
check value in block header: 0x7f0a
computed block checksum: 0xc02c
DBVERIFY - Verification complete
Total Pages Examined : 640
Total Pages Processed (Data) : 20
Total Pages Failing (Data) : 0
Total Pages Processed (Index): 0
Total Pages Failing (Index): 0
Total Pages Processed (Other): 578
Total Pages Processed (Seg) : 0
Total Pages Failing (Seg) : 0
Total Pages Empty : 41
Total Pages Marked Corrupt : 1
Total Pages Influx : 0
Highest block SCN : 1162502 (0.1162502)
3.利用RMAN的BLOCKRECOVER恢复
[oracle@ora10g ~]$ rman target sys/syspassword
Recovery Manager: Release 10.2.0.4.0 - Production on Sun Aug 14 22:33:30 2011
Copyright (c) 1982, 2007, Oracle. All rights reserved.
connected to target database: ORCL (DBID=1225112371)
RMAN> blockrecover datafile 6 block 11;
Starting blockrecover at 14-AUG-11
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=143 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 00006
channel ORA_DISK_1: reading from backup piece /oracle/app/rman/set/ORCL_759190745_213_1
channel ORA_DISK_1: restored block(s) from backup piece 1
piece handle=/oracle/app/rman/set/ORCL_759190745_213_1 tag=TAG20110814T221905
channel ORA_DISK_1: block restore complete, elapsed time: 00:00:03
starting media recovery
media recovery complete, elapsed time: 00:00:03
Finished blockrecover at 14-AUG-11
4.检查数据
sys@ORCL> select count(*) from t01;
COUNT(*)
----------
10000
说明坏块恢复成功。
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/25937377/viewspace-704846/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/25937377/viewspace-704846/