【Oracle】使用bbed恢复update的数据

使用bbed不仅仅可以找回已经delete的数据还可以恢复update的数据,当然过程要比恢复delete的数据复杂一些。

实验过程如下:

[email protected]>create table bbed_test(x int,y varchar2(20));

Table created.

[email protected]>insert into bbed_test values(1,‘BADLY9‘);

1 row created.

[email protected]>insert into bbed_test values(2,‘JP‘);

1 row created.

[email protected]>commit;

Commit complete.

[email protected]>select rowid, dbms_rowid.rowid_relative_fno(rowid)rel_fno,

2  dbms_rowid.rowid_block_number(rowid)blockno,

3  dbms_rowid.rowid_row_number(rowid) rowno

4  from bbed_test;

ROWID                 REL_FNO    BLOCKNO      ROWNO

------------------ ---------- ---------- ----------

AAAM0WAABAAAOuCAAA          1      60290          0

AAAM0WAABAAAOuCAAB          1      60290          1

[email protected]>update bbed_test set y=‘JP1‘ where x=1;

1 row updated.

[email protected]>commit;

Commit complete.

[email protected]>select dump(1,‘16‘) from dual;

DUMP(1,‘16‘)

-----------------

Typ=2 Len=2: c1,2

[email protected]>select dump(2,‘16‘) from dual;

DUMP(2,‘16‘)

-----------------

Typ=2 Len=2: c1,3

[email protected]>select dump(‘BADLY9‘,16) from dual;

DUMP(‘BADLY9‘,16)

-------------------------------

Typ=96 Len=6: 42,41,44,4c,59,39

[email protected]>select dump(‘JP1‘,‘16‘) from dual;

DUMP(‘JP1‘,‘16‘)

----------------------

Typ=96 Len=3: 4a,50,31

[email protected]>select * from bbed_test;

X Y

---------- --------------------

1 JP1

2 JP

下面使用bbed进行查看

BBED> set dba 1,60290

DBA             0x0040eb82 (4254594 1,60290)

BBED> map

File: /u01/app/oracle/oradata/ORCL/system01.dbf (1)

Block: 60290                                 Dba:0x0040eb82

------------------------------------------------------------

KTB Data Block (Table/Cluster)

struct kcbh, 20 bytes                      @0

struct ktbbh, 72 bytes                     @20

struct kdbh, 14 bytes                      @92

struct kdbt[1], 4 bytes                    @106

sb2 kdbr[2]                                @110

ub1 freespace[8042]                        @114

ub1 rowdata[32]                            @8156

ub4 tailchk                                @8188

BBED> p kdbr

sb2 kdbr[0]                                 @110      8064

sb2 kdbr[1]                                 @112      8074

BBED> p *kdbr[1]

rowdata[10]

-----------

ub1 rowdata[10]                             @8166     0x2c

8166-8074=92

BBED> x /rnc

rowdata[10]                                 @8166

-----------

[email protected]: 0x2c (KDRHFL, KDRHFF, KDRHFH)

[email protected]: 0x00

[email protected]:    2

col    0[2] @8169: 2

col    1[2] @8172: JP

BBED> p *kdbr[0]

rowdata[0]

----------

ub1 rowdata[0]                              @8156     0x2c

BBED> x /rnc

rowdata[0]                                  @8156

----------

[email protected]: 0x2c (KDRHFL, KDRHFF, KDRHFH)

[email protected]: 0x02

[email protected]:    2

col    0[2] @8159: 1

col    1[3] @8162: JP1

BBED> set count 64

COUNT           64

BBED> d /v

File: /u01/app/oracle/oradata/ORCL/system01.dbf (1)

Block: 60290   Offsets: 8156 to 8191  Dba:0x0040eb82

-------------------------------------------------------

2c020202 c102034a 50312c00 0202c103 l ,...?..JP1,...?.

024a502c 000202c1 02064241 444c5939 l .JP,...?..BADLY9

0206d5a3                            l ..?

<16 bytes per line>

使用bbed找回历史值

通过dump出来的值,推算出来第一条记录的起点02c1 02064241 444c5939

