BBED工具的安裝使用(二)

靜以致遠√團團發表於2014-07-11

BBED常用的命令如下:

set 設定當前的環境

show 檢視當前的環境引數,跟sqlplus的同名命令類似。

dump 列出指定block的內容

find 在指定的block中查詢指定的字串,結果是顯示出字串,及其偏移量--offset,偏移量就是在block中的位元組數

modify 修改指定block的指定偏移量的值,可以線上修改。

copy 把一個block的內容copy到另一個block

verify 檢查當前環境是否有壞塊

sum 計算blockchecksummodify之後block就被標識為壞塊,current checksumreqired checksum不一致,sum命令可以計算出新的checksum並應用到當前塊。

undo 回滾當前的修改操作,如果手誤做錯了,undo一下就ok了,回到原來的狀態。

revert 回滾所有之前的修改操作,意思就是 undo all

 

[oracle@node1 ~]$ cd $ORACLE_HOME/rdbms/lib

[oracle@node1 lib]$ ./bbed password=blockedit

BBED: Release 2.0.0.0.0 - Limited Production on Thu Jul 10 17:57:09 2014

 

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

 

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

SET

此時沒有指定任何的parfile登入,show命令看不到環境資訊

BBED> show

        FILE#           0

        BLOCK#          1

        OFFSET          0

        DBA             0x00000000 (0 0,1)

        FILENAME       

        BIFILE          bifile.bbd

        LISTFILE       

        BLOCKSIZE       8192

        MODE            Browse

        EDIT            Unrecoverable

        IBASE           Dec

        OBASE           Dec

        WIDTH           80

        COUNT           512

        LOGFILE         log.bbd

        SPOOL           No

 

set filename用來指定資料檔案

BBED> set filename '/u01/app/oracle/oradata/orcl_dup/users01.dbf';

        FILENAME        /u01/app/oracle/oradata/orcl_dup/users01.dbf

 

BBED> show

        FILE#           0

        BLOCK#          1

        OFFSET          0

        DBA             0x00000000 (0 0,1)

        FILENAME        /u01/app/oracle/oradata/orcl_dup/users01.dbf

        BIFILE          bifile.bbd

        LISTFILE       

        BLOCKSIZE       8192

        MODE            Browse

        EDIT            Unrecoverable

        IBASE           Dec

        OBASE           Dec

        WIDTH           80

        COUNT           512

        LOGFILE         log.bbd

        SPOOL           No

 

如果已經指定listfile,也可以直接跟list中對應的檔案編號

 

[oracle@node1 lib]$ cat /u01/bbedlist.parf 

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 

 

指定listfile

 

BBED> set listfile '/u01/bbedlist.parf'             

        LISTFILE        /u01/bbedlist.parf

 

BBED> set file 4;

        FILE#           4

 

BBED> show

        FILE#           4

        BLOCK#          1

        OFFSET          0

        DBA             0x01000001 (16777217 4,1)

        FILENAME        /u01/app/oracle/oradata/orcl_dup/users01.dbf

        BIFILE          bifile.bbd

        LISTFILE        /u01/bbedlist.parf

        BLOCKSIZE       8192

        MODE            Browse

        EDIT            Unrecoverable

        IBASE           Dec

        OBASE           Dec

        WIDTH           80

        COUNT           512

        LOGFILE         log.bbd

        SPOOL           No

 

設定指定檔案中的block

 

BBED> set block 692;

        BLOCK#          692

 

BBED> show

        FILE#           4

        BLOCK#          692

        OFFSET          0

        DBA             0x010002b4 (16777908 4,692)

        FILENAME        /u01/app/oracle/oradata/orcl_dup/users01.dbf

        BIFILE          bifile.bbd

        LISTFILE        /u01/bbedlist.parf

        BLOCKSIZE       8192

        MODE            Browse

        EDIT            Unrecoverable

        IBASE           Dec

        OBASE           Dec

        WIDTH           80

        COUNT           512

        LOGFILE         log.bbd

        SPOOL           No

 

BBED> set block +10

        BLOCK#          702

 

BBED> set block -20 

        BLOCK#          682

 

BBED> show block

        BLOCK#          682

 

設定偏移量

 

BBED> set offset 20;

        OFFSET          20

 

