欢迎光临
我们一直在努力

使用BBED修复坏块一例

使用BBED修复坏块一例

用户在查询一张表的时候报错:

SQL> select count(*) from crm.t;

select count(*) from crm.t *

ERROR at line 1:

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

ORA-01110: data file 4:

‘/oracle/oradata/ORCL/datafile/o1_mf_users_9xd4v32s_.dbf’

很显然,这张表中存在坏块,于是通过DBV检查确认:

[oracle@CRMDB ~]$ dbv file=/oracle/oradata/ORCL/datafile/o1_mf_users_9xd4v32s_.dbf

DBVERIFY: Release 11.2.0.1.0 – Production on Sat Aug 30 06:02:32 2014

Copyright (c) 1982, 2009, Oracle and/or its affiliates. All rights reserved.

DBVERIFY – Verification starting : FILE = /oracle/oradata/ORCL/datafile/o1_mf_users_9xd4v32s_.dbf

DBV-00200: Block, DBA 16777747, already marked corrupt

csc(0x0000.00305a03) higher than block scn(0x0000.00000000)

Page 531 failed with check code 6054

DBVERIFY – Verification complete

Total Pages Examined : 101280

Total Pages Processed (Data) : 18517

Total Pages Failing (Data) : 1

Total Pages Processed (Index): 2124

Total Pages Failing (Index): 0

Total Pages Processed (Other): 80395

Total Pages Processed (Seg) : 0

Total Pages Failing (Seg) : 0

Total Pages Empty : 244

Total Pages Marked Corrupt : 1

Total Pages Influx : 0

Total Pages Encrypted : 0

Highest block SCN : 3677313 (0.3677313)

发现只是块的元信息有不一致的情况,实际数据应该还在,由于客户并没有rman备份,此时可以通过一些办法进行修复。

1)通过10231事件跳过损坏的block,导出数据并重建表,但这种办法会丢失损坏的块中的数据。

使用常规方式导出表,当导到坏块的时候会报错1578,并终止exp:

[oracle@CRMDB ~]$ exp hr/hr file=/tmp/a.dmp tables=crm.t

Export: Release 11.2.0.1.0 – Production on Sat Aug 30 06:38:29 2014

Copyright (c) 1982, 2009, Oracle and/or its affiliates. All rights reserved.

Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 – 64bit Production

With the Partitioning, OLAP, Data Mining and Real Application Testing options

Export done in ZHS16GBK character set and AL16UTF16 NCHAR character set

About to export specified tables via Conventional Path …

. . exporting table A

EXP-00056: ORACLE error 1578 encountered

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

ORA-01110: data file 4: ‘/oracle/oradata/ORCL/datafile/o1_mf_users_9xd4v32s_.dbf’

Export terminated successfully with warnings.

[oracle@CRMDB ~]$

需要设置10231事件,再执行exp:

SQL> alter system set events ‘10231 trace name context forever’;

System altered.

[oracle@CRMDB ~]$ exp hr/hr file=/backup/a.dmp tables=crm.t

Export: Release 11.2.0.1.0 – Production on Sat Aug 30 06:42:01 2014

Copyright (c) 1982, 2009, Oracle and/or its affiliates. All rights reserved.

Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 – 64bit Production

With the Partitioning, OLAP, Data Mining and Real Application Testing options

Export done in ZHS16GBK character set and AL16UTF16 NCHAR character set

About to export specified tables via Conventional Path …

. . exporting table A 1955539 rows exported

Export terminated successfully without warnings.

[oracle@CRMDB ~]$

exp之后就可以重建表了。

如果可以容忍坏块中的数据丢失,可以采用第一种办法,否则,可以尝试第二种方法。

2)通过bbed修改块的元数据。

BBED> set dba 4,531

DBA 0x01000213 (16777747 4,531)

BBED> p 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 0x01000213

ub4 bas_kcbh @8 0x00000000

ub2 wrp_kcbh @12 0x0000

ub1 seq_kcbh @14 0xff

ub1 flg_kcbh @15 0x04 (KCBHFCKV)

ub2 chkval_kcbh @16 0xd21f

ub2 spare3_kcbh @18 0x0000

可以看到bas_kcbh=0/seq_kcbh=0xff,这2个值都有问题,参考下一个数据块的值进行修复。

BBED> set block +1

BLOCK# 532

BBED> p 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 0x01000214

ub4 bas_kcbh @8 0x00353895

ub2 wrp_kcbh @12 0x0000

ub1 seq_kcbh @14 0x1c

ub1 flg_kcbh @15 0x04 (KCBHFCKV)

ub2 chkval_kcbh @16 0x07c3

ub2 spare3_kcbh @18 0x0000

BBED> set block -1

BLOCK# 531

BBED> set offset 8

OFFSET 8

BBED> modify /x 0x953835

File: /oracle/oradata/ORCL/datafile/o1_mf_users_9xd4v32s_.dbf (4)

Block: 531 Offsets: 8 to 519 Dba:0x01000213

————————————————————————

95383500 0000ff04 1fd20000 01000000 f8440100 035a3000 00000000 03003200

10020001 ffff0000 00000000 00000000 00000000 00800000 035a3000 00000000

00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000

00000000 00000000 00000000 00000000 00000000 00014700 ffffa000 96037203

72030000 47009603 f4035504 b8041f05 8105db05 3c069c06 fe066107 c5072408