在这个值的基础上offset-3得到offset的值为8175

8175-92=8083 1f93

BBED> p kdbr

sb2 kdbr[0]                                 @110      8064

sb2 kdbr[1]                                 @112      8074

--修改row directory指针位置

BBED> m /x 931f

File: /u01/app/oracle/oradata/ORCL/system01.dbf (1)

Block: 60290            Offsets:  110 to  173           Dba:0x0040eb82

------------------------------------------------------------------------

931f8a1f 02000000 02000200 791f321f 831e481e 00000000 00000000 00000000

00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000

<32 bytes per line>

BBED> p kdbr

sb2 kdbr[0]                                 @110      8083

sb2 kdbr[1]                                 @112      8074

BBED> sum apply

Check value for File 1, Block 60290:

current = 0x3e20, required = 0x3e20

BBED> verify

DBVERIFY - Verification starting

FILE = /u01/app/oracle/oradata/ORCL/system01.dbf

BLOCK = 60290

Block Checking: DBA = 4254594, Block Type = KTB-managed data block

data header at 0x79a25c

kdbchk: xaction header lock count mismatch

trans=2 ilk=1 nlo=0      --提示事务错误

Block 60290 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

BBED> p *kdbr[0]

rowdata[19]

-----------

ub1 rowdata[19]                             @8175     0x2c

BBED> d

File: /u01/app/oracle/oradata/ORCL/system01.dbf (1)

Block: 60290            Offsets: 8175 to 8191           Dba:0x0040eb82

------------------------------------------------------------------------

2c000202 c1020642 41444c59 390206d5 a3

<32 bytes per line>

BBED> x /rnc

rowdata[19]                                 @8175

-----------

[email protected]: 0x2c (KDRHFL, KDRHFF, KDRHFH)

[email protected]: 0x00    --被更新前的记录事务锁标识为0,而更新后的事务锁标识为2

[email protected]:    2

col    0[2] @8178: 1

col    1[6] @8181: BADLY9

--修改事务锁标识为2

BBED> m /x 02 offset +1

File: /u01/app/oracle/oradata/ORCL/system01.dbf (1)

Block: 60290            Offsets: 8176 to 8191           Dba:0x0040eb82

------------------------------------------------------------------------

020202c1 02064241 444c5939 0206d5a3

<32 bytes per line>

--把更新后值得事务锁标识改为0

BBED> set offset 8156

OFFSET          8156

BBED> m /x 00 offset +1

File: /u01/app/oracle/oradata/ORCL/system01.dbf (1)

Block: 60290            Offsets: 8157 to 8191           Dba:0x0040eb82

------------------------------------------------------------------------

000202c1 02034a50 312c0002 02c10302 4a502c02 0202c102 06424144 4c593902

06d5a3

<32 bytes per line>

BBED> sum apply

Check value for File 1, Block 60290:

current = 0x3c22, required = 0x3c22

BBED> verify

DBVERIFY - Verification starting

FILE = /u01/app/oracle/oradata/ORCL/system01.dbf

BLOCK = 60290

Block Checking: DBA = 4254594, Block Type = KTB-managed data block

data header at 0x28225c

kdbchk: the amount of space used is not equal to block size

used=44 fsc=3 avsp=8052 dtl=8096   --提示块的空间使用不正确

Block 60290 failed with check code 6110

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

此时要将所有itl的fsc全部改为0,然后将kdbh.kdbhavsp和kdbh.kdbhtosp的值改成相等,它们的值都等于dbv校验中显示的dtl-used。本次案例为8096-44 741f

BBED> p ktbbh

struct ktbbh, 72 bytes                      @20

ub1 ktbbhtyp                             @20       0x01 (KDDBTDATA)

union ktbbhsid, 4 bytes                  @24

ub4 ktbbhsg1                          @24       0x0000cd16

ub4 ktbbhod1                          @24       0x0000cd16

struct ktbbhcsc, 8 bytes                 @28

ub4 kscnbas                           @28       0x0007a3d3

ub2 kscnwrp                           @32       0x0000