BBED> set offset +1;

        OFFSET          21

 

BBED> set offset -1;              

        OFFSET          20

 

BBED> show offset;

        OFFSET          20

 

設定blocksize大小

該值的大小要與資料庫的db_block_size想對應,否則會報錯

SQL> show parameter db_block_size

 

NAME                                 TYPE        VALUE

------------------------------------ ----------- ------------------------------

db_block_size                        integer     8192

 

BBED> set blocksize 12345;

BBED-00108: illegal BLOCKSIZE (12345) specified

 

BBED> set blocksize 8192;

        BLOCKSIZE       8192

 

width設定當前螢幕的寬度,預設是80

count設定dump 命令顯示bytes的數量。預設是512 bytes

ibase設定內部的數字格式,預設是十進位制;也可以設定為十六進位制或者八進位制;設定完數字格式之後,可是使用該格式來設定blcokoffset

 

BBED> set width 100

        WIDTH           100

 

BBED> set count 1000 

        COUNT           1000

 

一個比較重要的引數 mode設定bbed 的模式,該預設有2種:browse 和 edit。 browse 模式不允許進行修改。 如果要修改,就選擇edit模式。

 

BBED> show mode

        MODE            Browse

 

BBED> set mode edit;

        MODE            Edit

 

BBED> show mode

        MODE            Edit

 

INFO

info顯示當前可以進行browse 或者edit file。即我們filelist 裡指定的datafile資訊。

BBED> info

 File#  Name                                         Size(blks)

 -----  ----                                         ----------

     1  /u01/app/oracle/oradata/orcl_dup/system01.d       64000

     3  /u01/app/oracle/oradata/orcl_dup/sysaux01.d       42240

     4  /u01/app/oracle/oradata/orcl_dup/users01.db       23360

     5  /u01/app/oracle/oradata/orcl_dup/example01.       12800

     6  /u01/app/oracle/oradata/orcl_dup/tts01.dbf         2560

     7  /u01/app/oracle/oradata/orcl_dup/tts02.dbf         2560

     8  /u01/app/oracle/oradata/orcl_dup/undotbs001       12800

MAP

    Map會透過偏移量來顯示block裡的詳細資訊,如block headerdata block header row directory。 使用/v 選項,可以檢視更詳細的資訊。

    在不指定block的情況下,會顯示當前block的資訊,如果想顯示其他block的資訊,可以使用file namefile idblock DBA 來指定要顯示的block

 

BBED> map

 File: /u01/app/oracle/oradata/orcl_dup/users01.dbf (4)

 Block: 682                                   Dba:0x010002aa

------------------------------------------------------------

BBED-00400: invalid blocktype (33)

 

User01.dbf的資料檔案第682上沒有資料,把block設定成上文中的692

BBED> set block +10

        BLOCK#          692

 

BBED> map

 File: /u01/app/oracle/oradata/orcl_dup/users01.dbf (4)

 Block: 692                                   Dba:0x010002b4

------------------------------------------------------------

 KTB Data Block (Table/Cluster)

 

 struct kcbh, 20 bytes                      @0       

 

 struct ktbbh, 96 bytes                     @20      

 

 struct kdbh, 14 bytes                      @124     

 

 struct kdbt[1], 4 bytes                    @138     

 

 sb2 kdbr[2]                                @142     

 

 ub1 freespace[8018]                        @146     

 

 ub1 rowdata[24]                            @8164    

 

 ub4 tailchk                                @8188    

 

用/v引數查詢指定的塊的詳細資訊

 

BBED> map /v dba 4,693

 File: /u01/app/oracle/oradata/orcl_dup/users01.dbf (4)

 Block: 693                                   Dba:0x010002b5

