1号数据文件坏块处理修复

来源:这里教程网 时间:2026-03-03 22:39:53 作者:

一、模拟坏块环境:

进入 bbed

copy file 2 block 20 to file 1 block 520

然后强制关闭数据库

shutdown abort;

再次打开数据库,如下报错 ( 可以看到 1 号文件的 520 号块已被损坏 ):

Reading datafile '/oracle/app/xiete/system01.dbf' for corruption at rdba: 0x00400208 (file 1, block 520)
Reread (file 1, block 520) found same corrupt data (no logical check)
Errors in file /oracle/app/diag/rdbms/xiete/xiete/trace/xiete_ora_18012.trc  (incident=6137):
ORA-01578: ORACLE data block corrupted (file # 1, block # 520)
ORA-01110: data file 1: '/oracle/app/xiete/system01.dbf'
Incident details in: /oracle/app/diag/rdbms/xiete/xiete/incident/incdir_6137/xiete_ora_18012_i6137.trc
Errors in file /oracle/app/diag/rdbms/xiete/xiete/trace/xiete_ora_18012.trc:
ORA-00704: bootstrap process failure
ORA-01578: ORACLE data block corrupted (file # 1, block # 520)
ORA-01110: data file 1: '/oracle/app/xiete/system01.dbf'
Errors in file /oracle/app/diag/rdbms/xiete/xiete/trace/xiete_ora_18012.trc:
ORA-00704: bootstrap process failure
ORA-01578: ORACLE data block corrupted (file # 1, block # 520)
ORA-01110: data file 1: '/oracle/app/xiete/system01.dbf'
Error 704 happened during db open, shutting down database
USER (ospid: 18012): terminating the instance due to error 704
Instance terminated by USER, pid = 18012
ORA-1092 signalled during: alter database open...
opiodr aborting process unknown ospid (18012) as a result of ORA-1092
Thu Aug 26 16:28:38 2021
ORA-1092 : opitsk aborting process

  二、开始修复

(一)使用 dd 命令进行修复

1 、从一个相同系统,相同数据库版本的数据文件中 dd 一个好的 1 号文件 520 号块

[oracle@yikuer hzmc]$ dd if=/oracle/app/xiete/system01.dbf of=/home/oracle/1 skip=520 bs=8192 count=1  #skip用来跳过多少数据块
1+0 records in
1+0 records out
8192 bytes (8.2 kB) copied, 0.0160776 s, 510 kB/s

2、将文件传到出问题的主机,将这个文件dd进1号数据文件

[oracle@yikuer xiete]$ dd if=/home/oracle/1 of=/oracle/app/xiete/system01.dbf seek=520 bs=8192 count=1 conv=notrunc

# 使用 notrunc 不会删除之后的数据 ,否则第 520 块后面的数据就被清空了, seek 定位到第 520 个块, 做之前先备份文件

1+0 records in
1+0 records out
8192 bytes (8.2 kB) copied, 0.000196376 s, 41.7 MB/s

(二)使用 bbed进行修复

1 、从一个相同系统,相同数据库版本的 1 号数据文件中拷贝到问题主机中,然后写入到 filelist.txt 列表中

[oracle@yikuer trace]$ more filelist.txt
1 /oracle/app/xiete/system01.dbf 734003200
2 /oracle/app/xiete/sysaux01.dbf 629145600
3 /oracle/app/xiete/undotbs01.dbf 209715200
4 /oracle/app/xiete/users01.dbf 5242880
5 /oracle/app/xiete/system01bbed.dbf

5号就是我们拷贝过来的文件,只要把路径对应好就行,序号往下顺延一个即可

[oracle@yikuer trace]$ more bbed.par
blocksize=8192
listfile=/oracle/app/diag/rdbms/hzmc/hzmc/trace/filelist.txt
mode=edit

这是 bbed 的启动参数文件

bbed parfile=/oracle/app/diag/rdbms/hzmc/hzmc/trace/bbed.par
Passwd:blockedit

做之前先备份文件 ,cp /oracle/app/xiete/system01.dbf /oracle/app/xiete/system01.dbf.bak

BBED> copy file 5 block 520 to file 1 block 520
Warning: contents of previous BIFILE will be lost. Proceed? (Y/N) Y
 File: /oracle/app/xiete/system01.dbf (1)

替换完毕之后,即可重新正常打开数据库实例。

相关推荐