ITPub博客

首页 > Linux操作系统 > Linux操作系统 > 用bbed修改data block scn之模拟ora-0600[2662]一

用bbed修改data block scn之模拟ora-0600[2662]一

原创 Linux操作系统 作者:g644516804 时间:2011-12-29 10:44:20 0 删除 编辑

案例出现背景:某个blockscn比该datafile header SCN要大

即是经典的ORA-0600[2662]错误

 

修改blockscn (除了block1),将该blockscn 更改为同当前datafile header SCN 一致

 

 

原理:

File 1 block 1 是块头,记录了该 datafile header scn(整个datafile scn已该header scn为准的)

BBED> set file 1 block 1

        FILE#           1

        BLOCK#          1

 

BBED> p kcvfhckp (只用在block1的地方)

struct kcvfhckp, 36 bytes                   @484

   struct kcvcpscn, 8 bytes                 @484

      ub4 kscnbas                           @484      0x000f2d1a

      ub2 kscnwrp                           @488      0x0000

   ub4 kcvcptim                             @492      0x2def0690

   ub2 kcvcpthr                             @496      0x0001

   union u, 12 bytes                        @500

      struct kcvcprba, 12 bytes             @500

         ub4 kcrbaseq                       @500      0x00000005

         ub4 kcrbabno                       @504      0x000033cf

         ub2 kcrbabof                       @508      0x0010

   ub1 kcvcpetb[0]                          @512      0x02

   ub1 kcvcpetb[1]                          @513      0x00

   ub1 kcvcpetb[2]                          @514      0x00

   ub1 kcvcpetb[3]                          @515      0x00

   ub1 kcvcpetb[4]                          @516      0x00

   ub1 kcvcpetb[5]                          @517      0x00

   ub1 kcvcpetb[6]                          @518      0x00

   ub1 kcvcpetb[7]                          @519      0x00

 

一个block 8k(8192),在偏移量为8的位置上记录了该blockSCN,

BBED> set block 128

        BLOCK#          128

 

BBED> p bas_kcbh

ub4 bas_kcbh                                @8        0x000f2d16

 

可以看到当前blockscn(0x000f2d16<0x000f2d1a)  正常

 

BBED> p tailchk

ub4 tailchk                                 @8188     0x2d160e01

 

Tailchecks p tailchk

       The tail of an Oracle 8+ block is a concatenation of the lower order two bytes ofthe SCN base, the block type and the SCN sequence number.

       Oracle block tail (该block 最后4bytes)由4bytes组成,但实际上只用了低2bytes来存放。 2bytestail scn baseblock type scn sequence 组成。

 

E.g, if the SCN base number is 0x000f2d16 ,the block type is 0e and the SCN sequence number is 0x01, the tail check wouldbe 0x97280602:

 

SCN base     Type   SCN seq

2d16            0e         01

                     

可以计算出 block offset 8188(8192-2*2)为该block scn base=p bas_kcbh查出的 后四位

所以在修改blockscn时,除了需要修改block bas_kcbhoffset 8 还要修改tailchkscn,只修改scn bash,而block typescn sequence不变

并且注意:

在存放的时候是按照低位字节存放的the numbers are stored in little endian format (the low-order byte of thenumber is stored in memory at the lowest address) as this example database isrunning on Linux on an Intel platform.

 

现在修改file 1 block128scn

BBED> set offset 8

        OFFSET          8

 

BBED> dump

 File: /oradata/ora12/system01.dbf (1)

 Block: 128              Offsets:    8 to  135           Dba:0x00400080

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

 162d0f00 00000104 fe200000 00000000 00000000 00000000 00000000 06000000

 2f000000 20100000 03000000 03000000 08000000 1b024000 00000000 03000000

 00000000 00000000 00000000 00000000 00000000 06000000 00000000 00000000

 00000040 81004000 07000000 88004000 08000000 10024000 08000000 18024000

 

 <32 bytes per line>

 

