本文档仅限测试使用,对于生产环境,非专业人士请谨慎使用BBED,对数据保持敬畏之心。
模拟故障
BBED> info
File# Name Size(blks)
----- ---- ----------
1 /u01/app/oracle/oradata/ORCLT/system01.dbf 115200
3 /u01/app/oracle/oradata/ORCLT/sysaux01.dbf 71680
4 /u01/app/oracle/oradata/ORCLT/undotbs01.dbf 44160
7 /u01/app/oracle/oradata/ORCLT/users01.dbf 640
BBED> copy file 7 block 10 to file 1 block 1
BBED> sum apply
SQL> shutdown immediate
ORA-01122: database file 1 failed verification check
ORA-01110: data file 1: '/u01/app/oracle/oradata/ORCLT/system01.dbf'
ORA-01210: data file header is media corrupt
SQL> shutdown abort
ORACLE instance shut down.
SQL> startup
ORACLE instance started.
Total System Global Area 2466249672 bytes
Fixed Size 8899528 bytes
Variable Size 536870912 bytes
Database Buffers 1912602624 bytes
Redo Buffers 7876608 bytes
Database mounted.
ORA-01122: database file 1 failed verification check
ORA-01110: data file 1: '/u01/app/oracle/oradata/ORCLT/system01.dbf'
ORA-01210: data file header is media corrupt
BBED> set file 1 block 1
FILE# 1
BLOCK# 1
BBED> map /v
File: /u01/app/oracle/oradata/ORCLT/system01.dbf (1)
Block: 1 Dba:0x00400001
------------------------------------------------------------
BBED-00400: invalid blocktype (30)
复制
修复
1. 构造文件头结构
BBED> info
File# Name Size(blks)
----- ---- ----------
1 /u01/app/oracle/oradata/ORCLT/system01.dbf 115200
3 /u01/app/oracle/oradata/ORCLT/sysaux01.dbf 71680
4 /u01/app/oracle/oradata/ORCLT/undotbs01.dbf 44160
7 /u01/app/oracle/oradata/ORCLT/users01.dbf 640
BBED> set file 3 block 1
FILE# 3
BLOCK# 1
BBED> map /v
File: /u01/app/oracle/oradata/ORCLT/sysaux01.dbf (3)
Block: 1 Dba:0x00c00001
------------------------------------------------------------
Data File Header
... ...
BBED> copy file 3 block 1 to file 1 block 1
BBED> sum apply
Check value for File 1, Block 1:
current = 0xf45a, required = 0xf45a
BBED> set file 1 block 1
FILE# 1
BLOCK# 1
BBED> map /v
File: /u01/app/oracle/oradata/ORCLT/system01.dbf (1)
Block: 1 Dba:0x00400001
------------------------------------------------------------
Data File Header
... ...
复制
2. 修改 rdba_kcbh
BBED> p kcvfhbfh
struct kcvfhbfh, 20 bytes @0
ub4 rdba_kcbh @4 0x00c00001
# 0x00c00001 代表 3 号文件 1 号块
BBED> set file 1 block 1 offset 4 count 32
BBED> dump
File: /u01/app/oracle/oradata/ORCLT/system01.dbf (1)
Block: 1 Offsets: 4 to 35 Dba:0x00400001
------------------------------------------------------------------------
0100c000 00000000 00000104 5af40000 00000000 00000013 534e6ff3 4f52434c
<32 bytes per line>
# 修改 rdba_kcbh 为 1 号文件 1 号块
# 注意: dump 格式是反着的,2bit 一反转
BBED> modify /x 01004000 offset 4
File: /u01/app/oracle/oradata/ORCLT/system01.dbf (1)
Block: 1 Offsets: 4 to 35 Dba:0x00400001
------------------------------------------------------------------------
01004000 00000000 00000104 5af40000 00000000 00000013 534e6ff3 4f52434c
<32 bytes per line>
BBED> sum apply
BBED> p kcvfhbfh
struct kcvfhbfh, 20 bytes @0
ub4 rdba_kcbh @4 0x00400001
复制
3. 修改 kccfhfsz
BBED> p kcvfhhdr
struct kcvfhhdr, 76 bytes @20
ub4 kccfhfsz @44 0x00011800
[root@ora11g ORCLT]# ls -l system01.dbf
-rw-r----- 1 oracle oinstall 943726592 May 6 16:28 system01.dbf
SQL> select (943726592-8192)/8192 from dual;
(943726592-8192)/8192
---------------------
115200
SQL> select to_char('115200','xxxxxxxxxxx') from dual;
TO_CHAR(115
------------
1c200
BBED> set file 1 block 1 offset 44 count 32
BBED> dump
File: /u01/app/oracle/oradata/ORCLT/system01.dbf (1)
Block: 1 Offsets: 44 to 75 Dba:0x00400001
------------------------------------------------------------------------
00180100 00200000 03000300 00000000 00000000 00000000 00000000 00000000
<32 bytes per line>
BBED> set file 1 block 1 offset 44 count 32
BBED> dump
File: /u01/app/oracle/oradata/ORCLT/system01.dbf (1)
Block: 1 Offsets: 44 to 75 Dba:0x00400001
------------------------------------------------------------------------
00180100 00200000 03000300 00000000 00000000 00000000 00000000 00000000
<32 bytes per line>
BBED> modify /x 00c20100
File: /u01/app/oracle/oradata/ORCLT/system01.dbf (1)
Block: 1 Offsets: 44 to 75 Dba:0x00400001
------------------------------------------------------------------------
00c20100 00200000 03000300 00000000 00000000 00000000 00000000 00000000
<32 bytes per line>
BBED> sum apply
Check value for File 1, Block 1:
current = 0x2eda, required = 0x2eda
BBED> p kcvfhhdr
struct kcvfhhdr, 76 bytes @20
ub4 kccfhfsz @44 0x0001c200
复制
4. 修改 kccfhfno
BBED> p kcvfhhdr
struct kcvfhhdr, 76 bytes @20
ub2 kccfhfno @52 0x0003
BBED> set file 1 block 1 offset 52 count 32
BBED> dump
File: /u01/app/oracle/oradata/ORCLT/system01.dbf (1)
Block: 1 Offsets: 52 to 83 Dba:0x00400001
------------------------------------------------------------------------
03000300 00000000 00000000 00000000 00000000 00000000 00000000 00000000
<32 bytes per line>
BBED> modify /x 01 offset 52
File: /u01/app/oracle/oradata/ORCLT/system01.dbf (1)
Block: 1 Offsets: 52 to 83 Dba:0x00400001
------------------------------------------------------------------------
01000300 00000000 00000000 00000000 00000000 00000000 00000000 00000000
<32 bytes per line>
BBED> sum apply
BBED> p kcvfhhdr
struct kcvfhhdr, 76 bytes @20
ub2 kccfhfno @52 0x0001
复制
5. 修改 kcvfhrdb
BBED> p kcvfhrdb
ub4 kcvfhrdb @96 0x00000000
# 只有SYSTEM才有 root dba,用来定位 bootstrap$,这个位置一般固定在1号文件的520号块(0x00400208)
BBED> set file 1 block 1 offset 96 count 32
BBED> dump
File: /u01/app/oracle/oradata/ORCLT/system01.dbf (1)
Block: 1 Offsets: 96 to 127 Dba:0x00400001
------------------------------------------------------------------------
00000000 09000000 00800000 a912f33b 5596cc41 d14f1d00 00800000 00000000
<32 bytes per line>
BBED> modify /x 08024000
BBED> sum apply
BBED> p kcvfhrdb
ub4 kcvfhrdb @96 0x00400208
复制
6. 修改 kscnbas
BBED> p kcvfhcrs
struct kcvfhcrs, 8 bytes @100
ub4 kscnbas @100 0x00001568
SQL> select FILE#,CREATION_CHANGE# from v$datafile;
FILE# CREATION_CHANGE#
---------- ----------------
1 9
3 5480
4 1920446
7 32876
SQL> select to_char('5480','xxxxxxxxxxx') from dual;
TO_CHAR(548
------------
1568
BBED> set file 1 block 1 offset 100 count 32
BBED> dump
File: /u01/app/oracle/oradata/ORCLT/system01.dbf (1)
Block: 1 Offsets: 100 to 131 Dba:0x00400001
------------------------------------------------------------------------
68150000 00800000 b512f33b 5596cc41 d14f1d00 00800000 00000000 00000000
<32 bytes per line>
BBED> modify /x 09000000 offset 100
File: /u01/app/oracle/oradata/ORCLT/system01.dbf (1)
Block: 1 Offsets: 100 to 131 Dba:0x00400001
------------------------------------------------------------------------
09000000 00800000 b512f33b 5596cc41 d14f1d00 00800000 00000000 00000000
<32 bytes per line>
BBED> sum apply
BBED> p kcvfhcrs
struct kcvfhcrs, 8 bytes @100
ub4 kscnbas @100 0x00000009
复制
7. 修改 kcvfhcrt
BBED> p kcvfhcrt
ub4 kcvfhcrt @108 0x3bf312b5
SQL> select file#,to_char(creation_time,'yyyy-mm-dd hh24:mi:ss') creation_time_file, (to_char(creation_time,'yyyy')-1988)*12*31*24*3600
+(to_char(creation_time,'mm')-1)*31*24*3600
+(to_char(creation_time,'dd')-1)*24*3600
+to_char(creation_time,'hh24')*3600
+to_char(creation_time,'mi')*60
+to_char(creation_time,'ss') creation_name_scn
from v$datafile order by 1;
FILE# CREATION_TIME_FILE CREATION_NAME_SCN
---------- ------------------- -----------------
1 2019-04-17 00:56:09 1005785769
3 2019-04-17 00:56:21 1005785781
4 2019-04-17 02:11:02 1005790262
7 2019-04-17 00:57:08 1005785828
SQL> select to_char(1005785781,'xxxxxxxxxxxx') from dual;
TO_CHAR(10057
-------------
3bf312b5
SQL> select to_char(1005785769,'xxxxxxxxxxxx') from dual;
TO_CHAR(10057
-------------
3bf312a9
BBED> set file 1 block 1 offset 108 count 32
BBED> dump
File: /u01/app/oracle/oradata/ORCLT/system01.dbf (1)
Block: 1 Offsets: 108 to 139 Dba:0x00400001
------------------------------------------------------------------------
b512f33b 5596cc41 d14f1d00 00800000 00000000 00000000 00000000 00000400
<32 bytes per line>
BBED> modify /x a912f33b
BBED> set file 1 block 1 offset 108 count 32
BBED> dump
File: /u01/app/oracle/oradata/ORCLT/system01.dbf (1)
Block: 1 Offsets: 108 to 139 Dba:0x00400001
------------------------------------------------------------------------
a912f33b 5596cc41 d14f1d00 00800000 00000000 00000000 00000000 00000400
<32 bytes per line>
BBED> sum apply
BBED> p kcvfhcrt
ub4 kcvfhcrt @108 0x3bf312a9
复制
8. 修改 kcvfhsta
BBED> p kcvfhsta
ub2 kcvfhsta @138 0x0004 (KCVFHOFZ)
# 无需修改
复制
9. 修改 kcvfhtsn
BBED> p kcvfhtsn
sword kcvfhtsn @332 1
SQL> select file#,ts# from v$datafile;
FILE# TS#
---------- ----------
1 0
3 1
4 2
7 4
BBED> set file 1 block 1 offset 332 count 32
BBED> dump
File: /u01/app/oracle/oradata/ORCLT/system01.dbf (1)
Block: 1 Offsets: 332 to 363 Dba:0x00400001
------------------------------------------------------------------------
01000000 06005359 53415558 00000000 00000000 00000000 00000000 00000000
<32 bytes per line>
BBED> modify /x 00 offset 332
File: /u01/app/oracle/oradata/ORCLT/system01.dbf (1)
Block: 1 Offsets: 332 to 363 Dba:0x00400001
------------------------------------------------------------------------
00000000 06005359 53415558 00000000 00000000 00000000 00000000 00000000
<32 bytes per line>
BBED> sum apply
BBED> p kcvfhtsn
sword kcvfhtsn @332 0
复制
10. 修改 kcvfhtln 和 kcvfhtnm
BBED> p kcvfhtln
ub2 kcvfhtln @336 0x0006
# 长度一样,不修改了
BBED> p kcvfhtnm
text kcvfhtnm[0] @338 S
text kcvfhtnm[1] @339 Y
text kcvfhtnm[2] @340 S
text kcvfhtnm[3] @341 A
text kcvfhtnm[4] @342 U
text kcvfhtnm[5] @343 X
BBED> set file 1 block 1 offset 338 count 32
BBED> dump
File: /u01/app/oracle/oradata/ORCLT/system01.dbf (1)
Block: 1 Offsets: 338 to 369 Dba:0x00400001
------------------------------------------------------------------------
53595341 55580000 00000000 00000000 00000000 00000000 00000000 00000300
<32 bytes per line>
SQL> select dump('SYSAUX',16) from dual;
DUMP('SYSAUX',16)
-------------------------------
Typ=96 Len=6: 53,59,53,41,55,58
SQL> select dump('SYSTEM',16) from dual;
DUMP('SYSTEM',16)
-------------------------------
Typ=96 Len=6: 53,59,53,54,45,4d
BBED> set file 1 block 1 offset 341 count 32
BBED> dump
File: /u01/app/oracle/oradata/ORCLT/system01.dbf (1)
Block: 1 Offsets: 341 to 372 Dba:0x00400001
------------------------------------------------------------------------
41555800 00000000 00000000 00000000 00000000 00000000 00000003 00000000
<32 bytes per line>
BBED> modify /x 54454d
File: /u01/app/oracle/oradata/ORCLT/system01.dbf (1)
Block: 1 Offsets: 341 to 372 Dba:0x00400001
------------------------------------------------------------------------
54454d00 00000000 00000000 00000000 00000000 00000000 00000003 00000000
<32 bytes per line>
BBED> sum apply
BBED> p kcvfhtnm
text kcvfhtnm[0] @338 S
text kcvfhtnm[1] @339 Y
text kcvfhtnm[2] @340 S
text kcvfhtnm[3] @341 T
text kcvfhtnm[4] @342 E
text kcvfhtnm[5] @343 M
复制
12. 修改 kcvfhrfn
BBED> p kcvfhrfn
ub4 kcvfhrfn @368 0x00000003
SQL> select file#,rfile# from v$datafile;
FILE# RFILE#
---------- ----------
1 1
3 3
4 4
7 7
BBED> set file 1 block 1 offset 368 count 32
BBED> dump
File: /u01/app/oracle/oradata/ORCLT/system01.dbf (1)
Block: 1 Offsets: 368 to 399 Dba:0x00400001
------------------------------------------------------------------------
03000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
<32 bytes per line>
BBED> modify /x 01
File: /u01/app/oracle/oradata/ORCLT/system01.dbf (1)
Block: 1 Offsets: 368 to 399 Dba:0x00400001
------------------------------------------------------------------------
01000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
<32 bytes per line>
BBED> sum apply
BBED> p kcvfhrfn
ub4 kcvfhrfn @368 0x00000001
复制
13. 修改 kscnbas 和 kcvcptim
BBED> p kcvfhckp
struct kcvfhckp, 36 bytes @484
struct kcvcpscn, 8 bytes @484
ub4 kscnbas @484 0x00230ec2
ub4 kcvcptim @492 0x41cd85c8
SQL> set line 300
select file#,CREATION_CHANGE#,CHECKPOINT_CHANGE#,UNRECOVERABLE_CHANGE#,LAST_CHANGE#,OFFLINE_CHANGE# from v$datafile order by 1;
FILE# CREATION_CHANGE# CHECKPOINT_CHANGE# UNRECOVERABLE_CHANGE# LAST_CHANGE# OFFLINE_CHANGE#
---------- ---------------- ------------------ --------------------- ------------ ---------------
1 9 2297538 0 1920976
3 5480 2297538 0 1920976
4 1920446 2297538 0 1920976
7 32876 2297538 0 1920976
SQL> select to_char(2297538,'xxxxxxxxxxxxxxxx') from dual;
TO_CHAR(2297538,
-----------------
230ec2
# CHECKPOINT_CHANGE# 都一样,不用改了
SQL> select file#,to_char(CHECKPOINT_TIME,'yyyy-mm-dd hh24:mi:ss') CHECKPOINT_TIME_file, (to_char(CHECKPOINT_TIME,'yyyy')-1988)*12*31*24*3600
+(to_char(CHECKPOINT_TIME,'mm')-1)*31*24*3600
+(to_char(CHECKPOINT_TIME,'dd')-1)*24*3600
+to_char(CHECKPOINT_TIME,'hh24')*3600
+to_char(CHECKPOINT_TIME,'mi')*60
+to_char(CHECKPOINT_TIME,'ss') CHECKPOINT_TIME_scn
from v$datafile order by 1;
FILE# CHECKPOINT_TIME_FIL CHECKPOINT_TIME_SCN
---------- ------------------- -------------------
1 2022-05-06 15:22:48 1103988168
3 2022-05-06 15:22:48 1103988168
4 2022-05-06 15:22:48 1103988168
7 2022-05-06 15:22:48 1103988168
SQL> select to_char(1103988168,'xxxxxxxxxxxxxxxxxxxxxxx') from dual;
TO_CHAR(1103988168,'XXXX
------------------------
41cd85c8
# CHECKPOINT_TIME_SCN 都一样,也不用改了
复制
通过dbv检查下文件头修改是否都正确
[oracle@ora11g ~]$ dbv file=/u01/app/oracle/oradata/ORCLT/system01.dbf start=1 end=2 DBVERIFY: Release 19.0.0.0.0 - Production on Fri May 6 18:36:55 2022 Copyright (c) 1982, 2019, Oracle and/or its affiliates. All rights reserved. DBVERIFY - Verification starting : FILE = /u01/app/oracle/oradata/ORCLT/system01.dbf DBVERIFY - Verification complete Total Pages Examined : 2 Total Pages Processed (Data) : 0 Total Pages Failing (Data) : 0 Total Pages Processed (Index): 0 Total Pages Failing (Index): 0 Total Pages Processed (Other): 2 Total Pages Processed (Seg) : 0 Total Pages Failing (Seg) : 0 Total Pages Empty : 0 Total Pages Marked Corrupt : 0 Total Pages Influx : 0 Total Pages Encrypted : 0 Highest block SCN : 2191822 (0.2191822)
复制
OPEN数据库
SQL> alter database open;
Database altered.
复制
最后修改时间:2022-05-06 13:47:25
「喜欢这篇文章,您的关注和赞赏是给作者最好的鼓励」
关注作者
【版权声明】本文为墨天轮用户原创内容,转载时必须标注文章的来源(墨天轮),文章链接,文章作者等基本信息,否则作者和墨天轮有权追究责任。如果您发现墨天轮中有涉嫌抄袭或者侵权的内容,欢迎发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。
评论
真正圆满的人生,是在遗憾中珍惜当下,是在不足中感恩拥有。
11月前

评论
👍
1年前

评论
您好,您的文章已入选墨力原创作者计划合格奖,10墨值奖励已经到账请查收!
❤️我们还会实时派发您的流量收益。
2年前

评论
相关阅读
Oracle RAC 一键安装翻车?手把手教你如何排错!
Lucifer三思而后行
549次阅读
2025-04-15 17:24:06
【纯干货】Oracle 19C RU 19.27 发布,如何快速升级和安装?
Lucifer三思而后行
472次阅读
2025-04-18 14:18:38
Oracle SQL 执行计划分析与优化指南
Digital Observer
451次阅读
2025-04-01 11:08:44
XTTS跨版本迁移升级方案(11g to 19c RAC for Linux)
zwtian
445次阅读
2025-04-08 09:12:48
墨天轮个人数说知识点合集
JiekeXu
445次阅读
2025-04-01 15:56:03
【ORACLE】记录一些ORACLE的merge into语句的BUG
DarkAthena
438次阅读
2025-04-22 00:20:37
【ORACLE】你以为的真的是你以为的么?--ORA-38104: Columns referenced in the ON Clause cannot be updated
DarkAthena
414次阅读
2025-04-22 00:13:51
Oracle数据库一键巡检并生成HTML结果,免费脚本速来下载!
陈举超
413次阅读
2025-04-20 10:07:02
Oracle 19c RAC更换IP实战,运维必看!
szrsu
393次阅读
2025-04-08 23:57:08
【活动】分享你的压箱底干货文档,三篇解锁进阶奖励!
墨天轮编辑部
359次阅读
2025-04-17 17:02:24
TA的专栏
目录