[20140624]bbed修改資料記錄(不等長).txt

lfree發表於2014-06-25

[20140624]bbed修改資料記錄(不等長).txt

http://www.itpub.net/thread-1872851-1-1.html

--給出的問題修改記錄時,長度沒有變化,如果存在變化,修改與原來的不同,要修改kdbr[0]的值.
--還有一些細節的步驟.

SCOTT@test> @ver

BANNER
--------------------------------------------------------------------------------
Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production

create table itpub_t1 (id int,name varchar2(100));
insert into itpub_t1 values(1,'AAAAA');
insert into itpub_t1 values(2,'BBBBB');
commit;
alter system checkpoint;


SCOTT@test> SCOTT@test> select rowid,itpub_t1.* from itpub_t1;
ROWID                      ID NAME
------------------ ---------- --------------------
AABF2LAAEAAAAJEAAA          1 AAAAA
AABF2LAAEAAAAJEAAB          2 BBBBB

SCOTT@test> @lookup_rowid  AABF2LAAEAAAAJEAAA
    OBJECT       FILE      BLOCK        ROW DBA                  TEXT
---------- ---------- ---------- ---------- -------------------- ----------------------------------------
    286091          4        580          0 4,580                alter system dump datafile 4 block 580 ;


--bbed觀察:
BBED> set dba 4,580
        DBA             0x01000244 (16777796 4,580)

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

BBED> x /rnc
rowdata[12]                                 @8176
-----------
flag@8176: 0x2c (KDRHFL, KDRHFF, KDRHFH)
lock@8177: 0x01
cols@8178:    2

col    0[2] @8179: 1
col    1[5] @8182: AAAAA
-- 行記錄偏移在8176.

update itpub_t1 set name='1234' where name='AAAAA';
commit;

SCOTT@test> select rowid,itpub_t1.* from itpub_t1;
ROWID                      ID NAME
------------------ ---------- --------------------
AABF2LAAEAAAAJEAAA          1 1234
AABF2LAAEAAAAJEAAB          2 BBBBB

alter system checkpoint;

--bbed觀察:
BBED> set dba 4,580
        DBA             0x01000244 (16777796 4,580)

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

BBED> x /rnc
rowdata[0]                                  @8153
----------
flag@8153: 0x2c (KDRHFL, KDRHFF, KDRHFH)
lock@8154: 0x02
cols@8155:    2

col    0[2] @8156: 1
col    1[4] @8159: 1234

BBED> set offset 8176
        OFFSET          8176

BBED> x /rnc
rowdata[23]                                 @8176
-----------
flag@8176: 0x2c (KDRHFL, KDRHFF, KDRHFH)
lock@8177: 0x00
cols@8178:    2

col    0[2] @8179: 1
col    1[5] @8182: AAAAA

--要恢復回來,僅僅需要修改kdbr[0] 的值=8076(少100,後面有說明).就ok了.
--關閉資料庫來操作看看.

BBED> p kdbr
sb2 kdbr[0]                                 @118      8053
sb2 kdbr[1]                                 @120      8064

--修改kdbr[0]=8076,而不是8176[注意要減少100.]
--這個很容易觀察,看現在的kdbr[0]=8053,對比前面的p *kdbr[0]看到的偏移量為8153,說明記錄的是相對偏移量.

BBED> p kdbr[0]
sb2 kdbr[0]                                 @118      8053

BBED> dump /v count 2
File: /u01/app/oracle11g/oradata/test/users01.dbf (4)
Block: 580   Offsets:  118 to  119                                      Dba:0x01000244
-----------------------------------------------------------------------------------------
751f                                  l u.

SYS@testdg> @10to16 8053
10 to 16 HEX   REVERSE16
-------------- ------------------
0000000001f75 0x751f0000
--正好對上的.注意修改時要小頭在前(我的cpu是intel系列的).

SYS@testdg> @10to16 8076
10 to 16 HEX   REVERSE16
-------------- ------------------
0000000001f8c 0x8c1f0000

BBED> modify  /x  8c1f offset 118
Warning: contents of previous BIFILE will be lost. Proceed? (Y/N) y
File: /u01/app/oracle11g/oradata/test/users01.dbf (4)
Block: 580  Offsets:  118 to  119                           Dba:0x01000244
----------------------------------------------------------------------------
8c1f

BBED> p kdbr[0]
sb2 kdbr[0]                                 @118      8076

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

BBED> x /rnc
rowdata[23]                                 @8176
-----------
flag@8176: 0x2c (KDRHFL, KDRHFF, KDRHFH)
lock@8177: 0x00
cols@8178:    2

col    0[2] @8179: 1
col    1[5] @8182: AAAAA

--已經指向了修改的位置,並且修改正確.

BBED> sum apply
Check value for File 4, Block 580:
current = 0x8473, required = 0x8473

BBED> verify
DBVERIFY - Verification starting
FILE = /u01/app/oracle11g/oradata/test/users01.dbf
BLOCK = 580

Block Checking: DBA = 16777796, Block Type = KTB-managed data block
data header at 0x2a98318264
kdbchk: xaction header lock count mismatch
        trans=2 ilk=1 nlo=0
Block 580 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

--依舊存在問題,沒有修改正確.
--仔細觀察lock@8154: 0x02 ,lock@8177: 0x00 不同,難道11g提交併沒有清楚這個標誌嗎?

BBED> modify  /x  02 offset 8177
BBED> modify  /x  00 offset 8154

BBED> sum apply
Check value for File 4, Block 580:
current = 0x8671, required = 0x8671