BBED> modify /x 2f2d0f00  (增大该block scn 大于datafile header scn

Warning: contents of previous BIFILE will be lost. Proceed? (Y/N) Y

 File: /oradata/ora12/system01.dbf (1)

 Block: 128              Offsets:    8 to  135           Dba:0x00400080

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

 2f2d0f00 00000104 fe200000 00000000 00000000 00000000 00000000 06000000

 2f000000 20100000 03000000 03000000 08000000 1b024000 00000000 03000000

 00000000 00000000 00000000 00000000 00000000 06000000 00000000 00000000

 00000040 81004000 07000000 88004000 08000000 10024000 08000000 18024000

 

 <32 bytes per line>

 

BBED> p bas_kcbh

ub4 bas_kcbh                                @8        0x000f2d2f

 

BBED> set offset 8188

        OFFSET          8188

 

BBED> p tailchk

ub4 tailchk                                 @8188     0x2d160e01

 

--红色的标记变更,只变base scn,变成0x000f2d2f中的后四位,其他的不变

即变为:2d2f0e01 当注意在真正利用bbed modify 时注意存储方式是按照低位字节存储的

BBED> modify /x 010e2f2d

 File: /oradata/ora12/system01.dbf (1)

 Block: 128              Offsets: 8188 to 8191           Dba:0x00400080

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

 010e2f2d

 

 <32 bytes per line>

 

BBED> p tailchk

ub4 tailchk                                 @8188     0x2d2f0e01

 

修改之后

SQL> startup;

ORACLE instance started.

 

Total System Global Area 1653518336 bytes

Fixed Size                  2213896 bytes

Variable Size             956303352 bytes

Database Buffers          687865856 bytes

Redo Buffers                7135232 bytes

Database mounted.

ORA-01092: ORACLE instance terminated. Disconnection forced

ORA-00600: internal error code, arguments: [2662], [0], [994592], [0],

[994607], [4194432], [], [], [], [], [], []

Process ID: 6732

Session ID: 96 Serial number: 3

 

成功模拟出ora-0600 [2662]错误了

利用ORA-600 [2662] [A][B][C][D][E] 中的E 可以查看出哪个块的SCN比其datafile scn 大的block

 

 

SQL> select dbms_utility.data_block_address_block(4194432) "block",

  dbms_utility.data_block_address_file(4194432) "file" from dual;  2

 

     block       file

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

       128          1

 

BBED> set file 1 block 1

        FILE#           1

        BLOCK#          1

 

BBED> p kcvfhckp

struct kcvfhckp, 36 bytes                   @484

   struct kcvcpscn, 8 bytes                 @484

      ub4 kscnbas                           @484      0x000f2d1d

      ub2 kscnwrp                           @488      0x0000

   ub4 kcvcptim                             @492      0x2def14dd

   ub2 kcvcpthr                             @496      0x0001

   union u, 12 bytes                        @500

      struct kcvcprba, 12 bytes             @500

         ub4 kcrbaseq                       @500      0x00000005

         ub4 kcrbabno                       @504      0x000033cf

         ub2 kcrbabof                       @508      0x0010

   ub1 kcvcpetb[0]                          @512      0x02

   ub1 kcvcpetb[1]                          @513      0x00

   ub1 kcvcpetb[2]                          @514      0x00

   ub1 kcvcpetb[3]                          @515      0x00

   ub1 kcvcpetb[4]                          @516      0x00

   ub1 kcvcpetb[5]                          @517      0x00

   ub1 kcvcpetb[6]                          @518      0x00

   ub1 kcvcpetb[7]                          @519      0x00

 

BBED> set block 128

        BLOCK#          128

 

BBED> p bas_kcbh

ub4 bas_kcbh                                @8        0x000f2d2f

将查询得到的datafile header scn block  scn进行转换,发现得到的结果与

ORA-0600[2662][A][B][C][D][E]中的B 有一定出入当D一样,原因数据库在启动的时候会增加当前的SCN,所以如果BD小一点点,可以通过多次重启数据库达到两者SCN相等或是B大于D

 

 

现在修改block 128scn datafile header SCN一致

 

 

BBED> set block 128

        BLOCK#          128

 

BBED> p bas_kcbh

ub4 bas_kcbh                                @8        0x000f2d2f

 

BBED> set offset 8

        OFFSET          8

 

BBED> modify /x 1d2d0f00

 File: /oradata/ora12/system01.dbf (1)

 Block: 128              Offsets:    8 to  519           Dba:0x00400080

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

 1d2d0f00 00000104 fe200000 00000000 00000000 00000000 00000000 06000000

 2f000000 20100000 03000000 03000000 08000000 1b024000 00000000 03000000

 00000000 00000000 00000000 00000000 00000000 06000000 00000000 00000000

 00000040 81004000 07000000 88004000 08000000 10024000 08000000 18024000

 08000000 20024000 08000000 28024000 08000000 00000000 00000000 00000000

 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000

 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000

 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000

 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000

 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000

 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000

 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000

 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000

 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>

 

BBED> p tailchk

ub4 tailchk                                 @8188     0x2d2f0e01

 

BBED> set offset 8188

        OFFSET          8188

修改tailchk中的base scn

BBED> modify /x 010e1d2d

 File: /oradata/ora12/system01.dbf (1)

 Block: 128              Offsets: 8188 to 8191           Dba:0x00400080

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

 010e1d2d

 

 <32 bytes per line>

 

BBED> p tailchk

ub4 tailchk                                 @8188     0x2d1d0e01

 

BBED> p bas_kcbh

ub4 bas_kcbh                                @8        0x000f2d1d

 

重启数据库

SQL> alter database open;

 

Database altered.

 

注意:利用bbed修改的时候最好是在db 关闭的时,使得数据一致性

当然在出现ora-0600[2662]时,也可以通过alter session set events ‘10015 trace name level n’处理

 

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/24849178/viewspace-714125/,如需转载,请注明出处,否则将追究法律责任。

上一篇: dba rdba转换
请登录后发表评论 登录
全部评论

注册时间:2011-03-04

  • 博文量
    104
  • 访问量
    231717