文章详情

短信预约-IT技能 免费直播动态提醒

请输入下面的图形验证码

提交验证

短信预约提醒成功

利用BBED恢复UPDATE修改前的值

2024-04-02 19:55

关注

转载请注明出处:http://blog.csdn.net/guoyjoe/article/details/30615151

实验过程如下:


1、创建表guo_test1

gyj@PROD> create table guoyJoe_t1(id int,name varchar2(10));  Table created.  gyj@PROD> insert into guoyJoe_t1 values(1,'guoyJoe');  1 row created.  gyj@PROD> insert into guoyJoe_t1 values(1,'tom');  1 row created.  gyj@PROD> COMMIT;  Commit complete. 



2、查出这行记录的DBA

gyj@PROD> select name,dbms_rowid.rowid_relative_fno(rowid) file#,dbms_rowid.rowid_block_number(rowid) block#,dbms_rowid.rowid_row_number(rowid)    row# from guoyJoe_t1;  NAME            FILE#     BLOCK#       ROW# ---------- ---------- ---------- ---------- guoyJoe             5      20877          0 tom                 5      20877          1 


3、刷数据缓存

gyj@PROD> alter system flush buffer_cache;  System altered. 


4、利用BBED找到这行记录(修改前的值:guoyJoe)

BBED> BBED> set file 5    block 20877         FILE#           5         BLOCK#          20877 

--观察行头
BBED> p kdbr
sb2 kdbr[0]                                 @118      8074
sb2 kdbr[1]                                 @120      8064


BBED> p *kdbr[0]
rowdata[10]
-----------
ub1 rowdata[10]                             @8174     0x2c


--观察事务
BBBED> x /rnc
rowdata[10]                                 @8174    
-----------
flag@8174: 0x2c (KDRHFL, KDRHFF, KDRHFH)
lock@8175: 0x01
cols@8176:    2


col    0[2] @8177: 1 
col    1[7] @8180: guoyJoe


---观察空间
BBED> p kdbhavsp
sb2 kdbhavsp                                @110      8042


BBED> p kdbhtosp
sb2 kdbhtosp                                @112      8042


5、发生UPDATE语句,把原来的值guoyJoe修改成oracledba

gyj@PROD> update guoyJoe_t1 set name='oracledba' where name='guoyJoe';  1 row updated.  gyj@PROD> commit;  Commit complete


6、刷数据缓存

gyj@PROD> alter system flush buffer_cache;  System altered.


7、利用BBED找到这行被修改后的记录(修改后的值上:oracledba)

BBED> set file 5    block 20877         FILE#           5         BLOCK#          20877

--观察行头
BBED> p kdbr
sb2 kdbr[0]                                 @118      8048
sb2 kdbr[1]                                 @120      8064


BBED> p *kdbr[0]
rowdata[0]
----------
ub1 rowdata[0]                              @8148     0x2c


--观察事务
BBED> x /rnc
rowdata[0]                                  @8148    
----------
flag@8148: 0x2c (KDRHFL, KDRHFF, KDRHFH)
lock@8149: 0x01
cols@8150:    2


col    0[2] @8151: 1 
col    1[9] @8154: oracledba


---观察空间
BBED> p kdbhavsp
sb2 kdbhavsp                                @110      8040


BBED> p kdbhtosp  
sb2 kdbhtosp                                @112      8040


8、对比修改前与修改后的数据

BBED> d /v offset 8174 count 16  File: /u01/app/oracle/oradata/PROD/tp01.dbf (5)  Block: 20877   Offsets: 8174 to 8189  Dba:0x0140518d -------------------------------------------------------  2c000202 c1020767 756f794a 6f650106 l ,...á..guoyJoe..   BBED> d /v offset 8148 count 16  File: /u01/app/oracle/oradata/PROD/tp01.dbf (5)  Block: 20877   Offsets: 8148 to 8163  Dba:0x0140518d -------------------------------------------------------  2c010202 c102096f 7261636c 65646261 l ,...á..oracledba


