Oracle bbed工具的使用

gycixput發表於2013-12-17
        BBED(Oracle Block Browerand EDitor Tool),是Oracle的一款內部工具,用來維護資料檔案,由於不提供支援,需要手動編譯後才可以使用。

     測試環境:
            Oracle 10gR2
            RHEL 6.3
     9i/10g需要手動編譯bbed工具,11g據說需要複製10g的然後手動編譯。
            make -f ins_rdbms.mk /opt/oracle/product/10.2.0/db/rdbms/lib/bbed
測試目的:
dump某1號檔案第377塊內容
測試過程:
[oracle@eagle db]$cd /opt/oracle/product/10.2.0/db/rdbms/lib

[oracle@eagle lib]$ make -f ins_rdbms.mk /opt/oracle/product/10.2.0/db/rdbms/lib/bbed

Linking BBED utility (bbed)
rm -f /opt/oracle/product/10.2.0/db/rdbms/lib/bbed
gcc -o /opt/oracle/product/10.2.0/db/rdbms/lib/bbed -L/opt/oracle/product/10.2.0/db/rdbms/lib/ -L/opt/oracle/product/10.2.0/db/lib/ -L/opt/oracle/product/10.2.0/db/lib/stubs/  /opt/oracle/product/10.2.0/db/lib/s0main.o /opt/oracle/product/10.2.0/db/rdbms/lib/ssbbded.o /opt/oracle/product/10.2.0/db/rdbms/lib/sbbdpt.o `cat /opt/oracle/product/10.2.0/db/lib/ldflags`    -lnsslb10 -lncrypt10 -lnsgr10 -lnzjs10 -ln10 -lnnz10 -lnl10 /opt/oracle/product/10.2.0/db/rdbms/lib/defopt.o -ldbtools10 -lclntsh  `cat /opt/oracle/product/10.2.0/db/lib/ldflags`    -lnsslb10 -lncrypt10 -lnsgr10 -lnzjs10 -ln10 -lnnz10 -lnl10 -lnro10 `cat /opt/oracle/product/10.2.0/db/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 /opt/oracle/product/10.2.0/db/lib/ldflags`    -lnsslb10 -lncrypt10 -lnsgr10 -lnzjs10 -ln10 -lnnz10 -lnl10 -lnro10 `cat /opt/oracle/product/10.2.0/db/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 /opt/oracle/product/10.2.0/db/lib/sysliblist` -Wl,-rpath,/opt/oracle/product/10.2.0/db/lib -lm    `cat /opt/oracle/product/10.2.0/db/lib/sysliblist` -ldl -lm   -L/opt/oracle/product/10.2.0/db/lib
可以複製bbed到$ORACLE_HOME/bin下
[oracle@eagle lib]$ cp /opt/oracle/product/10.2.0/db/rdbms/lib/bbed /opt/oracle/product/10.2.0/db/bin/
bbed登入的密碼是:blockedit

[oracle@eagle lib]$ bbed
Password:

BBED: Release 2.0.0.0.0 - Limited Production on Tue Dec 17 21:42:27 2013

Copyright (c) 1982, 2007, Oracle.  All rights reserved.

************* !!! For Oracle Internal Use only !!! ***************

BBED> help
HELP [ | ALL ]

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] =
: [ DBA | FILE | FILENAME | BLOCK | OFFSET | symbol | *symbol ]
: [ value | ]
SUM [ DBA | FILE | FILENAME | BLOCK ] [ APPLY ]
PUSH [ DBA | FILE | FILENAME | BLOCK | OFFSET ]
POP [ALL]
REVERT [ DBA | FILE | FILENAME | BLOCK ]
UNDO
HELP [ | ALL ]
VERIFY [ DBA | FILE | FILENAME | BLOCK ]
CORRUPT [ DBA | FILE | FILENAME | BLOCK ]

set 設定當前的環境變數
show 顯示當前的環境變數
設定檔案列表
[oracle@eagle ~]$ cat listfile.txt
1 /opt/oracle/product/oradata/oragg/system01.dbf 461373440
2 /opt/oracle/product/oradata/oragg/undotbs01.dbf 26214400
3 /opt/oracle/product/oradata/oragg/sysaux01.dbf 262144000
4 /opt/oracle/product/oradata/oragg/users01.dbf 14417920
5 /opt/oracle/product/oradata/oragg/ggs01.dbf 209715200
內容來源
<source>
<source>

 

> select file#||' '||name||' '||bytes from v$datafile ;

FILE#||''||NAME||''||BYTES
----------------------------------------------------------------------------------------------------
1 /opt/oracle/product/oradata/oragg/system01.dbf 461373440
2 /opt/oracle/product/oradata/oragg/undotbs01.dbf 26214400
3 /opt/oracle/product/oradata/oragg/sysaux01.dbf 262144000
4 /opt/oracle/product/oradata/oragg/users01.dbf 14417920
5 /opt/oracle/product/oradata/oragg/ggs01.dbf 209715200

設定引數檔案
[oracle@eagle ~]$ cat bd.par
listfile=listfile.txt
mode=edit

[oracle@eagle ~]$ bbed parfile=bd.par
Password:

BBED: Release 2.0.0.0.0 - Limited Production on Tue Dec 17 22:01:48 2013