------------------------------------------------------------

 KTB Data Block (Index Leaf)

 

 struct kcbh, 20 bytes                      @0       

    ub1 type_kcbh                           @0       

    ub1 frmt_kcbh                           @1       

    ub1 spare1_kcbh                         @2       

    ub1 spare2_kcbh                         @3       

    ub4 rdba_kcbh                           @4       

    ub4 bas_kcbh                            @8       

    ub2 wrp_kcbh                            @12      

    ub1 seq_kcbh                            @14      

    ub1 flg_kcbh                            @15      

    ub2 chkval_kcbh                         @16      

    ub2 spare3_kcbh                         @18      

 

 struct ktbbh, 72 bytes                     @20      

    ub1 ktbbhtyp                            @20      

    union ktbbhsid, 4 bytes                 @24      

    struct ktbbhcsc, 8 bytes                @28      

    b2 ktbbhict                             @36      

    ub1 ktbbhflg                            @38      

    ub1 ktbbhfsl                            @39      

    ub4 ktbbhfnx                            @40      

    struct ktbbhitl[2], 48 bytes            @44      

 

 struct kdxle, 32 bytes                     @100     

    struct kdxlexco, 16 bytes               @100     

    b2 kdxlespl                             @116     

    sb2 kdxlende                            @118     

    ub4 kdxlenxt                            @120     

    ub4 kdxleprv                            @124     

    ub1 kdxledsz                            @128     

    ub1 kdxleunuse                          @129     

 

 b2 kd_off[239]                             @132     

 

 ub1 freespace[68]                          @610     

 

 ub1 rowdata[7450]                          @678     

 

 ub4 tailchk                                @8188   

 

我們看到692693的後四個部分及其相似,是因為oracleblocks 的最後4bytes tail checkOracleblock tail 4bytes組成,但實際上只用了低2bytes來存放。 2bytestail scn baseblock type 和 scn sequence 組成。雖然tail check 3個部分組成,但是oracle 把這3部分作為一個整體來儲存,並且佔用4bytes

DUMP

dump命令可以講block 的內從顯示到螢幕。 每次顯示的bytescount 控制,預設是512 bytes。 使用 /v 選項,可以顯示更多詳細資訊。

 

BBED> dump /v dba 4,692 offset 0 count 200

 File: /u01/app/oracle/oradata/orcl_dup/users01.dbf (4)

 Block: 692     Offsets:    0 to  199  Dba:0x010002b4

-------------------------------------------------------

 06a20000 b4020001 21f71f00 00000204 l .?..?...!?......

 04e50000 01000000 46df0000 20f71f00 l .?......F?.. 

 00000000 03003200 b1020001 ffff0000 l ......2.?.......

 00000000 00000000 00000000 00800000 l ................

 20f71f00 00000000 00000000 00000000 l  ?..............

 00000000 00000000 00000000 00000000 l ................

 00000000 00000000 00000000 00000000 l ................

 00000000 00000000 00000000 00010200 l ................

 ffff1600 681f521f 521f0000 0200761f l ....h.R.R.....v.

 681f0000 00000000 00000000 00000000 l h...............

 00000000 00000000 00000000 00000000 l ................

 00000000 00000000 00000000 00000000 l ................

 00000000 00000000                   l ........

 

 <16 bytes per line>

 

其中拿第一行的bytes為例,架構如下:

Type

Format

Unused

RDBA

SCN Base

SCN Wrap

Seq

Flag

06

a2

0000

b4020001

21f71f00

0000

02

03

 

PRINT

print命令輸出data structures。 在使用print時,可以指定dbablock 等引數來限定輸出特定block(縮寫是p)

 

BBED> print dba 4,693 offset 1

kcbh.frmt_kcbh

--------------

ub1 frmt_kcbh                               @1        0xa2

 

BBED> print dba 4,693 offset 20

ktbbh.ktbbhtyp

--------------

ub1 ktbbhtyp                                @20       0x02 (KDDBTINDEX)

 

使用map命令列出該塊的詳細資訊,注意上面列出的偏移量為120時的structures

BBED> map /v dba 4,693

 File: /u01/app/oracle/oradata/orcl_dup/users01.dbf (4)

 Block: 693                                   Dba:0x010002b5

