oracle10g bbed編譯與使用
-bash-3.00$cd $ORACLE_HOME/rdbms/lib
-bash-3.00$ make -f ins_rdbms.mk $ORACLE_HOME/rdbms/lib/bbed
-bash-3.00$ ./bbed
Password:
Password:
BBED: Release 2.0.0.0.0 - Limited Production on Thu Dec 23 10:58:43 2010
Copyright (c) 1982, 2007, 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 [ | 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 ]
:
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]=
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 [
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 ]
:
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]
BBED> exit
-bash-3.00$
還真不少,下面是幾個常用的:
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的預設的口令為blockedit
執行bbed之前先要自己寫幾個配置檔案:
這裡有2個 filelist.txt par.bbd
---filelist.txt中指定了具體資料檔案,第一個域為編號,第二個域為資料檔案全路徑,第三個域為資料檔案大小
-bash-3.00$ more filelist.txt
-bash-3.00$ more filelist.txt
1 /u01/app/ora10g/oradata/aning/system01.dbf 608174080
2 /u01/app/ora10g/oradata/aning/undotbs01.dbf 52428800
3 /u01/app/ora10g/oradata/aning/sysaux01.dbf 293601280
4 /u01/app/ora10g/oradata/aning/users01.dbf 17039360
5 /u01/app/ora10g/oradata/aning/example01.dbf 104857600
6 /u01/app/ora10g/oradata/aning/test_part01.dbf 524288
7 /u01/app/ora10g/oradata/aning/test_part02.dbf 524288
8 /tmp/test_uniform.dbf 10485760
9 /u01/app/ora10g/oradata/aning/test_lmt_mssm.dbf 524288000
10 /u01/app/ora10g/oradata/aning/mssm.dbf 104857600
11 /u01/app/ora10g/oradata/aning/demo.dbf 52428800
12 /u01/app/ora10g/oradata/aning/testing.dbf 12582912
13 /u01/app/ora10g/oradata/aning/testingmssm.dbf 1048576
14 /u01/app/ora10g/oradata/aning/ts.dbf 1048576
15 /u01/app/ora10g/oradata/aning/system02.dbf 10485760
2 /u01/app/ora10g/oradata/aning/undotbs01.dbf 52428800
3 /u01/app/ora10g/oradata/aning/sysaux01.dbf 293601280
4 /u01/app/ora10g/oradata/aning/users01.dbf 17039360
5 /u01/app/ora10g/oradata/aning/example01.dbf 104857600
6 /u01/app/ora10g/oradata/aning/test_part01.dbf 524288
7 /u01/app/ora10g/oradata/aning/test_part02.dbf 524288
8 /tmp/test_uniform.dbf 10485760
9 /u01/app/ora10g/oradata/aning/test_lmt_mssm.dbf 524288000
10 /u01/app/ora10g/oradata/aning/mssm.dbf 104857600
11 /u01/app/ora10g/oradata/aning/demo.dbf 52428800
12 /u01/app/ora10g/oradata/aning/testing.dbf 12582912
13 /u01/app/ora10g/oradata/aning/testingmssm.dbf 1048576
14 /u01/app/ora10g/oradata/aning/ts.dbf 1048576
15 /u01/app/ora10g/oradata/aning/system02.dbf 10485760
-bash-3.00$ more par.bbd
blocksize=8192
listfile=filelist.txt
mode=edit
blocksize=8192
listfile=filelist.txt
mode=edit
編譯好了就可以執行bbed了
下面做些實驗
先建一個表插入一條資料
sqlplus / as sysdba
SQL> create table bbed(a varchar2(10)) tablespace users;
Table created.
SQL> insert into bbed values('aning');
1 row created.
SQL> commit;
Commit complete.
SQL> select segment_name,file_id,block_id,blocks from dba_extents where segment_name='BBED';
SQL> select segment_name,file_id,block_id,blocks from dba_extents where segment_name='BBED';
SEGMENT_NAME FILE_ID BLOCK_ID BLOCKS
------------------------------ ---------- ---------- ----------
BBED 4 417 8
------------------------------ ---------- ---------- ----------
BBED 4 417 8
表存放在file4,block417 - 417+8,先關閉資料塊對users資料檔案做cp
SQL> shutdown immediate;
-bash-3.00$ cp /u01/app/ora10g/oradata/aning/users01.dbf /u01/app/ora10g/oradata/aning/users01.dbf.bak
SQL> startup
ORACLE instance started.
ORACLE instance started.
Total System Global Area 285212672 bytes
Fixed Size 1267068 bytes
Variable Size 109054596 bytes
Database Buffers 171966464 bytes
Redo Buffers 2924544 bytes
Database mounted.
Database opened
Fixed Size 1267068 bytes
Variable Size 109054596 bytes
Database Buffers 171966464 bytes
Redo Buffers 2924544 bytes
Database mounted.
Database opened
重新啟動資料塊進入bbed
-bash-3.00$ pwd
/home/oracle
-bash-3.00$ bbed parfile=par.bbd
/home/oracle
-bash-3.00$ bbed parfile=par.bbd
BBED> set file 4
FILE# 4
FILE# 4
BBED> show
FILE# 4
BLOCK# 1
OFFSET 0
DBA 0x01000001 (16777217 4,1)
FILENAME /u01/app/ora10g/oradata/aning/users01.dbf
BIFILE bifile.bbd
LISTFILE filelist.txt
BLOCKSIZE 8192
MODE Edit
EDIT Unrecoverable
IBASE Dec
OBASE Dec
WIDTH 80
COUNT 512
LOGFILE log.bbd
SPOOL No
剛才建立的bbed表在file4 block417 - 417+8上面,用bbed檢視420上的資料
FILE# 4
BLOCK# 1
OFFSET 0
DBA 0x01000001 (16777217 4,1)
FILENAME /u01/app/ora10g/oradata/aning/users01.dbf
BIFILE bifile.bbd
LISTFILE filelist.txt
BLOCKSIZE 8192
MODE Edit
EDIT Unrecoverable
IBASE Dec
OBASE Dec
WIDTH 80
COUNT 512
LOGFILE log.bbd
SPOOL No
剛才建立的bbed表在file4 block417 - 417+8上面,用bbed檢視420上的資料
BBED> dump file 4 block 420
File: /u01/app/ora10g/oradata/aning/users01.dbf (4)
Block: 420 Offsets: 0 to 511 Dba:0x010001a4
------------------------------------------------------------------------
06a20000 a4010001 a67c1000 00000306 9aee0000 01000000 f1d00000 577c1000
00000000 02003200 a1010001 04001000 5c010000 13008000 92011f00 01200000
a67c1000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
00000000 00010100 ffff1400 8f1f7b1f 7b1f0000 01008f1f 00000000 00000000
00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
File: /u01/app/ora10g/oradata/aning/users01.dbf (4)
Block: 420 Offsets: 0 to 511 Dba:0x010001a4
------------------------------------------------------------------------
06a20000 a4010001 a67c1000 00000306 9aee0000 01000000 f1d00000 577c1000
00000000 02003200 a1010001 04001000 5c010000 13008000 92011f00 01200000
a67c1000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
00000000 00010100 ffff1400 8f1f7b1f 7b1f0000 01008f1f 00000000 00000000
00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
<32 bytes per line>
offset的偏移量是從0-511單位是位元組,資料塊是8k的,想看全部的可以擴大offset的範圍
offset的偏移量是從0-511單位是位元組,資料塊是8k的,想看全部的可以擴大offset的範圍
BBED> dump file 4 block 420 count 8200
File: /u01/app/ora10g/oradata/aning/users01.dbf (4)
Block: 420 Offsets: 0 to 8191 Dba:0x010001a4
------------------------------------------------------------------------
06a20000 a4010001 a67c1000 00000306 9aee0000 01000000 f1d00000 577c1000
00000000 02003200 a1010001 04001000 5c010000 13008000 92011f00 01200000
a67c1000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
00000000 00010100 ffff1400 8f1f7b1f 7b1f0000 01008f1f 00000000 00000000
00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
File: /u01/app/ora10g/oradata/aning/users01.dbf (4)
Block: 420 Offsets: 0 to 8191 Dba:0x010001a4
------------------------------------------------------------------------
06a20000 a4010001 a67c1000 00000306 9aee0000 01000000 f1d00000 577c1000
00000000 02003200 a1010001 04001000 5c010000 13008000 92011f00 01200000
a67c1000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
00000000 00010100 ffff1400 8f1f7b1f 7b1f0000 01008f1f 00000000 00000000
00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
。。。。
00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
00000000 00000000 00000000 00000000 0000002c 01010561 6e696e67 0306a67c
00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
00000000 00000000 00000000 00000000 0000002c 01010561 6e696e67 0306a67c
<32 bytes per line>
Offsets: 0 to 8191 1024*8=8192個位元組, 正好是8k,注意最後位元組中有個61,這個就是表中的那條資料,驗證一下:
Offsets: 0 to 8191 1024*8=8192個位元組, 正好是8k,注意最後位元組中有個61,這個就是表中的那條資料,驗證一下:
SQL> select * from bbed;
A
----------
aning
----------
aning
SQL> select dump(a,1016) from bbed;
DUMP(A,1016)
------------------------------------------------------------------------------------------------------------------------------------------------------
Typ=1 Len=5 CharacterSet=ZHS16GBK: 61,6e,69,6e,67
------------------------------------------------------------------------------------------------------------------------------------------------------
Typ=1 Len=5 CharacterSet=ZHS16GBK: 61,6e,69,6e,67
字元a對應的16進位制就是61,如果資料量大可以用find查詢
BBED> help find
FIND[/x|d|u|o|c] numeric/character string [ TOP | CURR ]
FIND[/x|d|u|o|c] numeric/character string [ TOP | CURR ]
BBED> set file 4
FILE# 4
FILE# 4
BBED> set block 420
BLOCK# 420
BLOCK# 420
BBED> find 97 curr
File: /u01/app/ora10g/oradata/aning/users01.dbf (4)
Block: 420 Offsets: 8183 to 8191 Dba:0x010001a4
------------------------------------------------------------------------
616e696e 670306a6 7c
File: /u01/app/ora10g/oradata/aning/users01.dbf (4)
Block: 420 Offsets: 8183 to 8191 Dba:0x010001a4
------------------------------------------------------------------------
616e696e 670306a6 7c
<32 bytes per line>
BBED> find /x 61 curr
File: /u01/app/ora10g/oradata/aning/users01.dbf (4)
Block: 420 Offsets: 8183 to 8191 Dba:0x010001a4
------------------------------------------------------------------------
616e696e 670306a6 7c
File: /u01/app/ora10g/oradata/aning/users01.dbf (4)
Block: 420 Offsets: 8183 to 8191 Dba:0x010001a4
------------------------------------------------------------------------
616e696e 670306a6 7c
<32 bytes per line>
在find之前要先設定file和block,預設是十進位制的ascii編碼,/x表示十六進位制,find的結果顯示出offset,即字元出現的位置
下面試驗修改,把aning改成Oraning
SQL> select dump('Oraning',1016) from dual;
DUMP('ORANING',1016)
--------------------------------------------------------
Typ=96 Len=7 CharacterSet=ZHS16GBK: 4f,72,61,6e,69,6e,67
--------------------------------------------------------
Typ=96 Len=7 CharacterSet=ZHS16GBK: 4f,72,61,6e,69,6e,67
BBED> help modify
MODIFY[/x|d|u|o|c] numeric/character string
[ DBA | FILE | FILENAME | BLOCK | OFFSET | symbol | *symbol ]
MODIFY[/x|d|u|o|c] numeric/character string
[ DBA | FILE | FILENAME | BLOCK | OFFSET | symbol | *symbol ]
BBED> modify 98 file 4 block 420 offset 8183
File: /u01/app/ora10g/oradata/aning/users01.dbf (4)
Block: 420 Offsets: 8183 to 8191 Dba:0x010001a4
------------------------------------------------------------------------
626e696e 670306a6 7c
File: /u01/app/ora10g/oradata/aning/users01.dbf (4)
Block: 420 Offsets: 8183 to 8191 Dba:0x010001a4
------------------------------------------------------------------------
626e696e 670306a6 7c
<32 bytes per line>
修改完之後61就變成62了,不過這時資料塊是損壞狀態,試驗一下
BBED> verify
DBVERIFY - Verification starting
FILE = /u01/app/ora10g/oradata/aning/users01.dbf
BLOCK = 420
DBVERIFY - Verification starting
FILE = /u01/app/ora10g/oradata/aning/users01.dbf
BLOCK = 420
Block 420 is corrupt
Corrupt block relative dba: 0x010001a4 (file 0, block 420)
Bad check value found during verification
Data in bad block:
type: 6 format: 2 rdba: 0x010001a4
last change scn: 0x0000.00107ca6 seq: 0x3 flg: 0x06
spare1: 0x0 spare2: 0x0 spare3: 0x0
consistency value in tail: 0x7ca60603
check value in block header: 0xee9a
computed block checksum: 0x300
Corrupt block relative dba: 0x010001a4 (file 0, block 420)
Bad check value found during verification
Data in bad block:
type: 6 format: 2 rdba: 0x010001a4
last change scn: 0x0000.00107ca6 seq: 0x3 flg: 0x06
spare1: 0x0 spare2: 0x0 spare3: 0x0
consistency value in tail: 0x7ca60603
check value in block header: 0xee9a
computed block checksum: 0x300
DBVERIFY - Verification complete
Total Blocks Examined : 1
Total Blocks Processed (Data) : 0
Total Blocks Failing (Data) : 0
Total Blocks Processed (Index): 0
Total Blocks Failing (Index): 0
Total Blocks Empty : 0
Total Blocks Marked Corrupt : 1
Total Blocks Influx : 0
Total Blocks Processed (Data) : 0
Total Blocks Failing (Data) : 0
Total Blocks Processed (Index): 0
Total Blocks Failing (Index): 0
Total Blocks Empty : 0
Total Blocks Marked Corrupt : 1
Total Blocks Influx : 0
有一個塊標識為壞塊,從剛才備份的那個檔案覆蓋它
BBED> copy file 24 block 420 to file 4 block 420
Warning: contents of previous BIFILE will be lost. Proceed? (Y/N) y
File: /u01/app/ora10g/oradata/aning/users01.dbf (4)
Block: 420 Offsets: 0 to 511 Dba:0x010001a4
------------------------------------------------------------------------
06a20000 a4010001 a67c1000 00000306 9aee0000 01000000 f1d00000 577c1000
00000000 02003200 a1010001 04001000 5c010000 13008000 92011f00 01200000
a67c1000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
00000000 00010100 ffff1400 8f1f7b1f 7b1f0000 01008f1f 00000000 00000000
00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
Warning: contents of previous BIFILE will be lost. Proceed? (Y/N) y
File: /u01/app/ora10g/oradata/aning/users01.dbf (4)
Block: 420 Offsets: 0 to 511 Dba:0x010001a4
------------------------------------------------------------------------
06a20000 a4010001 a67c1000 00000306 9aee0000 01000000 f1d00000 577c1000
00000000 02003200 a1010001 04001000 5c010000 13008000 92011f00 01200000
a67c1000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
00000000 00010100 ffff1400 8f1f7b1f 7b1f0000 01008f1f 00000000 00000000
00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
<32 bytes per line>
從剛才關閉資料庫cp的資料檔案中複製第420塊覆蓋當前的塊,覆蓋了再檢查一下
BBED> verify
DBVERIFY - Verification starting
FILE = /u01/app/ora10g/oradata/aning/users01.dbf
BLOCK = 420
DBVERIFY - Verification starting
FILE = /u01/app/ora10g/oradata/aning/users01.dbf
BLOCK = 420
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
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
好了,看看8183的情況
BBED> dump file 4 block 420 offset 8183
File: /u01/app/ora10g/oradata/aning/users01.dbf (4)
Block: 420 Offsets: 8183 to 8191 Dba:0x010001a4
------------------------------------------------------------------------
616e696e 670306a6 7c
<32 bytes per line>
是61原來的字元a,再次改過來,看看回滾命令
BBED> modify /x 62 file 4 block 420 offset 8183
File: /u01/app/ora10g/oradata/aning/users01.dbf (4)
Block: 420 Offsets: 8183 to 8191 Dba:0x010001a4
------------------------------------------------------------------------
626e696e 670306a6 7c
File: /u01/app/ora10g/oradata/aning/users01.dbf (4)
Block: 420 Offsets: 8183 to 8191 Dba:0x010001a4
------------------------------------------------------------------------
626e696e 670306a6 7c
<32 bytes per line>
BBED> undo
BBED> modify /x 61 filename '/u01/app/ora10g/oradata/aning/users01.dbf' block 420. offset 8183.
File: /u01/app/ora10g/oradata/aning/users01.dbf (4)
Block: 420 Offsets: 8183 to 8191 Dba:0x010001a4
------------------------------------------------------------------------
616e696e 670306a6 7c
BBED> modify /x 61 filename '/u01/app/ora10g/oradata/aning/users01.dbf' block 420. offset 8183.
File: /u01/app/ora10g/oradata/aning/users01.dbf (4)
Block: 420 Offsets: 8183 to 8191 Dba:0x010001a4
------------------------------------------------------------------------
616e696e 670306a6 7c
<32 bytes per line>
undo相當於sqlplus裡面的rollback,不過是回滾上一步,而不是所有操作
下面試試revert,不過要重新登入,因為revert回滾這次登入以來的所有操作
BBED> exit
-bash-3.00$ bbed parfile=par.bbd
Password:
Password:
BBED: Release 2.0.0.0.0 - Limited Production on Thu Dec 23 13:21:12 2010
Copyright (c) 1982, 2007, Oracle. All rights reserved.
************* !!! For Oracle Internal Use only !!! ***************
BBED> dump file 4 block 420 offset 8183
File: /u01/app/ora10g/oradata/aning/users01.dbf (4)
Block: 420 Offsets: 8183 to 8191 Dba:0x010001a4
------------------------------------------------------------------------
616e696e 670306a6 7c
File: /u01/app/ora10g/oradata/aning/users01.dbf (4)
Block: 420 Offsets: 8183 to 8191 Dba:0x010001a4
------------------------------------------------------------------------
616e696e 670306a6 7c
<32 bytes per line>
BBED> modify /x 62 file 4 block 420 offset 8183
Warning: contents of previous BIFILE will be lost. Proceed? (Y/N) y
File: /u01/app/ora10g/oradata/aning/users01.dbf (4)
Block: 420 Offsets: 8183 to 8191 Dba:0x010001a4
------------------------------------------------------------------------
626e696e 670306a6 7c
Warning: contents of previous BIFILE will be lost. Proceed? (Y/N) y
File: /u01/app/ora10g/oradata/aning/users01.dbf (4)
Block: 420 Offsets: 8183 to 8191 Dba:0x010001a4
------------------------------------------------------------------------
626e696e 670306a6 7c
<32 bytes per line>
BBED> revert
All changes made in this session will be rolled back. Proceed? (Y/N) y
Reverted file '/u01/app/ora10g/oradata/aning/users01.dbf', block 420
Warning: contents of previous BIFILE will be lost. Proceed? (Y/N) y
All changes made in this session will be rolled back. Proceed? (Y/N) y
Reverted file '/u01/app/ora10g/oradata/aning/users01.dbf', block 420
Warning: contents of previous BIFILE will be lost. Proceed? (Y/N) y
BBED> dump file 4 block 420 offset 8183
File: /u01/app/ora10g/oradata/aning/users01.dbf (4)
Block: 420 Offsets: 8183 to 8191 Dba:0x010001a4
------------------------------------------------------------------------
616e696e 670306a6 7c
File: /u01/app/ora10g/oradata/aning/users01.dbf (4)
Block: 420 Offsets: 8183 to 8191 Dba:0x010001a4
------------------------------------------------------------------------
616e696e 670306a6 7c
<32 bytes per line>
BBED>
個人感覺bbed用在資料塊恢復的時候,比如由於誤操作把資料庫的字典表的資訊改錯了,導致資料庫不能啟動了,此時用bbed在離線的情況下把字典表的值再改回來。使資料庫open。用modify改完資料之後,block處於corrupt狀態,所以要通過sum命令計算並應用checksum值,使block狀態恢復正常
BBED> dump file 4 block 420 offset 8183
File: /u01/app/ora10g/oradata/aning/users01.dbf (4)
Block: 420 Offsets: 8183 to 8191 Dba:0x010001a4
------------------------------------------------------------------------
616e696e 670306a6 7c
File: /u01/app/ora10g/oradata/aning/users01.dbf (4)
Block: 420 Offsets: 8183 to 8191 Dba:0x010001a4
------------------------------------------------------------------------
616e696e 670306a6 7c
<32 bytes per line>
BBED> modify /x 62 file 4 block 420 offset 8183
File: /u01/app/ora10g/oradata/aning/users01.dbf (4)
Block: 420 Offsets: 8183 to 8191 Dba:0x010001a4
------------------------------------------------------------------------
626e696e 670306a6 7c
File: /u01/app/ora10g/oradata/aning/users01.dbf (4)
Block: 420 Offsets: 8183 to 8191 Dba:0x010001a4
------------------------------------------------------------------------
626e696e 670306a6 7c
<32 bytes per line>
BBED> verify
DBVERIFY - Verification starting
FILE = /u01/app/ora10g/oradata/aning/users01.dbf
BLOCK = 420
DBVERIFY - Verification starting
FILE = /u01/app/ora10g/oradata/aning/users01.dbf
BLOCK = 420
Block 420 is corrupt
Corrupt block relative dba: 0x010001a4 (file 0, block 420)
Bad check value found during verification
Data in bad block:
type: 6 format: 2 rdba: 0x010001a4
last change scn: 0x0000.00107ca6 seq: 0x3 flg: 0x06
spare1: 0x0 spare2: 0x0 spare3: 0x0
consistency value in tail: 0x7ca60603
check value in block header: 0xee9a
computed block checksum: 0x300
Corrupt block relative dba: 0x010001a4 (file 0, block 420)
Bad check value found during verification
Data in bad block:
type: 6 format: 2 rdba: 0x010001a4
last change scn: 0x0000.00107ca6 seq: 0x3 flg: 0x06
spare1: 0x0 spare2: 0x0 spare3: 0x0
consistency value in tail: 0x7ca60603
check value in block header: 0xee9a
computed block checksum: 0x300
DBVERIFY - Verification complete
Total Blocks Examined : 1
Total Blocks Processed (Data) : 0
Total Blocks Failing (Data) : 0
Total Blocks Processed (Index): 0
Total Blocks Failing (Index): 0
Total Blocks Empty : 0
Total Blocks Marked Corrupt : 1
Total Blocks Influx : 0
Total Blocks Processed (Data) : 0
Total Blocks Failing (Data) : 0
Total Blocks Processed (Index): 0
Total Blocks Failing (Index): 0
Total Blocks Empty : 0
Total Blocks Marked Corrupt : 1
Total Blocks Influx : 0
修改完之後block的狀態是corrupt的。用sum命令使之有效。
BBED> help sum
SUM [ DBA | FILE | FILENAME | BLOCK ] [ APPLY ]
SUM [ DBA | FILE | FILENAME | BLOCK ] [ APPLY ]
BBED> sum file 4 block 420
Check value for File 4, Block 420:
current = 0xee9a, required = 0xed9a
Check value for File 4, Block 420:
current = 0xee9a, required = 0xed9a
此時 current checksum 是0xee9a,required checksum 是 0xed9a
BBED> sum file 4 block 420 apply
Check value for File 4, Block 420:
current = 0xed9a, required = 0xed9a
Check value for File 4, Block 420:
current = 0xed9a, required = 0xed9a
加上apply引數,使checksum一致。此時block狀態恢復正常。
BBED> verify
DBVERIFY - Verification starting
FILE = /u01/app/ora10g/oradata/aning/users01.dbf
BLOCK = 420
DBVERIFY - Verification starting
FILE = /u01/app/ora10g/oradata/aning/users01.dbf
BLOCK = 420
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
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
看看資料庫的資料
SQL> select * from bbed;
A
----------
aning
----------
aning
沒變化,重啟一下
SQL> startup force;
SQL> select * from bbed;
A
----------
bning
----------
bning
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/12457158/viewspace-682593/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- 11g下編譯使用BBED編譯
- redhat下如何編譯bbed!Redhat編譯
- [BBED]Oracle 11.2.0.4 Centos6.5下編譯bbedOracleCentOS編譯
- 【BBED】編譯及基本命令(1)編譯
- oracle11g 編譯BBED工具Oracle編譯
- oracle11g編譯生成bbedOracle編譯
- Java編譯與反編譯Java編譯
- protobuf 編譯工具安裝與使用編譯
- nginx 編譯安裝與配置使用Nginx編譯
- 初探JsonCpp - 編譯與基本使用JSON編譯
- gcc 編譯器與 clang 編譯器GC編譯
- [20121004]11G下編譯bbed.txt編譯
- oracle bbed使用Oracle
- 使用makefile編譯編譯
- Rust 交叉編譯與條件編譯總結Rust編譯
- 【BBED】使用bbed修改數字型別資料型別
- 【BBED】使用bbed修改字元型別資料字元型別
- 常見 APK 反編譯工具安裝與使用APK編譯
- 交叉編譯-Mac環境使用NDK編譯FFmpeg編譯Mac
- BBED安裝使用
- 使用xmake編譯工程編譯
- 編譯原理與javacc初探編譯原理Java
- Java程式碼的編譯與反編譯那些事兒Java編譯
- 【BBED】使用bbed 修改日期型別的資料型別
- 【BBED】使用bbed解決 the amount of space used is not equal to block sizeBloC
- Windows下編譯使用AliyunOSSCSDKWindows編譯
- 使用makefile編譯c程式編譯C程式
- 編譯和使用zlib編譯
- GCC編譯器的使用GC編譯
- Oracle bbed工具的使用Oracle
- 使用C編譯器編寫shellcode編譯
- [Web翻譯]JavaScript中的編譯與填充WebJavaScript編譯
- 後端編譯與優化後端編譯優化
- linux與windows交叉編譯LinuxWindows編譯
- Ceph原始碼編譯與打包原始碼編譯
- C編譯: 使用gdb除錯編譯除錯
- Rust 編譯器探索使用 PGORust編譯Go
- 使用 Nginx 編譯 Sass 和 ScssNginx編譯CSS