BBED工具的安装使用(二)

BBED常用的命令如下:

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

 

[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设置内部的数字格式,默认是十进制;也可以设置为十六进制或者八进制;设置完数字格式之后,可是使用该格式来设置blcok,offset等

 

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 header,data block header 和row directory。 使用/v 选项,可以查看更详细的信息。

    在不指定block的情况下,会显示当前block的信息,如果想显示其他block的信息,可以使用file name,file id,block 和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   

 

我们看到692和693的后四个部分及其相似,是因为oracleblocks 的最后4个bytes 是tail check。Oracleblock tail 由4个bytes组成,但实际上只用了低2个bytes来存放。 2个bytes的tail 由scn base,block type 和 scn sequence 组成。虽然tail check 由3个部分组成,但是oracle 把这3部分作为一个整体来存储,并且占用4个bytes。

DUMP

dump命令可以讲block 的内从显示到屏幕。 每次显示的bytes由count 控制,默认是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时,可以指定dba,block 等参数来限定输出特定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命令列出该块的详细信息,注意上面列出的偏移量为1和20时的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/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/29320885/viewspace-1216978/

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值