[20210304]bbed的assign命令.txt
[20210304]bbed的assign命令.txt
--//曾經寫過一篇bbed的assign命令,實際上使用它使得使用bbed變得更加簡單快捷,不用考慮大小頭問題,比modify修改更加方便快捷。
--//昨天偶然發現assign還可以不寫offset完成同樣的功能以及assign存在的一些弊端。我透過一個刪除記錄並恢復部分記錄來說明問題:
1.環境:
SCOTT@book> @ ver1
PORT_STRING VERSION BANNER
------------------------------ -------------- --------------------------------------------------------------------------------
x86_64/Linux 2.4.xx 11.2.0.4.0 Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
SCOTT@book> create table deptx as select * from dept;
Table created.
SCOTT@book> select rowid,deptx.* from deptx;
ROWID DEPTNO DNAME LOC
------------------ ---------- -------------- -------------
AAAWHpAAEAAAAKrAAA 10 ACCOUNTING NEW YORK
AAAWHpAAEAAAAKrAAB 20 RESEARCH DALLAS
AAAWHpAAEAAAAKrAAC 30 SALES CHICAGO
AAAWHpAAEAAAAKrAAD 40 OPERATIONS BOSTON
SCOTT@book> @ rowid AAAWHpAAEAAAAKrAAA
OBJECT FILE BLOCK ROW ROWID_DBA DBA TEXT
---------- ---------- ---------- ---------- -------------------- -------------------- ----------------------------------------
90601 4 683 0 0x10002AB 4,683 alter system dump datafile 4 block 683 ;
SCOTT@book> delete deptx where deptno in (20,40);
2 rows deleted.
SCOTT@book> commit ;
Commit complete.
SCOTT@book> alter system checkpoint ;
System altered.
2.嘗試恢復:
--//刪除後表示從0x2c->0x3c,注意不包括出現行遷移的情況。
$ echo -e "set dba 4,683\nset offset 0\n$(seq 4 | xargs -IQ echo -e 'find /x 3c curr \nset offset +2')" | rlbbed
BBED: Release 2.0.0.0.0 - Limited Production on Thu Mar 4 09:29:29 2021
Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved.
************* !!! For Oracle Internal Use only !!! ***************
BBED> set count 64
COUNT 64
BBED> set width 160
WIDTH 160
BBED> DBA 0x010002ab (16777899 4,683)
BBED> OFFSET 0
BBED> File: /mnt/ramdisk/book/users01.dbf (4)
Block: 683 Offsets: 146 to 209 Dba:0x010002ab
------------------------------------------------------------------------------------------------------------------------------------------------
3c1f241f 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
<64 bytes per line>
BBED> OFFSET 148
BBED> File: /mnt/ramdisk/book/users01.dbf (4)
Block: 683 Offsets: 8096 to 8159 Dba:0x010002ab
------------------------------------------------------------------------------------------------------------------------------------------------
3c020302 c1290a4f 50455241 54494f4e 5306424f 53544f4e 2c000302 c11f0553 414c4553 07434849 4341474f 3c020302 c1150852 45534541 52434806 44414c4c
<64 bytes per line>
BBED> OFFSET 8098
BBED> File: /mnt/ramdisk/book/users01.dbf (4)
Block: 683 Offsets: 8140 to 8191 Dba:0x010002ab
------------------------------------------------------------------------------------------------------------------------------------------------
3c020302 c1150852 45534541 52434806 44414c4c 41532c00 0302c10b 0a414343 4f554e54 494e4708 4e455720 594f524b 03068098
<64 bytes per line>
BBED> OFFSET 8142
BBED> BBED-00212: search string not found
BBED> OFFSET 8144
--//可以發現刪除表示偏移在8096,8140。
--//正常執行如下:
assign dba 4,683 offset 8096=0x2c
assign dba 4,683 offset 8140=0x2c
--//可以去掉offset,執行如下,這是我不小心寫錯才發現可以這樣操作:
assign dba 4,683 8096=0x2c
assign dba 4,683 8140=0x2c
BBED> assign dba 4,683 8096=0x2c
Warning: contents of previous BIFILE will be lost. Proceed? (Y/N) y
ub1 rowdata[0] @8096 0x2c
--//你可以發現修改的位置還是offset 8096的位置。
BBED> x /rncc dba 4,683 offset 8096
rowdata[0] @8096
----------
flag@8096: 0x2c (KDRHFL, KDRHFF, KDRHFH)
lock@8097: 0x02
cols@8098: 3
col 0[2] @8099: 40
col 1[10] @8102: OPERATIONS
col 2[6] @8113: BOSTON
BBED> sum apply dba 4,683
Check value for File 4, Block 683:
current = 0xe1d0, required = 0xe1d0
BBED> verify dba 4,683
DBVERIFY - Verification starting
FILE = /mnt/ramdisk/book/users01.dbf
BLOCK = 683
Block Checking: DBA = 16777899, Block Type = KTB-managed data block
data header at 0xf54e7c
kdbchk: the amount of space used is not equal to block size
used=98 fsc=42 avsp=7946 dtl=8064
Block 683 failed with check code 6110
--//我僅僅恢復1條,理論將修改fsc,這樣比較麻煩。
--//dtl - used -fsc = avsp.
--//8064-98-42 = 7924
BBED> set dba 4,683
DBA 0x010002ab (16777899 4,683)
BBED> p kdbh.kdbhavsp
sb2 kdbhavsp @134 7946
--//偏移在134. 佔2個位元組。
BBED> assign 134=7924;
sb2 kdbhavsp @134 7924
--//我還可以寫成:
BBED> assign 135=7925;
sb2 kdbhavsp @134 7925
--//bbed的assign會透過偏移計算正確的位置,對齊賦值。當然我並不建議這樣操作,最佳的方式應該執行如下:
BBED> assign kdbh.kdbhavsp=7924;
sb2 kdbhavsp @134 7924
BBED> sum apply dba 4,683
Check value for File 4, Block 683:
current = 0xe02e, required = 0xe02e
BBED> verify dba 4,683
DBVERIFY - Verification starting
FILE = /mnt/ramdisk/book/users01.dbf
BLOCK = 683
Block Checking: DBA = 16777899, Block Type = KTB-managed data block
data header at 0xf76e7c
kdbchk: space available on commit is incorrect
tosp=7992 fsc=42 stb=2 avsp=7924
Block 683 failed with check code 6111
--//avsp+stb+fsc=tosp.
--//7924+2+42 = 7968
BBED> p kdbh.kdbhtosp
sb2 kdbhtosp @136 7992
BBED> assign 136=7968
sb2 kdbhtosp @136 7968
BBED> sum apply dba 4,683
Check value for File 4, Block 683:
current = 0xe036, required = 0xe036
BBED> verify dba 4,683
DBVERIFY - Verification starting
FILE = /mnt/ramdisk/book/users01.dbf
BLOCK = 683
3.驗證看看。
SCOTT@book> alter system flush buffer_cache ;
System altered.
SCOTT@book> select rowid,deptx.* from deptx;
ROWID DEPTNO DNAME LOC
------------------ ---------- -------------- -------------
AAAWHpAAEAAAAKrAAA 10 ACCOUNTING NEW YORK
AAAWHpAAEAAAAKrAAC 30 SALES CHICAGO
AAAWHpAAEAAAAKrAAD 40 OPERATIONS BOSTON
--//恢復正確。
4.繼續嘗試:
--//不過我發現assign也存在1個缺點
BBED> p dba 4,683 kcbh
struct kcbh, 20 bytes @0
ub1 type_kcbh @0 0x06
ub1 frmt_kcbh @1 0xa2
ub1 spare1_kcbh @2 0x00
ub1 spare2_kcbh @3 0x00
ub4 rdba_kcbh @4 0x010002ab
ub4 bas_kcbh @8 0x17689880
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
ub2 wrp_kcbh @12 0x0003
ub1 seq_kcbh @14 0x03
ub1 flg_kcbh @15 0x06 (KCBHFDLC, KCBHFCKV)
ub2 chkval_kcbh @16 0xe036
ub2 spare3_kcbh @18 0x0000
--//嘗試修改kcbh.bas_kcbh.
BBED> assign 8=0x77689880
ub4 bas_kcbh @8 0x77689880
--//0x77689880 = 2003343488
BBED> assign 8=2003343488
ub4 bas_kcbh @8 0x77689880
--//10,16 進位制一樣沒有問題。
--//但是這樣修改存在缺點:
BBED> assign 8=0x87689880
BBED-00206: out of range offset (87689880)
--//第1位不能大於0x8.
--//0x87689880 = 2271778944
BBED> assign 8=2271778944
BBED-00207: invalid offset specifier (2271778944)
BBED> assign 8=0xa7689880
BBED-00207: invalid offset specifier (a7689880)
--//0xa7689880 = 2808649856
BBED> assign 8=2808649856
BBED-00207: invalid offset specifier (2808649856)
--//注意兩個提示無一樣。
--//也就是assign無法修改4位元組內容時,第1位不能是大於0x8.
BBED> assign kcbh.bas_kcbh=0x87689880
BBED-00206: out of range offset (87689880)
BBED> assign kcbh.bas_kcbh=0xa7689880
BBED-00207: invalid offset specifier (a7689880)
--//如果你的修改遇到這樣的情況就比較麻煩了,感覺這個是bbed的bug。
BBED> assign kcbh.bas_kcbh=0x17689880
ub4 bas_kcbh @8 0x17689880
BBED> assign offset 8 = 0xa7
ub4 bas_kcbh @8 0x000000a7
--//你可以發現這個時候assign將偏移轉換為一個整體,只能使用modify修改,實際上modify一樣有這個問題存在。
--//注意modify修改要考慮大小頭問題。
--//我以前的測試:
BBED> modify /x 8affffff dba 101,1 offset 40
BBED-00209: invalid number (8affffff)
------------
--//還原:
BBED> assign kcbh.bas_kcbh=0x17689880
ub4 bas_kcbh @8 0x17689880
5.總結:
--//總之知道bbed assign與modify這些缺點,才能更好的利用這個工具。
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/267265/viewspace-2761047/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- [20210920]bbed的assign命令.txt
- [20180628]顯示bbed x命令格式.txt
- [20180627]測試bbed是否支援管道命令.txt
- [20231109]bbed p命令dba引數問題.txt
- [20210218]Select vs Assign – How To Assign PLSQL Variables.txtSQL
- [20181227]bbed的使用問題.txt
- [20181204]bbed修改問題.txt
- [20180619]bbed verify問題.txt
- [20231008]bbed探究lob段.txt
- [20220223]bbed ktbbh.ktbbhict.txt
- 【BBED】Oracle bbed常用命令參考Oracle
- [20210906]bbed讀取資料塊(bbed-wrap.sh).txt
- [20231021]生成bbed的執行指令碼.txt指令碼
- [20190104]bbed手工插入資料.txt
- [20210901]cygwin下使用bbed.txt
- [20230224]bbed設定偏移技巧.txt
- [20210303]bbed使用小問題.txt
- [20210223]bbed itl ktbitflg 2.txt
- [20210930]bbed恢復刪除的資料.txt
- [20190104]bbed手動修改資料.txt
- [20210318]bbed讀取資料塊.txt
- [20210311]如何建立bbed安裝包.txt
- [20231023]生成bbed的執行指令碼(bash shell).txt指令碼
- [20210304]關於11g一致性讀取的測試.txt
- [20230427]bbed sum apply問題2.txtAPP
- [20180604]在記憶體修改資料(bbed).txt記憶體
- [20210817]如何通過bbed確定undo段.txt
- [20210831]bbed讀取資料塊6.txt
- [20210323]bbed讀取資料塊5.txt
- [20210318]bbed讀取資料塊2.txt
- [20210319]bbed讀取資料塊3.txt
- [20231020]rename IDL_UB1$後使用bbed的恢復.txt
- [20190213]學習bbed-恢復刪除的資料.txt
- [20181122]bbed人為修改事務提交標誌.txt
- [20231026]bbed檢視索引kd_off結構的問題.txt索引
- [20220909]bbed關於刪除記錄恢復的問題.txt
- [20210930]bbed讀取資料塊7 fffext.sh.txt
- [20190124]bbed恢復資料遇到延遲塊清除的問題.txt