您好,登錄后才能下訂單哦!
BBED是用來直接查看和修改數據文件數據的一個工具,是Oracle一款內部工具,可以直接修改Oracle數據文件塊的內容,在一些極端恢復場景下比較有用。要想使用該工具,需用戶自己安裝,在Oracle 9i和10g版本中,安裝的方法很簡單:
[oracle@node1 u01]$ cd $ORACLE_HOME/rdbms/lib/
[oracle@node1 lib]$ make -f ins_rdbms.mk $ORACLE_HOME/rdbms/lib/bbed
Linking BBED utility (bbed)
rm -f /u01/app/oracle/10.2.0/db_1/rdbms/lib/bbed
gcc -o /u01/app/oracle/10.2.0/db_1/rdbms/lib/bbed -L/u01/app/oracle/10.2.0/db_1/rdbms/lib/ -L/u01/app/oracle/10.2.0/db_1/lib/ -L/u01/app/oracle/10.2.0/db_1/lib/stubs/ -L/usr/lib -lirc /u01/app/oracle/10.2.0/db_1/lib/s0main.o /u01/app/oracle/10.2.0/db_1/rdbms/lib/ssbbded.o /u01/app/oracle/10.2.0/db_1/rdbms/lib/sbbdpt.o `cat /u01/app/oracle/10.2.0/db_1/lib/ldflags` -lnsslb10 -lncrypt10 -lnsgr10 -lnzjs10 -ln10 -lnnz10 -lnl10 /u01/app/oracle/10.2.0/db_1/rdbms/lib/defopt.o -ldbtools10 -lclntsh `cat /u01/app/oracle/10.2.0/db_1/lib/ldflags` -lnsslb10 -lncrypt10 -lnsgr10 -lnzjs10 -ln10 -lnnz10 -lnl10 -lnro10 `cat /u01/app/oracle/10.2.0/db_1/lib/ldflags` -lnsslb10 -lncrypt10 -lnsgr10 -lnzjs10 -ln10 -lnnz10 -lnl10 -lclient10 -lnnetd10 -lvsn10 -lcommon10 -lgeneric10 -lmm -lsnls10 -lnls10 -lcore10 -lsnls10 -lnls10 -lcore10 -lsnls10 -lnls10 -lxml10 -lcore10 -lunls10 -lsnls10 -lnls10 -lcore10 -lnls10 `cat /u01/app/oracle/10.2.0/db_1/lib/ldflags` -lnsslb10 -lncrypt10 -lnsgr10 -lnzjs10 -ln10 -lnnz10 -lnl10 -lnro10 `cat /u01/app/oracle/10.2.0/db_1/lib/ldflags` -lnsslb10 -lncrypt10 -lnsgr10 -lnzjs10 -ln10 -lnnz10 -lnl10 -lclient10 -lnnetd10 -lvsn10 -lcommon10 -lgeneric10 -lsnls10 -lnls10 -lcore10 -lsnls10 -lnls10 -lcore10 -lsnls10 -lnls10 -lxml10 -lcore10 -lunls10 -lsnls10 -lnls10 -lcore10 -lnls10 -lclient10 -lnnetd10 -lvsn10 -lcommon10 -lgeneric10 -lsnls10 -lnls10 -lcore10 -lsnls10 -lnls10 -lcore10 -lsnls10 -lnls10 -lxml10 -lcore10 -lunls10 -lsnls10 -lnls10 -lcore10 -lnls10 `cat /u01/app/oracle/10.2.0/db_1/lib/sysliblist` -Wl,-rpath,/u01/app/oracle/10.2.0/db_1/lib -lm `cat /u01/app/oracle/10.2.0/db_1/lib/sysliblist` -ldl -lm -L/u01/app/oracle/10.2.0/db_1/lib
Oracle11g中缺省不提供BBET庫文件,如果需要可以將10g中的文件copy到11g相應目錄再執行安裝:
$ORACLE_HOME/rdbms/lib/ssbbded.o
$ORACLE_HOME/rdbms/lib/sbbdpt.o
$ORACLE_HOME/rdbms/mesg/bbedus.msb
$ORACLE_HOME/rdbms/mesg/bbedus.msg
在第一次使用時會發現有默認的口令,從這里可以看出oracle對bbed工具的限制,默認的密碼是blockedit
[oracle@node1 ~]$ cd $ORACLE_HOME/rdbms/lib
[oracle@node1 lib]$ ./bbed
Password:
BBED: Release 2.0.0.0.0 - Limited Production on Thu Jul 10 16:09:57 2014
Copyright (c) 1982, 2005, Oracle. All rights reserved.
************* !!! For Oracle Internal Use only !!! ***************
查看一下bbed 命令
BBED> help all
SET DBA [ dba | file#, block# ]
SET FILENAME 'filename'
SET FILE file#
SET BLOCK [+/-]block#
SET OFFSET [ [+/-]byte offset | symbol | *symbol ]
SET BLOCKSIZE bytes
SET LIST[FILE] 'filename'
SET WIDTH character_count
SET COUNT bytes_to_display
SET IBASE [ HEX | OCT | DEC ]
SET OBASE [ HEX | OCT | DEC ]
SET MODE [ BROWSE | EDIT ]
SET SPOOL [ Y | N ]
SHOW [ <SET parameter> | ALL ]
INFO
MAP[/v] [ DBA | FILENAME | FILE | BLOCK ]
DUMP[/v] [ DBA | FILENAME | FILE | BLOCK | OFFSET | COUNT ]
PRINT[/x|d|u|o|c] [ DBA | FILE | FILENAME | BLOCK | OFFSET | symbol | *symbol ]
EXAMINE[/Nuf] [ DBA | FILE | FILENAME | BLOCK | OFFSET | symbol | *symbol ]
</Nuf>:
N - a number which specifies a repeat count.
u - a letter which specifies a unit size:
b - b1, ub1 (byte)
h - b2, ub2 (half-word)
w - b4, ub4(word)
r - Oracle table/index row
f - a letter which specifies a display format:
x - hexadecimal
d - decimal
u - unsigned decimal
o - octal
c - character (native)
n - Oracle number
t - Oracle date
i - Oracle rowid
FIND[/x|d|u|o|c] numeric/character string [ TOP | CURR ]
COPY [ DBA | FILE | FILENAME | BLOCK ] TO [ DBA | FILE | FILENAME | BLOCK ]
MODIFY[/x|d|u|o|c] numeric/character string
[ DBA | FILE | FILENAME | BLOCK | OFFSET | symbol | *symbol ]
ASSIGN[/x|d|u|o] <target spec>=<source spec>
<target spec> : [ DBA | FILE | FILENAME | BLOCK | OFFSET | symbol | *symbol ]
<source spec> : [ value | <target spec options> ]
SUM [ DBA | FILE | FILENAME | BLOCK ] [ APPLY ]
PUSH [ DBA | FILE | FILENAME | BLOCK | OFFSET ]
POP [ALL]
REVERT [ DBA | FILE | FILENAME | BLOCK ]
UNDO
HELP [ <bbed command> | ALL ]
VERIFY [ DBA | FILE | FILENAME | BLOCK ]
CORRUPT [ DBA | FILE | FILENAME | BLOCK ]
set 設定當前的環境
show 查看當前的環境參數,跟sqlplus的同名命令類似。
dump 列出指定block的內容
find 在指定的block中查找指定的字符串,結果是顯示出字符串,及其偏移量--offset,偏移量就是在block中的字節數
modify 修改指定block的指定偏移量的值,可以在線修改。
copy 把一個block的內容copy到另一個block中
verify 檢查當前環境是否有壞塊
sum 計算block的checksum,modify之后block就被標識為壞塊,current checksum與reqired checksum不一致,sum命令可以計算出新的checksum并應用到當前塊。
undo 回滾當前的修改操作,如果手誤做錯了,undo一下就ok了,回到原來的狀態。
revert 回滾所有之前的修改操作,意思就是 undo all
為bbed配置一個參數文本
制作bbed列表
SQL> set heading off;
SQL> set feedback off;
SQL> spool /u01/bbedlist.parf
SQL> select file#||' '||name||' '||bytes from v$datafile ;
1 /u01/app/oracle/oradata/orcl_dup/system01.dbf 524288000
3 /u01/app/oracle/oradata/orcl_dup/sysaux01.dbf 346030080
4 /u01/app/oracle/oradata/orcl_dup/users01.dbf 191365120
5 /u01/app/oracle/oradata/orcl_dup/example01.dbf 104857600
6 /u01/app/oracle/oradata/orcl_dup/tts01.dbf 20971520
7 /u01/app/oracle/oradata/orcl_dup/tts02.dbf 20971520
8 /u01/app/oracle/oradata/orcl_dup/undotbs001.dbf 104857600
SQL> spool off;
SQL> set heading on;
SQL> set feedback on;
制作parfile
[oracle@node1 lib]$ vi /u01/bbed.par
blocksize = 8192
listfile= /u01/bbedlist.parf
mode = edit
用parfile啟動bbed
[oracle@node1 lib]$ ./bbed parfile=/u01/bbed.par password=blockedit
BBED: Release 2.0.0.0.0 - Limited Production on Thu Jul 10 16:42:27 2014
Copyright (c) 1982, 2005, Oracle. All rights reserved.
************* !!! For Oracle Internal Use only !!! ***************
BBED> show
FILE# 1
BLOCK# 1
OFFSET 0
DBA 0x00400001 (4194305 1,1)
FILENAME /u01/app/oracle/oradata/orcl_dup/system01.dbf
BIFILE bifile.bbd
LISTFILE /u01/bbedlist.parf
BLOCKSIZE 8192
MODE Edit
EDIT Unrecoverable
IBASE Dec
OBASE Dec
WIDTH 80
COUNT 512
LOGFILE log.bbd
SPOOL No
通過bbed獲取指定數值的RDBA(Relative Data Block Address)
SQL> select * from bbed_test;
JOB
-------------------------
123456
1234567890
2 rows selected.
SQL> select
2 rowid,
3 dbms_rowid.rowid_relative_fno(rowid)rel_fno,
4 dbms_rowid.rowid_block_number(rowid)blockno,
5 dbms_rowid.rowid_row_number(rowid)rowno
6 from bbed_test;
ROWID REL_FNO BLOCKNO ROWNO
------------------ ---------- ---------- ----------
AAAN9GAAEAAAAK0AAA 4 692 0
AAAN9GAAEAAAAK0AAB 4 692 1
2 rows selected.
BBED> set dba 4,692 offset 0
DBA 0x010002b4 (16777908 4,692)
OFFSET 0
BBED> show
FILE# 4
BLOCK# 692
OFFSET 8168
DBA 0x010002b4 (16777908 4,692)
FILENAME /u01/app/oracle/oradata/orcl_dup/users01.dbf
BIFILE bifile.bbd
LISTFILE /u01/bbedlist.parf
BLOCKSIZE 8192
MODE Edit
EDIT Unrecoverable
IBASE Dec
OBASE Dec
WIDTH 80
COUNT 512
LOGFILE log.bbd
SPOOL No
當然數據庫中通過dbms_utility包也很容易就能獲得,此處可以對比一下
SQL> variable get_rdba varchar2(30);
SQL> exec :dba :=dbms_utility.make_data_block_address(4,692);
PL/SQL procedure successfully completed.
SQL> print dba
DBA
--------------------------------
16777908
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。