------------------------------------------------------------

 KTB Data Block (Index Leaf)

 

 struct kcbh, 20 bytes                      @0       

    ub1 type_kcbh                           @0       

    ub1 frmt_kcbh                           @1       

    ub1 spare1_kcbh                         @2       

    ub1 spare2_kcbh                         @3       

    ub4 rdba_kcbh                           @4       

    ub4 bas_kcbh                            @8       

    ub2 wrp_kcbh                            @12      

    ub1 seq_kcbh                            @14      

    ub1 flg_kcbh                            @15      

    ub2 chkval_kcbh                         @16      

    ub2 spare3_kcbh                         @18      

 

 struct ktbbh, 72 bytes                     @20      

    ub1 ktbbhtyp                            @20      

    union ktbbhsid, 4 bytes                 @24      

    struct ktbbhcsc, 8 bytes                @28      

    b2 ktbbhict                             @36      

    ub1 ktbbhflg                            @38      

    ub1 ktbbhfsl                            @39      

    ub4 ktbbhfnx                            @40      

    struct ktbbhitl[2], 48 bytes            @44      

 

 struct kdxle, 32 bytes                     @100     

    struct kdxlexco, 16 bytes               @100     

    b2 kdxlespl                             @116     

    sb2 kdxlende                            @118     

    ub4 kdxlenxt                            @120     

    ub4 kdxleprv                            @124     

    ub1 kdxledsz                            @128     

    ub1 kdxleunuse                          @129     

 

 b2 kd_off[239]                             @132     

 ub1 freespace[68]                          @610     

 ub1 rowdata[7450]                          @678     

 ub4 tailchk                                @8188   

 

透過print structname檢視一下指定struct對照關係

 

BBED> print 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        0x010002b4

   ub4 bas_kcbh                             @8        0x001ff721

   ub2 wrp_kcbh                             @12       0x0000

   ub1 seq_kcbh                             @14       0x02

   ub1 flg_kcbh                             @15       0x04 (KCBHFCKV)

   ub2 chkval_kcbh                          @16       0xe504

   ub2 spare3_kcbh                          @18       0x0000

BBED> print ktbbh

struct ktbbh, 96 bytes                      @20      

   ub1 ktbbhtyp                             @20       0x01 (KDDBTDATA)

   union ktbbhsid, 4 bytes                  @24      

      ub4 ktbbhsg1                          @24       0x0000df46

      ub4 ktbbhod1                          @24       0x0000df46

   struct ktbbhcsc, 8 bytes                 @28      

      ub4 kscnbas                           @28       0x001ff720

      ub2 kscnwrp                           @32       0x0000

   b2 ktbbhict                              @36       3

   ub1 ktbbhflg                             @38       0x32 (NONE)

   ub1 ktbbhfsl                             @39       0x00

   ub4 ktbbhfnx                             @40       0x010002b1

   struct ktbbhitl[0], 24 bytes             @44      

      struct ktbitxid, 8 bytes              @44      

         ub2 kxidusn                        @44       0xffff

         ub2 kxidslt                        @46       0x0000

         ub4 kxidsqn                        @48       0x00000000

      struct ktbituba, 8 bytes              @52      

         ub4 kubadba                        @52       0x00000000

         ub2 kubaseq                        @56       0x0000

         ub1 kubarec                        @58       0x00

      ub2 ktbitflg                          @60       0x8000 (KTBFCOM)

      union _ktbitun, 2 bytes               @62      

         b2 _ktbitfsc                       @62       0

         ub2 _ktbitwrp                      @62       0x0000

      ub4 ktbitbas                          @64       0x001ff720

   struct ktbbhitl[1], 24 bytes             @68      

      struct ktbitxid, 8 bytes              @68      

         ub2 kxidusn                        @68       0x0000

         ub2 kxidslt                        @70       0x0000

         ub4 kxidsqn                        @72       0x00000000

      struct ktbituba, 8 bytes              @76      

         ub4 kubadba                        @76       0x00000000

         ub2 kubaseq                        @80       0x0000

         ub1 kubarec                        @82       0x00

      ub2 ktbitflg                          @84       0x0000 (NONE)

      union _ktbitun, 2 bytes               @86      

         b2 _ktbitfsc                       @86       0

         ub2 _ktbitwrp                      @86       0x0000

      ub4 ktbitbas                          @88       0x00000000

   struct ktbbhitl[2], 24 bytes             @92      

      struct ktbitxid, 8 bytes              @92      

         ub2 kxidusn                        @92       0x0000

         ub2 kxidslt                        @94       0x0000

         ub4 kxidsqn                        @96       0x00000000

      struct ktbituba, 8 bytes              @100     

         ub4 kubadba                        @100      0x00000000

         ub2 kubaseq                        @104      0x0000

         ub1 kubarec                        @106      0x00

      ub2 ktbitflg                          @108      0x0000 (NONE)

      union _ktbitun, 2 bytes               @110     

         b2 _ktbitfsc                       @110      0

         ub2 _ktbitwrp                      @110      0x0000

      ub4 ktbitbas                          @112      0x00000000

 