b2 ktbbhict                              @36       7938

ub1 ktbbhflg                             @38       0x03 (KTBFONFL)

ub1 ktbbhfsl                             @39       0x00

ub4 ktbbhfnx                             @40       0x00000000

struct ktbbhitl[0], 24 bytes             @44

struct ktbitxid, 8 bytes              @44

ub2 kxidusn                        @44       0x0008

ub2 kxidslt                        @46       0x0009

ub4 kxidsqn                        @48       0x0000010e

struct ktbituba, 8 bytes              @52

ub4 kubadba                        @52       0x00800270

ub2 kubaseq                        @56       0x00c4

ub1 kubarec                        @58       0x02

ub2 ktbitflg                          @60       0x8000 (KTBFCOM)

union _ktbitun, 2 bytes               @62

b2 _ktbitfsc                       @62       0

ub2 _ktbitwrp                      @62       0x0000

ub4 ktbitbas                          @64       0x0007a37e

struct ktbbhitl[1], 24 bytes             @68

struct ktbitxid, 8 bytes              @68

ub2 kxidusn                        @68       0x0001

ub2 kxidslt                        @70       0x0024

ub4 kxidsqn                        @72       0x000000d5

struct ktbituba, 8 bytes              @76

ub4 kubadba                        @76       0x008000d8

ub2 kubaseq                        @80       0x0082

ub1 kubarec                        @82       0x38

ub2 ktbitflg                          @84       0x2001 (KTBFUPB)

union _ktbitun, 2 bytes               @86

b2 _ktbitfsc                       @86       3

ub2 _ktbitwrp                      @86       0x0003

ub4 ktbitbas                          @88       0x0007a3d5

BBED> m /x 00 offset 86

File: /u01/app/oracle/oradata/ORCL/system01.dbf (1)

Block: 60290            Offsets:   86 to  149           Dba:0x0040eb82

------------------------------------------------------------------------

0000d5a3 07000001 0200ffff 1600801f 741f771f 00000200 931f8a1f 02000000

02000200 791f321f 831e481e 00000000 00000000 00000000 00000000 00000000

<32 bytes per line>

BBED> sum apply

Check value for File 1, Block 60290:

current = 0x3c21, required = 0x3c21

BBED> p kdbh

struct kdbh, 14 bytes                       @92

ub1 kdbhflag                             @92       0x00 (NONE)

b1 kdbhntab                              @93       1

b2 kdbhnrow                              @94       2

sb2 kdbhfrre                             @96      -1

sb2 kdbhfsbo                             @98       22

sb2 kdbhfseo                             @100      8064

b2 kdbhavsp                              @102      8052

b2 kdbhtosp                              @104      8055

BBED> m /x 741f offset 102

File: /u01/app/oracle/oradata/ORCL/system01.dbf (1)

Block: 60290            Offsets:  102 to  165           Dba:0x0040eb82

------------------------------------------------------------------------

741f771f 00000200 931f8a1f 02000000 02000200 791f321f 831e481e 00000000

00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000

<32 bytes per line>

BBED> m /x 741f offset 104

File: /u01/app/oracle/oradata/ORCL/system01.dbf (1)

Block: 60290            Offsets:  104 to  167           Dba:0x0040eb82

------------------------------------------------------------------------

741f0000 0200931f 8a1f0200 00000200 0200791f 321f831e 481e0000 00000000

00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000

<32 bytes per line>

BBED> sum apply

Check value for File 1, Block 60290:

current = 0x3c22, required = 0x3c22

BBED> verify

DBVERIFY - Verification starting

FILE = /u01/app/oracle/oradata/ORCL/system01.dbf

BLOCK = 60290

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

此时数据块验证通过

现在回到库里进行验证:

[email protected]>alter system flush buffer_cache;

System altered.

[email protected]>select * from bbed_test;

X Y

---------- --------------------

1 BADLY9

2 JP

可以看到UPDATE之前的数据已经被恢复回来了。

实验过程参考飞总的文章:

http;//www.xifenfei.com/3704.html

【Oracle】使用bbed恢复update的数据

时间: 2024-10-13 05:23:21