BBED> verify
DBVERIFY - Verification starting
FILE = /u01/app/oracle11g/oradata/test/users01.dbf
BLOCK = 580

Block Checking: DBA = 16777796, Block Type = KTB-managed data block
data header at 0x2a98318264
kdbchk: the amount of space used is not equal to block size
        used=46 fsc=1 avsp=8042 dtl=8088
Block 580 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
Message 531 not found;  product=RDBMS; facility=BBED

--還有有問題.好像記錄長度變化,導致一些記錄資訊不對.

BBED> p kdbh
struct kdbh, 14 bytes                       @100
   ub1 kdbhflag                             @100      0x00 (NONE)
   sb1 kdbhntab                             @101      1
   sb2 kdbhnrow                             @102      2
   sb2 kdbhfrre                             @104     -1
   sb2 kdbhfsbo                             @106      22
   sb2 kdbhfseo                             @108      8053
   sb2 kdbhavsp                             @110      8042
   sb2 kdbhtosp                             @112      8043

BBED> dump /v offset 110 count 4
File: /u01/app/oracle11g/oradata/test/users01.dbf (4)
Block: 580                                                         Offsets:  110 to  113                                                      Dba:0x01000244
---------------------------------------------------------------------------------------------------------------------------------------------------------------
6a1f6b1f                                                                                                    l j.k.

<48 bytes per line>

BBED> modify /x 6b1f offset 110
File: /u01/app/oracle11g/oradata/test/users01.dbf (4)
Block: 580                                                                    Offsets:  110 to  113                                                                 Dba:0x01000244
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
6b1f6b1f

<80 bytes per line>

BBED> sum apply

BBED> verify
DBVERIFY - Verification starting
FILE = /u01/app/oracle11g/oradata/test/users01.dbf
BLOCK = 580

Block Checking: DBA = 16777796, Block Type = KTB-managed data block
data header at 0x2a98318264
kdbchk: the amount of space used is not equal to block size
        used=46 fsc=1 avsp=8043 dtl=8088
Block 580 failed with check code 6110

DBVERIFY - Verification complete


BBED>  p ktbbhitl
struct ktbbhitl[0], 24 bytes                @44
   struct ktbitxid, 8 bytes                 @44
      ub2 kxidusn                           @44       0x0005
      ub2 kxidslt                           @46       0x0008
      ub4 kxidsqn                           @48       0x00005d6c
   struct ktbituba, 8 bytes                 @52
      ub4 kubadba                           @52       0x00c003b3
      ub2 kubaseq                           @56       0x1ff2
      ub1 kubarec                           @58       0x08
   ub2 ktbitflg                             @60       0x8000 (KTBFCOM)
   union _ktbitun, 2 bytes                  @62
      sb2 _ktbitfsc                         @62       0
      ub2 _ktbitwrp                         @62       0x0000
   ub4 ktbitbas                             @64       0xc2e7c553
struct ktbbhitl[1], 24 bytes                @68
   struct ktbitxid, 8 bytes                 @68
      ub2 kxidusn                           @68       0x0005
      ub2 kxidslt                           @70       0x0012
      ub4 kxidsqn                           @72       0x00005d70
   struct ktbituba, 8 bytes                 @76
      ub4 kubadba                           @76       0x00c003b7
      ub2 kubaseq                           @80       0x1ff2
      ub1 kubarec                           @82       0x0a
   ub2 ktbitflg                             @84       0x2001 (KTBFUPB)
   union _ktbitun, 2 bytes                  @86
      sb2 _ktbitfsc                         @86       1
      ub2 _ktbitwrp                         @86       0x0001
   ub4 ktbitbas                             @88       0xc2e7c87f

--修改以下位置為0
      sb2 _ktbitfsc                         @86       1
      ub2 _ktbitwrp                         @86       0x0001

BBED> modify /x 00 offset 86
File: /u01/app/oracle11g/oradata/test/users01.dbf (4)
Block: 580                                                                    Offsets:   86 to   89                                                                 Dba:0x01000244
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
00007fc8


--
BBED> verify
DBVERIFY - Verification starting
FILE = /u01/app/oracle11g/oradata/test/users01.dbf
BLOCK = 580

Block Checking: DBA = 16777796, Block Type = KTB-managed data block
data header at 0x2a9835e264
kdbchk: the amount of space used is not equal to block size
        used=46 fsc=0 avsp=8043 dtl=8088
Block 580 failed with check code 6110

--依舊不行.修好avsp=8042看看.

BBED> modify /x 6a1f offset 110
File: /u01/app/oracle11g/oradata/test/users01.dbf (4)
Block: 580                                                                    Offsets:  110 to  113                                                                 Dba:0x01000244
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
6a1f6b1f

<80 bytes per line>

BBED> modify /x 6a1f offset 112
File: /u01/app/oracle11g/oradata/test/users01.dbf (4)
Block: 580                                                                    Offsets:  112 to  115                                                                 Dba:0x01000244
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
6a1f0000

<80 bytes per line>

BBED> sum apply
Check value for File 4, Block 580:
current = 0x8671, required = 0x8671

BBED> verify
DBVERIFY - Verification starting
FILE = /u01/app/oracle11g/oradata/test/users01.dbf
BLOCK = 580


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

--ok透過.

檢視資料庫:

SCOTT@test> select rowid,itpub_t1.* from itpub_t1;

ROWID                      ID NAME
------------------ ---------- --------------------
AABF2LAAEAAAAJEAAA          1 AAAAA
AABF2LAAEAAAAJEAAB          2 BBBBB

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/267265/viewspace-1193074/,如需轉載,請註明出處,否則將追究法律責任。

相關文章