反過來透過structure來print出具體的位移量

BBED> print ktbbhtyp

ub1 ktbbhtyp                                @20       0x01 (KDDBTDATA)

 

print 一個data structure 時,輸出的格式如下

 

BBED> p kdbr

sb2 kdbr[0]                                 @142      8054

sb2 kdbr[1]                                 @144      8040

 

從結果中可以看出,該資料塊有兩條記錄,每行的pointer需要2個位元組來儲存,可以x顯示*kdbr[0]值得到該資料塊對應的內容

 

BBED> p *kdbr[0]

rowdata[14]

-----------

ub1 rowdata[14]                             @8178     0x2c

 

Dump出該資料塊的具體資訊

 

BBED> dump /v dba 4,692 offset 8178 count 200

 File: /u01/app/oracle/oradata/orcl_dup/users01.dbf (4)

 Block: 692     Offsets: 8178 to 8191  Dba:0x010002b4

-------------------------------------------------------

 2c000106 31323334 35360206 21f7     l ,...123456..!?

 

 <16 bytes per line>

 

既然知道了offset,也可以直接輸出絕對的offset內容(/d是以十進位制格式輸出)

 

BBED> p /d offset 8178

rowdata[14]

-----------

ub1 rowdata[14]                             @8178     44

 

EXAMINE

examine命令也是用來顯示datablock的內容(簡寫x),該命令可以跟print結合到一起對資料庫和資料庫中的資料進行對照說明。

 

BBED> show

        FILE#           4

        BLOCK#          692

        OFFSET          8164

        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           200

        LOGFILE         log.bbd

        SPOOL           No

 

SQL> select job,dbms_rowid.rowid_block_number(rowid)blockno from bbed_test;

 

JOB                          BLOCKNO

------------------------- ----------

123456                           692

1234567890                       692

 

 

BBED> p *kdbr[0]

rowdata[14]

-----------

ub1 rowdata[14]                             @8178     0x2c

 

BBED> x /rcnn

rowdata[14]                                 @8178    

-----------

flag@8178: 0x2c (KDRHFL, KDRHFF, KDRHFH)

lock@8179: 0x00

cols@8180:    1

 

col    0[6] @8181: 123456

 

BBED> x /rcnn

rowdata[0]                                  @8164    

----------

flag@8164: 0x2c (KDRHFL, KDRHFF, KDRHFH)

lock@8165: 0x00

cols@8166:    1

 

col   0[10] @8167: 1234567890

 

examine也可以多行顯示

比如:

BBED> p kdbhnrow

b2 kdbhnrow                                 @126      2

該資料塊一共有兩條記錄,將print指向最後一個row

BBED> p *kdbr[1]

rowdata[0]

----------

ub1 rowdata[0]                              @8164     0x2c

 

BBED> x /2rcnn

rowdata[0]                                  @8164    

----------

flag@8164: 0x2c (KDRHFL, KDRHFF, KDRHFH)

lock@8165: 0x00

cols@8166:    1

 

col   0[10] @8167: 1234567890

 

rowdata[14]                                 @8178    

-----------

flag@8178: 0x2c (KDRHFL, KDRHFF, KDRHFH)

lock@8179: 0x00

cols@8180:    1

 

col    0[6] @8181: 123456

 

FIND

find命令可以用來搜尋關鍵字。 可以從offset 0 搜尋到top 或者從當前的offset 搜尋到top(縮寫f)

 

SQL> select job,dbms_rowid.rowid_block_number(rowid)blockno from bbed_test;

 

JOB                          BLOCKNO

------------------------- ----------

123456                           692

1234567890                       692

Find命令查詢123456命令

BBED> find /c 123456 top

 File: /u01/app/oracle/oradata/orcl_dup/users01.dbf (4)

 Block: 692              Offsets: 8168 to 8191           Dba:0x010002b4

------------------------------------------------------------------------

 31323334 35363738 39302c00 01063132 33343536 020621f7 

 

 <32 bytes per line>

 

Dump出該offset的資料看看

 