9、开始恢复
(1)修改row directory指针位置(@118)
--修改前
BBED> p kdbr
sb2 kdbr[0]                                 @118      8074
--修改后
BBED> p kdbr
sb2 kdbr[0]                                 @118      8048
gyj@PROD> select to_char('8074','xxxxxxxxxxxxxx') from dual;


TO_CHAR('8074',
---------------
           1f8a


gyj@PROD> select to_char('8048','xxxxxxxxxxxxxx') from dual;


TO_CHAR('8048',
---------------
           1f70


BBED> d /v offset 118 count 16
 File: /u01/app/oracle/oradata/PROD/tp01.dbf (5)
 Block: 20877   Offsets:  118 to  133  Dba:0x0140518d
-------------------------------------------------------
 701f801f 00000000 00000000 00000000 l p...............




BBED> modify /x 8a offset 118
Warning: contents of previous BIFILE will be lost. Proceed? (Y/N) Y
 File: /u01/app/oracle/oradata/PROD/tp01.dbf (5)
 Block: 20877            Offsets:  118 to  133           Dba:0x0140518d
------------------------------------------------------------------------
 8a1f801f 00000000 00000000 00000000 


 <32 bytes per line>


BBED> sum apply
Check value for File 5, Block 20877:
current = 0x8a00, required = 0x8a00


BBED> verify
DBVERIFY - Verification starting
FILE = /u01/app/oracle/oradata/PROD/tp01.dbf
BLOCK = 20877


Block Checking: DBA = 20992397, Block Type = KTB-managed data block
data header at 0x7f76ff66e264
kdbchk: xaction header lock count mismatch  ----事务锁报错
        trans=1 ilk=1 nlo=0
Block 20877 failed with check code 6108


DBVERIFY - Verification complete


Total Blocks Examined         : 1
Total Blocks Processed (Data) : 1
Total Blocks Failing   (Data) : 1
Total Blocks Processed (Index): 0
Total Blocks Failing   (Index): 0
Total Blocks Empty            : 0
Total Blocks Marked Corrupt   : 0
Total Blocks Influx           : 0
Message 531 not found;  product=RDBMS; facility=BBED




(2)接下来修改事务锁
---把更新前值的事务锁标记从00改为01
BBBED> x /rnc
rowdata[10]                                 @8174    
-----------
flag@8174: 0x2c (KDRHFL, KDRHFF, KDRHFH)
lock@8175: 0x01
cols@8176:    2


BBED> d /v offset 8175 count 16
 File: /u01/app/oracle/oradata/PROD/tp01.dbf (5)
 Block: 20877   Offsets: 8175 to 8190  Dba:0x0140518d
-------------------------------------------------------
 000202c1 02076775 6f794a6f 6501066f l ...á..guoyJoe..o


BBED> modify /x 01 offset 8175
 File: /u01/app/oracle/oradata/PROD/tp01.dbf (5)
 Block: 20861            Offsets: 8175 to 8190           Dba:0x0140517d
------------------------------------------------------------------------
 010202c1 02076775 6f794a6f 650106ed 




--把更新后值的事务锁标识01改为00
BBED> x /rnc
rowdata[0]                                  @8148    
----------
flag@8148: 0x2c (KDRHFL, KDRHFF, KDRHFH)
lock@8149: 0x01
cols@8150:    2


BBED> d /v offset 8149 count 16
 File: /u01/app/oracle/oradata/PROD/tp01.dbf (5)
 Block: 20877   Offsets: 8149 to 8164  Dba:0x0140518d
-------------------------------------------------------
 010202c1 02096f72 61636c65 6462612c l ...á..oracledba,


BBED> modify /x 00 offset 8149
 File: /u01/app/oracle/oradata/PROD/tp01.dbf (5)
 Block: 20861            Offsets: 8159 to 8174           Dba:0x0140517d
------------------------------------------------------------------------
 000202c1 02096f72 61636c65 6462612c 


BBED> sum apply
Check value for File 5, Block 20877:
current = 0x8a00, required = 0x8a00


BBED> verify
DBVERIFY - Verification starting
FILE = /u01/app/oracle/oradata/PROD/tp01.dbf
BLOCK = 20877


Block Checking: DBA = 20992397, Block Type = KTB-managed data block
data header at 0x7cb464
kdbchk: the amount of space used is not equal to block size
        used=46 fsc=0 avsp=8040 dtl=8088 
    ---提示数据块的空间使用不正确(dtl-used=kdbhavsp=kdbhtosp)
       8088-46=8042 与 avsp=8040相关2,也就是说我要恢复到8042
     
 (3)修改空间,把空间修改为6a1f,以dtl-used=kdbhavsp为主
  gyj@PROD> select to_char('8042','xxxxxxxxxxxxxx') from dual;


      TO_CHAR('8042',
       ---------------
           1f6a
  BBED> modify /x 6a1f  offset 110
 File: /u01/app/oracle/oradata/PROD/tp01.dbf (5)
 Block: 20877            Offsets:  110 to  125           Dba:0x0140518d
------------------------------------------------------------------------
 6a1f681f 00000200 8a1f801f 00000000 


 <32 bytes per line>


BBED> modify /x 6a1f  offset 112
 File: /u01/app/oracle/oradata/PROD/tp01.dbf (5)
 Block: 20877            Offsets:  112 to  127           Dba:0x0140518d
------------------------------------------------------------------------
 6a1f0000 02008a1f 801f0000 00000000 


 <32 bytes per line>


BBED> sum apply
Check value for File 5, Block 20877:
current = 0x8a00, required = 0x8a00


BBED> verify
DBVERIFY - Verification starting
FILE = /u01/app/oracle/oradata/PROD/tp01.dbf
BLOCK = 20877




DBVERIFY - Verification complete


Total Blocks Examined         : 1
Total Blocks Processed (Data) : 1
Total Blocks Failing   (Data) : 0
Total Blocks Processed (Index): 0
Total Blocks Failing   (Index): 0
Total Blocks Empty            : 0
Total Blocks Marked Corrupt   : 0
Total Blocks Influx           : 0
Message 531 not found;  product=RDBMS; facility=BBED


10、恢复成功(oracledba--->guoyJoe)

gyj@PROD> alter system flush buffer_cache;  System altered.  gyj@PROD> select name,dbms_rowid.rowid_relative_fno(rowid) file#,dbms_rowid.rowid_block_number(rowid) block#,dbms_rowid.rowid_row_number(rowid)    row# from guoyJoe_t1 where id=1;  NAME            FILE#     BLOCK#       ROW# ---------- ---------- ---------- ---------- guoyJoe             5      20877          0 tom                 5      20877          1 


实际上用BBED恢复UPDATE前的值不难,主要是要了解内部原理和块格式
总结如下:
 (1)修改行头
 (2)修改事务
 (3)修改空间

阅读原文内容投诉

免责声明:

① 本站未注明“稿件来源”的信息均来自网络整理。其文字、图片和音视频稿件的所属权归原作者所有。本站收集整理出于非商业性的教育和科研之目的,并不意味着本站赞同其观点或证实其内容的真实性。仅作为临时的测试数据,供内部测试之用。本站并未授权任何人以任何方式主动获取本站任何信息。

② 本站未注明“稿件来源”的临时测试数据将在测试完成后最终做删除处理。有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341

软考中级精品资料免费领

  • 历年真题答案解析
  • 备考技巧名师总结
  • 高频考点精准押题
  • 2024年上半年信息系统项目管理师第二批次真题及答案解析(完整版)

    难度     813人已做
    查看
  • 【考后总结】2024年5月26日信息系统项目管理师第2批次考情分析

    难度     354人已做
    查看
  • 【考后总结】2024年5月25日信息系统项目管理师第1批次考情分析

    难度     318人已做
    查看
  • 2024年上半年软考高项第一、二批次真题考点汇总(完整版)

    难度     435人已做
    查看
  • 2024年上半年系统架构设计师考试综合知识真题

    难度     224人已做
    查看

相关文章

发现更多好内容

猜你喜欢

AI推送时光机
位置:首页-资讯-数据库
咦!没有更多了?去看看其它编程学习网 内容吧
首页课程
资料下载
问答资讯