BBED,Block Browser and EDitor ,是一个用来能够直接修改oracle数据块的工具,在极端恢复场景时能够使用到。该工具不受Oracle的支持,默认是没有可执行文件的。所以,要使用这个这个工具,还的自己先编译下。
1.BBED的编译
Oracle 9i/10G提供了BBED的编译库文件,但11G未提供,一个解决方法就是从10G中拷一份。
[oracle@WZY ~]$ cd $ORACLE_HOME/rdbms/lib
[oracle@WZY lib]$ make -f ins_rdbms.mk $ORACLE_HOME/rdbms/lib/bbed
Linking BBED utility (bbed)
rm -f /u01/app/oracle/product/10.2.0/db_1/rdbms/lib/bbed
gcc -o /u01/app/oracle/product/10.2.0/db_1/rdbms/lib/bbed -L/u01/app/oracle/product/10.2.0/db_1/rdbms/lib/ -L/u01/app/oracle/product/10.2.0/db_1/lib/ -L/u01/app/oracle/product/10.2.0/db_1/lib/stubs/ -L/usr/lib -lirc /u01/app/oracle/product/10.2.0/db_1/lib/s0main.o /u01/app/oracle/product/10.2.0/db_1/rdbm
…………
…………
2 BBED的登录
BBED的初始密码是blockedit
[oracle@edbjr2p1 lib]$ ./bbed
Password:
BBED: Release 2.0.0.0.0 - Limited Production on Wed Sep 17 16:59:40 2014
Copyright (c) 1982, 2005, Oracle. All rights reserved.
************* !!! For Oracle Internal Use only !!! ***************
BBED>
[oracle@edbjr2p1 lib]$ ./bbed help=y
PASSWORD - Required parameter
FILENAME - Database file name
BLOCKSIZE - Database block size
LISTFILE - List file name
MODE - [browse/edit]
SPOOL - Spool to logfile [no/yes]
CMDFILE - BBED command file name
LOGFILE - BBED log file name
PARFILE - Parameter file name
BIFILE - BBED before-image file name
REVERT - Rollback changes from BIFILE [no/yes]
SILENT - Hide banner [no/yes]
HELP - Show all valid parameters [no/yes]
[oracle@edbjr2p1 lib]$
3.对BBED的简单操作
1)
SYS@ORCL>select FILE#||''||NAME||' '||BYTES from v$datafile;
FILE#||''||NAME||''||BYTES
--------------------------------------------------------------------------------
1/u01/app/oracle/oradata/PROD/disk1/system01.dbf 340787200
2/u01/app/oracle/oradata/PROD/disk1/undotbs01.dbf 209715200
3/u01/app/oracle/oradata/PROD/disk1/sysaux01.dbf 340787200
4/u01/app/oracle/oradata/PROD/disk3/example.dbf 673185792
5/u01/app/oracle/oradata/PROD/disk4/USERS.dbf 50331648
2)
[oracle@edbjr2p1 wzy]$ cat filelist.txt
1/u01/app/oracle/oradata/PROD/disk1/system01.dbf 340787200
2/u01/app/oracle/oradata/PROD/disk1/undotbs01.dbf 209715200
3/u01/app/oracle/oradata/PROD/disk1/sysaux01.dbf 340787200
4/u01/app/oracle/oradata/PROD/disk3/example.dbf 673185792
5/u01/app/oracle/oradata/PROD/disk4/USERS.dbf 50331648
3)
[oracle@edbjr2p1 lib]$ ./bbed BLOCKSIZE=8192 LISTFILE=/home/oracle/wzy/filelist.txt MODE=edit
Password:
BBED: Release 2.0.0.0.0 - Limited Production on Thu Sep 18 09:37:32 2014
Copyright (c) 1982, 2005, Oracle. All rights reserved.
************* !!! For Oracle Internal Use only !!! ***************
BBED>
也可以将后面的一堆参数放在一个参数文件中
[oracle@edbjr2p1 wzy]$ cat bbed.par
BLOCKSIZE=8192
LISTFILE=/home/oracle/wzy/filelist.txt
MODE=edit
[oracle@edbjr2p1 lib]$ ./bbed parfile=/home/oracle/wzy/bbed.par
Password:
BBED: Release 2.0.0.0.0 - Limited Production on Thu Sep 18 09:39:46 2014
Copyright (c) 1982, 2005, Oracle. All rights reserved.
************* !!! For Oracle Internal Use only !!! ***************
help all 命令将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 ]