BBED> dump /v dba 4,692 offset 8168 count 200

 File: /u01/app/oracle/oradata/orcl_dup/users01.dbf (4)

 Block: 692     Offsets: 8168 to 8191  Dba:0x010002b4

-------------------------------------------------------

 31323334 35363738 39302c00 01063132 l 1234567890,...12

 33343536 020621f7                  l 3456..!

 

如果想要接著搜尋,可以再次輸入find即可

 

BBED> set offset 0

        OFFSET          0

 

BBED> find /c 123 top

 File: /u01/app/oracle/oradata/orcl_dup/users01.dbf (4)

 Block: 692              Offsets: 8168 to 8191           Dba:0x010002b4

------------------------------------------------------------------------

 31323334 35363738 39302c00 01063132 33343536 020621f7 

 

 <32 bytes per line>

 

BBED> find

 File: /u01/app/oracle/oradata/orcl_dup/users01.dbf (4)

 Block: 692              Offsets: 8182 to 8191           Dba:0x010002b4

------------------------------------------------------------------------

 31323334 35360206 21f7 

 

 <32 bytes per line>

 

BBED> find

BBED-00212: search string not found

copy用來複制資料塊,不要隨便copy資料庫!

 

BBED> copy dba 4,691 to dba 4,692

 File: /u01/app/oracle/oradata/orcl_dup/users01.dbf (4)

 Block: 692              Offsets: 8182 to 8191           Dba:0x010002b4

------------------------------------------------------------------------

 00000000 00000123 23f7 

 <32 bytes per line>

 

SQL> alter system flush buffer_cache;

System altered.

SQL> conn scott/oracle

Connected.

 

SQL> select * from bbed_test;

select * from bbed_test

              *

ERROR at line 1:

ORA-01578: ORACLE data block corrupted (file # 4, block # 692)

ORA-01110: data file 4: '/u01/app/oracle/oradata/orcl_dup/users01.dbf'

 

REVERT

revert是恢復自bbed 啟動以來的所有修改。

 

BBED> revert dba 4,692

All changes made to this block will be rolled back. Proceed? (Y/N) Y

Reverted file '/u01/app/oracle/oradata/orcl_dup/users01.dbf', block 692

 

SQL> alter system flush buffer_cache;

System altered.

 

SQL> conn scott/oracle

Connected.

SQL> select * from bbed_test;

 

JOB

-------------------------

123456

1234567890

 

MODIFY

modify用來修改資料庫資訊(縮寫m

 

BBED> modify /c 654321 dba 4,692 offset 8182

 File: /u01/app/oracle/oradata/orcl_dup/users01.dbf (4)

 Block: 692              Offsets: 8182 to 8191           Dba:0x010002b4

------------------------------------------------------------------------

 36353433 32310206 21f7 

 

 <32 bytes per line>

 

BBED> dump /v dba 4,692 offset 8182 

 File: /u01/app/oracle/oradata/orcl_dup/users01.dbf (4)

 Block: 692     Offsets: 8182 to 8191  Dba:0x010002b4

-------------------------------------------------------

 36353433 32310206 21f7              l 654321..!?

 

 <16 bytes per line>

 

VERIFY

此時查詢資料是無法查詢的,此時的塊由於更改處於損壞狀態

BBED> verify

DBVERIFY - Verification starting

FILE = /u01/app/oracle/oradata/orcl_dup/users01.dbf

BLOCK = 692

 

Block 692 is corrupt

Corrupt block relative dba: 0x010002b4 (file 0, block 692)

Bad check value found during verification

Data in bad block:

 type: 6 format: 2 rdba: 0x010002b4

 last change scn: 0x0000.001ff721 seq: 0x2 flg: 0x04

 spare1: 0x0 spare2: 0x0 spare3: 0x0

 consistency value in tail: 0xf7210602

 check value in block header: 0xe504

 computed block checksum: 0x101

 

 

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

 

SQL> select * from bbed_test;  //查詢前別忘了清理一下cache alter system flush buffer_cache;

select * from bbed_test

*

ERROR at line 1:

ORA-01578: ORACLE data block corrupted (file # 4, block # 692)

ORA-01110: data file 4: '/u01/app/oracle/oradata/orcl_dup/users01.dbf'

 

sum apply使對塊的修改生效,sum 後跟引數apply是為了即時生效

 

BBED> sum dba 4,692 apply

Check value for File 4, Block 692:

current = 0xe405, required = 0xe405

 

此時在檢查該塊,發現塊已經正常

BBED> verify  

DBVERIFY - Verification starting

FILE = /u01/app/oracle/oradata/orcl_dup/users01.dbf

BLOCK = 692

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

 

去資料庫檢視一下,資料已經更改成功

 

SQL> alter system flush buffer_cache;

System altered.

 

SQL> conn scott/oracle

Connected.

SQL> select * from bbed_test;

JOB

-------------------------

123456

0987654321

 

UNDO

undo命令用來回滾最後一次的操作

 

更改一個資料

BBED> dump /v offset 8182

 File: /u01/app/oracle/oradata/orcl_dup/users01.dbf (4)

 Block: 692     Offsets: 8182 to 8191  Dba:0x010002b4

-------------------------------------------------------

 31323334 35360206 21f7              l 123456..!?

 

 <16 bytes per line>

 

BBED> modify /x 654321 dba 4,692 offset 8182

 File: /u01/app/oracle/oradata/orcl_dup/users01.dbf (4)

 Block: 692              Offsets: 8182 to 8191           Dba:0x010002b4

------------------------------------------------------------------------

 65432134 35360206 21f7 

 

 <32 bytes per line>

 

BBED> verify

DBVERIFY - Verification starting

FILE = /u01/app/oracle/oradata/orcl_dup/users01.dbf

BLOCK = 692

 

Block 692 is corrupt

Corrupt block relative dba: 0x010002b4 (file 0, block 692)

Bad check value found during verification

Data in bad block:

 type: 6 format: 2 rdba: 0x010002b4

 last change scn: 0x0000.001ff721 seq: 0x2 flg: 0x04

 spare1: 0x0 spare2: 0x0 spare3: 0x0

 consistency value in tail: 0xf7210602

 check value in block header: 0xe504

 computed block checksum: 0x7146

 

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

 

BBED> sum dba 4,692 apply;

Check value for File 4, Block 692:

current = 0x9442, required = 0x9442

 

BBED> verify

DBVERIFY - Verification starting

FILE = /u01/app/oracle/oradata/orcl_dup/users01.dbf

BLOCK = 692

 

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

 

資料庫中可以檢視更改

SQL> alter system flush buffer_cache;

System altered.

 

SQL> conn scott/oracle

Connected.

SQL> select * from bbed_test;

 

JOB

-------------------------

eC!456

1234567890

 

使用undo回滾

BBED> undo

BBED> modify /x 313233 filename '/u01/app/oracle/oradata/orcl_dup/users01.dbf' block 692. offset 8182.

 File: /u01/app/oracle/oradata/orcl_dup/users01.dbf (4)

 Block: 692              Offsets: 8182 to 8191           Dba:0x010002b4

------------------------------------------------------------------------

 31323334 35360206 21f7 

 

 <32 bytes per line>

 

BBED> verify

DBVERIFY - Verification starting

FILE = /u01/app/oracle/oradata/orcl_dup/users01.dbf

BLOCK = 692

 

Block 692 is corrupt

Corrupt block relative dba: 0x010002b4 (file 0, block 692)

Bad check value found during verification

Data in bad block:

 type: 6 format: 2 rdba: 0x010002b4

 last change scn: 0x0000.001ff721 seq: 0x2 flg: 0x04

 spare1: 0x0 spare2: 0x0 spare3: 0x0

 consistency value in tail: 0xf7210602

 check value in block header: 0x9442

 computed block checksum: 0x7146

 

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

 

BBED> sum dba 4,692 apply;

Check value for File 4, Block 692:

current = 0xe504, required = 0xe504

 

BBED> verify

DBVERIFY - Verification starting

FILE = /u01/app/oracle/oradata/orcl_dup/users01.dbf

BLOCK = 692

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

 

資料庫中再次檢視資料已經回滾

 

SQL> alter system flush buffer_cache;

System altered.

 

SQL> conn scott/oracle

Connected.

SQL> select * from bbed_test;

 

JOB

-------------------------

123456

1234567890

 

其他命令此處不一一測試,主要的命令也就上面那麼多了。

 


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

相關文章