暂无图片
暂无图片
1
暂无图片
暂无图片
暂无图片

oracle 19c 通过bbed copy 修复文件头

原创 四九年入国军 2025-05-16
131
--模拟坏头损坏
dd if=/dev/zero of=/oradata/ORCL/users01.dbf  bs=8192 seek=1 count=1 conv=notrunc
startup
ORA-01122: database file 7 failed verification check
ORA-01110: data file 7: '/oradata/ORCL/users01.dbf'
ORA-01210: data file header is media corrupt



BBED> info
 File#  Name                                                        Size(blks)
 -----  ----                                                        ----------
     1  /oradata/ORCL/system01.dbf                                           0
     3  /oradata/ORCL/sysaux01.dbf                                           0
     4  /oradata/ORCL/undotbs01.dbf                                          0
     5  /oradata/ORCL/test01.dbf                                             0
     7  /oradata/ORCL/users01.dbf                                            0




--把5号文件头复制过去copy  dba 5,1 to dba 7,1



1>修改 rdba地址,offset 4
BBED> d /v dba  7,1 offset  4 count 10
 File: /oradata/ORCL/users01.dbf (7)
 Block: 1       Offsets:    4 to   13  Dba:0x01c00001
-------------------------------------------------------
 01004001 00000000 0000              l ..@.......
 --应该修改成 0100c001
 
 modify /x 0100c001 dba  7,1 offset  4
 p kcvfhbfh



2>修改文件大小,offset 44

BBED> d /v offset 44 count 10                   --0x00003200
 File: /oradata/ORCL/users01.dbf (7)
 Block: 1       Offsets:   44 to   53  Dba:0x01c00001
-------------------------------------------------------
 00320000 00200000 0500              l .2... ....
 
 --修改成0x00000280
 modify /x 8002 offset  44 
 p kcvfhhdr

3>修改datafile 文件号:offset 52

BBED> d/ v offset  52 count 10
 File: /oradata/ORCL/users01.dbf (7)
 Block: 1       Offsets:   52 to   61  Dba:0x01c00001
-------------------------------------------------------
 05000300 00000000 0000  
 -- 5 改成7
 modify /x 07 offset  52
 p kcvfhhdr
  
 
4>修改v$datafile.creation_change#: offset 100   --可以从控制文件中查

BBED> d /v dba 7,1 offset 100 count 10
 File: /oradata/ORCL/users01.dbf (7)
 Block: 1       Offsets:  100 to  109  Dba:0x01c00001
-------------------------------------------------------
 60fb1f00 00800000 2c07              l `.......,.               --存放值  0x001ffb60
 

--0806c 
modify /x 6c8000  offset  100  
p kcvfhcrs


5>修改v$datafile.creation_time: offset 108  --等8位一起修改的时候如果第一位大于8会报错


BBED> d /v offset 108 count 10
 File: /oradata/ORCL/users01.dbf (7)
 Block: 1       Offsets:  108 to  117  Dba:0x01c00001
-------------------------------------------------------
 2c077947 75174047 d14f              l ,.yGu.@G.O               --0x4779072c
 
 
 --需要修改成 3bf312e4
  
modify /x e412f33b offset 108 
--BBED-00209: invalid number (e412f33b)


--8位修改的时候第一个大于8会报错invalid number
--可以两位两位修改
modify /x e4 offset 108
modify /x 12 offset 109
modify /x f3 offset 110
modify /x 3b offset 111

--可以8位一起修改,第一位故意写成小于8的
modify /x 7412f33b offset 108
modify /x e4 offset 108

--如果是单个属性值,可以采用16进行直接进行修改,如

assign kcvfh.kcvfhcrs.kcvfhcrt=0x3bf312e4



 

6>修改表空间编号 v$tablespace.ts#:offset  332 

d /v offset 332 
 Block: 1       Offsets:  332 to  341  Dba:0x01c00001
-------------------------------------------------------
 06000000 04005445 5354              l ......TEST
 
 --6 修改成4
 modify /x 04 offset 332

7> v$datafile.rfile# 相对文件号:offset  368

d /v offset 368 
 File: /oradata/ORCL/users01.dbf (7)
 Block: 1       Offsets:  368 to  377  Dba:0x01c00001
-------------------------------------------------------
 05000000 00000000 0000    

modify /x 07 offset 368
 

8> v$datafile.rfile# 相对文件号:offset  338+ 

modify /c U OFFSET 338
modify /c S offset 339
modify /c E offset 340
modify /c R offset 341
modify /c S offset 342



9> 表空间长度:offset 336  

 d /v offset  336
 File: /oradata/ORCL/users01.dbf (7)
 Block: 1       Offsets:  336 to  345  Dba:0x01c00001
-------------------------------------------------------
 04005553 45525300 0000              l ..USERS...
 
modify /x 05 offset 336 


10> checkpoint scn offset 484 

    复制的5号文件和7号文件的scn一样,不需要修改
col checkpoint_change# for 99999999999999
col name for  a50
select name,checkpoint_change# from v$datafile;

NAME                                               CHECKPOINT_CHANGE#
-------------------------------------------------- ------------------
/oradata/ORCL/system01.dbf                                    2353087
/oradata/ORCL/sysaux01.dbf                                    2353087
/oradata/ORCL/undotbs01.dbf                                   2353087
/oradata/ORCL/test01.dbf                                      2353087
/oradata/ORCL/users01.dbf                                     2353087



11> last  checkpoint_time :offset  492



--修复成功:

SQL> startup force
ORACLE instance started.

Total System Global Area 4680840344 bytes
Fixed Size                  8905880 bytes
Variable Size             872415232 bytes
Database Buffers         3791650816 bytes
Redo Buffers                7868416 bytes
Database mounted.
ORA-01113: file 7 needs media recovery
ORA-01110: data file 7: '/oradata/ORCL/users01.dbf'


SQL> recover datafile 7;
Media recovery complete.
SQL> alter database open;

Database altered.

「喜欢这篇文章,您的关注和赞赏是给作者最好的鼓励」
关注作者
【版权声明】本文为墨天轮用户原创内容,转载时必须标注文章的来源(墨天轮),文章链接,文章作者等基本信息,否则作者和墨天轮有权追究责任。如果您发现墨天轮中有涉嫌抄袭或者侵权的内容,欢迎发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。

评论