8f08f808 5c09bb09 1f0a7f0a e00a3e0b a70b020c 630ccb0c 2e0d900d 6e14ce14

31159615 ff156316 bf162217 8417e817 4d18b318 14198119 ec19521a b31a191b

7b1bc61e 5b1efe1d 9b1d311d cc1c681c 001cf60d 530eb30e 150f7b0f dc0f3510

9510f410 5511b711 1a127812 e2124a13 ad130b14 00000000 00000000 00000000

00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000

00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000

2c001303 53595307 495f5553 455231ff 02c12f02 c12f0549 4e444558 07786d08

0f011134 07786d08 0f011134 13323030 392d3038 2d31353a 30303a31 363a3531

0556414c 4944014e 014e014e 02c105ff 02c15105 53616c65 7303c202 2e02c21a

2c001303 53595307 495f5553 455231ff 02c12f02 c12f0549 4e444558 07786d08

0f011134 07786d08 0f011134 13323030 392d3038 2d31353a 30303a31 363a3531

<32 bytes per line>

BBED> modify /x 0x1c offset 14

File: /oracle/oradata/ORCL/datafile/o1_mf_users_9xd4v32s_.dbf (4)

Block: 531 Offsets: 14 to 525 Dba:0x01000213

————————————————————————

1c04bfea 00000100 0000f844 0100035a 30000000 00000300 32001002 0001ffff

00000000 00000000 00000000 00000080 0000035a 30000000 00000000 00000000

00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000

00000000 00000000 00000000 00000001 4700ffff a0009603 72037203 00004700

9603f403 5504b804 1f058105 db053c06 9c06fe06 6107c507 24088f08 f8085c09

bb091f0a 7f0ae00a 3e0ba70b 020c630c cb0c2e0d 900d6e14 ce143115 9615ff15

6316bf16 22178417 e8174d18 b3181419 8119ec19 521ab31a 191b7b1b c61e5b1e

fe1d9b1d 311dcc1c 681c001c f60d530e b30e150f 7b0fdc0f 35109510 f4105511

b7111a12 7812e212 4a13ad13 0b140000 00000000 00000000 00000000 00000000

00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000

00000000 00000000 00000000 00000000 00000000 00000000 00002c00 13035359

5307495f 55534552 31ff02c1 2f02c12f 05494e44 45580778 6d080f01 11340778

6d080f01 11341332 3030392d 30382d31 353a3030 3a31363a 35310556 414c4944

014e014e 014e02c1 05ff02c1 51055361 6c657303 c2022e02 c21a2c00 13035359

5307495f 55534552 31ff02c1 2f02c12f 05494e44 45580778 6d080f01 11340778

6d080f01 11341332 3030392d 30382d31 353a3030 3a31363a 35310556 414c4944

<32 bytes per line>

BBED> p 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 0x01000213

ub4 bas_kcbh @8 0x00353895

ub2 wrp_kcbh @12 0x0000

ub1 seq_kcbh @14 0x1c

ub1 flg_kcbh @15 0x04 (KCBHFCKV)

ub2 chkval_kcbh @16 0xeabf

ub2 spare3_kcbh @18 0x0000

经验证,已经修改过来了,但还需要重新设置tailchk的值,在Oracle块中,tailchk必须等于(scn的后四位+type+seq),

否则在读写块的时候,Oracle会报错。

此时的tailchk是不一致的:

BBED> p tailchk

ub4 tailchk @8188 0x000006ff

修改tailchk的值:

BBED> modify /x 0x1c069538 offset 8188

File: /oracle/oradata/ORCL/datafile/o1_mf_users_9xd4v32s_.dbf (4)

Block: 531 Offsets: 8188 to 8191 Dba:0x01000213

————————————————————————

1c069538

<32 bytes per line>

BBED> p tailchk

ub4 tailchk @8188 0x3895061c

BBED> sum apply

Check value for File 4, Block 531:

current = 0xd22a, required = 0xd22a

此时执行DBV检查:

[oracle@CRMDB ~]$ dbv file=/oracle/oradata/ORCL/datafile/o1_mf_users_9xd4v32s_.dbf

DBVERIFY: Release 11.2.0.1.0 – Production on Sat Aug 30 06:33:13 2014

Copyright (c) 1982, 2009, Oracle and/or its affiliates. All rights reserved.

DBVERIFY – Verification starting : FILE = /oracle/oradata/ORCL/datafile/o1_mf_users_9xd4v32s_.dbf

DBVERIFY – Verification complete

Total Pages Examined : 101280

Total Pages Processed (Data) : 18517

Total Pages Failing (Data) : 0

Total Pages Processed (Index): 2124

Total Pages Failing (Index): 0

Total Pages Processed (Other): 80395

Total Pages Processed (Seg) : 0

Total Pages Failing (Seg) : 0

Total Pages Empty : 244

Total Pages Marked Corrupt : 0

Total Pages Influx : 0

Total Pages Encrypted : 0

Highest block SCN : 3749884 (0.3749884)

[oracle@CRMDB ~]$

此时再次执行查询:

SQL> select count(*) from crm.t;

COUNT(*)

———-

1955610

SQL>

坏块已经被修复了。

未经允许不得转载:SRE空间 » 使用BBED修复坏块一例

分享到:更多 ()

评论 抢沙发

评论前必须登录!

 

oracle