1.通过DBV 检查文件是否有坏块
例如:检查 cjc_index01.dbf 文件
dbv file='/oradata/nc/cjc_index01.dbf'
2.检查坏块所属段类型
例如:file_id=6(cjc_index01.dbf),block=459202
select tablespace_name, segment_type, owner, segment_name
from dba_extents
where file_id = 6
and 459202 between block_id and block_id + blocks - 1;
3.rman恢复坏块
恢复方式:基于数据块的Rman 恢复
检查datafile=6的所有坏块
检查坏块位置
RMAN>backup validate datafile 6;
验证坏块
select FILE#,BLOCK#,BLOCKS,CORRUPTION_CHANGE#,CORRUPTION_TYPE from v$database_block_corruption where file#=6;
修复坏块
RMAN>blockrecover datafile 6 block 459202 from backupset;
如果有多个坏块,可以用逗号分开,例如:
RMAN>blockrecover datafile 6 block 459202,643867,1963727;
4.如果没有RMAN备份
索引类型坏块,可以选择重建索引;
数据类型坏块,可以选择跳过坏块导出数据,重建表。
如果是通过exp备份不能直接备份出有坏块的表,需要设置内部事件
ALTER SYSTEM SET EVENTS='10231 trace name context forever,level 10';
通过expdp 备份可以直接跳过坏块;
也可以使用10231事件忽略坏块,然后使用CTAS方式重建表最后rename table,别忘记rebuild index,例如:
alter session SET EVENTS '10231 trace name context forever,level 10';
create table tab_new as select * from tab;
rename tab to tab_bak;
rename tab_new to new;
select 'alter index '||index_name||' rebuild;' from user_ind_columns where table_name='T1';
alter session SET EVENTS '10231 trace name context off';
###chenjuchao 20240308###
欢迎关注我的公众号《IT小Chen》