【Oracle】使用bbed恢复update的数据的相关文章

利用BBED恢复UPDATE修改前的值

实验过程如下: 1.创建表guo_test1 [email protected]> create table guoyJoe_t1(id int,name varchar2(10)); Table created. [email protected]> insert into guoyJoe_t1 values(1,'guoyJoe'); 1 row created. [email protected]> insert into guoyJoe_t1 values(1,'tom'); 1

使用BBED恢复DELETE的数据

测试环境请参见 使用BBED手工提交事务 尝试恢复delete的数据: BBED> modify /x 2c offset 5064 File: /data/orcl/orcl/users01.dbf (4) Block: 68               Offsets: 5064 to 5071           Dba:0x01000044 ------------------------------------------------------------------------ 2

【Oracle】使用bbed恢复delete的数据

表中的数据被delete之后并不会真正删除数据,而是打了一个删除标记,仅仅要还没有被覆盖就能够恢复回来. 实验步骤例如以下: [email protected]>create table bbed_test(x varchar2(20)); Table created. [email protected]>insert into bbed_test values('BADLY9'); 1 row created. [email protected]>insert into bbed_te

利用BBED恢复数据文件头

转载请注明出处:http://blog.csdn.net/guoyjoe/article/details/31018075 @@@@@@@利用BBED模拟损坏5文件1号块(文件头) BBED> copy file 4 block 4 to file 5 block 1 File: /u01/app/oracle/oradata/PROD/tp01.dbf (5) Block: 1 Offsets: 0 to 19 Dba:0x01400001 --------------------------

利用 BBED 恢复非归档模式下 OFFLINE 数据文件

今天来模拟一个非归档模式下恢复OFFLINE数据文件的场景,主要有2种情况: 一种是在线日志没有被覆盖,另一种是在线日志被覆盖. 第一种情况比较简单,数据库自身就能处理,而第二种情况稍显复杂,但也并不难,下面开始整个实验过程: 一.在线日志没有被覆盖的场景 --切换数据库到非归档模式 SQL> archive log list Database log mode       Archive Mode Automatic archival       Enabled Archive destina

Oracle闪回查询恢复delete删除数据

Flashback query(闪回查询)原理 Oracle根据undo信息,利用undo数据,类似一致性读取方法,可以把表置于一个删除前的时间点(或SCN),从而将数据找回. Flashback query(闪回查询)前提: SQL> show parameter undo; NAME                                TYPE       VALUE ------------------------------------ ----------- --------

Oracle数据库备份恢复高级培训视频课程(案例、实战、深入、全面)

套餐介绍: 介绍:风哥Oracle数据库备份恢复培训(案例.实战.深入.全面),DBA初级到骨灰级的脱变. 内容:风哥Oracle数据库备份恢复及存储容灾基础,控制文件与参数文件详解,存储结构深入分析,Oracle底层技术,数据块解析,BBED深入解析,重做日志Redo深入解析,Undo回滚段深入解析,用户管理模式的备份恢复,RMAN备份恢复,Flashback闪回恢复管理,LogMiner日志挖掘技术,SQL_Loader,Oracle逻辑备份恢复迁移之exp/imp和expdp/impdp.

netbackup之oracle的备份恢复

1.1.1 挂载裸LUN 1. 挂载裸LUN,mount到/nbubakcup. 1.1.2 确认安装环境 1.确认磁盘空间 在AIX/Linux环境中,/usr/openv目录下需要3GB以上的剩余空间. 2.解析相关服务器主机名与备份通信的ip地址 我们需要在/etc/hosts文件中添加本机及Master Server的主机名及IP地址. 3.确认Media Server已经正确识别磁带驱动器及磁带库 运行lsdev –Cc tape命令查看Media Server已经正确识别磁带库与磁带

oracle 11g 数据库恢复技术 ---02 控制文件

[email protected] orcl >show parameter control_file NAME TYPE VALUE ------------------------------------ ----------- ------------------------------ control_file_record_keep_time integer 7 control_files string /u01/app/oracle/oradata/orcl/c ontrol01.c