Copyright (c) 1982, 2007, Oracle.  All rights reserved.

************* !!! For Oracle Internal Use only !!! ***************

BBED> show   
        FILE#           1
        BLOCK#          1
        OFFSET          0
        DBA             0x00400001 (4194305 1,1)
        FILENAME        /opt/oracle/product/oradata/oragg/system01.dbf
        BIFILE          bifile.bbd
        LISTFILE        listfile.txt
        BLOCKSIZE       8192
        MODE            Edit
        EDIT            Unrecoverable
        IBASE           Dec
        OBASE           Dec
        WIDTH           80
        COUNT           512
        LOGFILE         log.bbd
        SPOOL           No

info檢視listfile
BBED> info
 File#  Name                                                        Size(blks)
 -----  ----                                                        ----------
     1  /opt/oracle/product/oradata/oragg/system01.dbf                   56320
     2  /opt/oracle/product/oradata/oragg/undotbs01.dbf                   3200
     3  /opt/oracle/product/oradata/oragg/sysaux01.dbf                   32000
     4  /opt/oracle/product/oradata/oragg/users01.dbf                     1760
     5  /opt/oracle/product/oradata/oragg/ggs01.dbf                      25600
檢視dba的值

BBED> map
 File: /opt/oracle/product/oradata/oragg/system01.dbf (1)
 Block: 377                                   Dba:0x00400179
------------------------------------------------------------
 Unlimited Data Segment Header

 struct kcbh, 20 bytes                      @0      

 struct ktech, 72 bytes                     @20     

 struct ktemh, 16 bytes                     @92     

 struct ktetb[1], 8 bytes                   @108    

 struct ktshc, 8 bytes                      @4148   

 struct ktsfs_seg[1], 20 bytes              @4156   

 struct ktsfs_txn[16], 320 bytes            @4176   

 ub4 tailchk                                @8188   

檢視1號檔案第377塊內容:
BBED> dump
 File: /opt/oracle/product/oradata/oragg/system01.dbf (1)
 Block: 377              Offsets:    0 to  511           Dba:0x00400179
------------------------------------------------------------------------
 10a20000 79014000 d3000000 00000204 33e70000 00000000 00000000 00000000
 00000000 01000000 07000000 20100000 00000000 03000000 07000000 7d014000
 00000000 00000000 01000000 03000000 00000000 00000000 00000000 01000000
 00000000 38000000 00000040 7a014000 07000000 00000000 00000000 00000000
 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
 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>

Map 顯示的具體資訊解釋如下【整理自網路】

struct kcbh, 20 bytes

Block Header Structure

  ub1 type_kcbh

Block type (see Header Block Types below)

  ub1 frmt_kcbh

Block format 1=Oracle 7, 2=Oracle 8+

  ub1 spare1_kcbh

Not used

  ub1 spare2_kcbh

Not used

  ub4 rdba_kcbh

RDBA -Relative Data Block Address

  ub4 bas_kcbh

SCN Base

  ub2 wrp_kcbh

SCN Wrap

  ub1 seq_kcbh

Sequence number, incremented for every change made to the block at the same SCN

  ub1 flg_kcbh

Flag:

0x01 New Block

0x02 Delayed Logging Change advanced SCN/seq 0x04 Check value saved - block XOR‘s to zero

0x08 Temporary block

  ub2 chkval_kcbh

Optional block checksum (if DB_BLOCK_CHECKSUM=TRUE)

  ub2 spare3_kcbh

Not used

struct ktbbh, 72 bytes

Transaction Fixed Header Structure

  ub1 ktbbhtyp

Block type (1=DATA, 2=INDEX)

  union ktbbhsid, 4 bytes

Segment/Object ID

  struct ktbbhcsc, 8 bytes

SCN at last block cleanout

  b2 ktbbhict

Number of ITL slots

  ub1 ktbbhflg

0=on the freelist

  ub1 ktbbhfsl

ITL TX freelist slot

  ub4 ktbbhfnx

DBA of next block on the freelist

  struct ktbbhitl[2], 48 bytes

ITL list index

struct kdbh, 14 bytes

Data Header Structure

  ub1 kdbhflag

N=pctfree hit(clusters); F=do not put on freelist; K=flushable cluster keys

  b1 kdbhntab

Number of tables (>1 in clusters)

  b2 kdbhnrow

Number of rows

  sb2 kdbhfrre

First free row entry index; -1 = you have to add one

  sb2 kdbhfsbo

Freespace begin offset

  sb2 kdbhfseo

Freespace end offset

  b2 kdbhavsp

Available space in the block

  b2 kdbhtosp

Total available space when all TXs commit

struct kdbt[1], 4 bytes

Table Directory Entry Structure

  b2 kdbtoffs

 

  b2 kdbtnrow

 

sb2 kdbr[1]

Row Directory

ub1 freespace[8030]

Free Space

ub1 rowdata[38]

Row Data

ub4 tailchk

(See Tailchecks below)

Header Block Types【整理自網路】

ID

Type

01

Undo segment header

02

Undo data block

03

Save undo header

04

Save undo data block

05

Data segment header (temp, index, data and so on)

06

KTB managed data block (with ITL)

07

Temp table data block (no ITL)

08

Sort Key

09

Sort Run

10

Segment free list block

11

Data file header

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

相關文章