数据库

位置:IT落伍者 >> 数据库 >> 浏览文章

Oracle的一个内部工具blockcorruption


发布日期:2022年06月06日
 
Oracle的一个内部工具blockcorruption

有人在Google新闻组上提出了一个问题:How can I get the BBED password?继而引发了一场很有意思的讨论

后来Pete Finnigan也在他的Blog写了一篇文章An interesting thread on Oraclel about BBED描述这次有意思的探讨

在讨论中有一个有趣的观点提到如果这个工具被广泛传播那么可能有些人不是用BBED来修复数据意外的破坏可能更为多见最终的后果可能是Oracle彻底把这个工具移除

BBED是Block Browser/Editor的缩写是Oracle的一个内部工具不对外发布文档及支持

BBED随软件发布但是我们需要进行简单的relink才能使用relink请参考:How to compile Oracleg BBED tools

虽然BBED工具的使用存在很多风险但是如果利用得当可以以之解决很多棘手的问题

本文简单介绍一下如何用BBED模拟坏块以练习坏块修复等技术此前我曾经介绍过另外一种方法请参考:Oracle中模拟及修复数据块损坏

创建测试表

[oracle@jumper conner]$ sqlplus / as sysdba

SQL*Plus: Release Production on Sun Sep ::

Copyright (c) Oracle Corporation All rights reserved

Connected to:

Oraclei Enterprise Edition Release Production

With the Partitioning option

JServer Release Production

SQL> create table bbed tablespace users as select * from dba_tables;

Table created

SQL> select count(*) from bbed;

COUNT(*)

SQL> col segment_name for a

SQL> select segment_namefile_idblock_id from dba_extents where segment_name=BBED;

SEGMENT_NA FILE_ID BLOCK_ID

BBED

BBED

BBED

SQL> select count(*) from bbed;

COUNT(*)

创建BBED参数文件等

[oracle@jumper conner]$ more filelisttxt

/opt/oracle/oradata/conner/systemdbf

/opt/oracle/oradata/conner/undotbsdbf

/opt/oracle/oradata/conner/usersdbf

[oracle@jumper conner]$ more parbbd

blocksize=

listfile=filelisttxt

mode=edit

使用BBED

[oracle@jumper conner]$ bbed parfile=parbbd

Password:

BBED: Release Limited Production on Sun Sep ::

Copyright (c) Oracle Corporation All rights reserved

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

BBED> set file

FILE#

BBED> show

FILE#

BLOCK#

OFFSET

DBA xc ( )

FILENAME /opt/oracle/oradata/conner/usersdbf

BIFILE bifilebbd

LISTFILE filelisttxt

BLOCKSIZE

MODE Edit

EDIT Unrecoverable

IBASE Dec

OBASE Dec

WIDTH

COUNT

LOGFILE logbbd

SPOOL No

回滚误操作

如果操作中发生误操作可以使用revert命令回滚

BBED> modify /x xc

File: /opt/oracle/oradata/conner/usersdbf ()

Block: Offsets: to Dba:xc

c

< bytes per line>

BBED> revert

All changes made in this session will be rolled back Proceed? (Y/N) Y

Reverted file /opt/oracle/oradata/conner/usersdbf block

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

改写数据块

模拟坏块

BBED> modify file block

File: /opt/oracle/oradata/conner/usersdbf ()

Block: Offsets: to Dba:xc

e

cf cf fe fc

ff cde d ffffc bc c c

c ffc c eff c c e ffffffff

ffffffff a a e

e c ffffe fffe ee f c

c e fef ff c e fff

c c cf c f f

fe c dff ffcb c cc c

ff c c eff cc eff ffffffff

ffffffa a e

e cff ffef ffe eef c

c ef efff c ef ff c

cc f c c f f

< bytes per line>

检查数据块损坏

使用verify命令可以发现刚才修改的file block 已经被标记为损坏

BBED> verify

DBVERIFY Verification starting

FILE = /opt/oracle/oradata/conner/usersdbf

BLOCK =

Block is corrupt

***

Corrupt block relative dba: xc (file block )

Bad check value found during verification

Data in bad block

type: format: rdba: xc

last change scn: xab seq: x flg: x

consistency value in tail: xb

check value in block header: x computed block checksum: xe

spare: x spare: x spare: x

***

DBVERIFY Verification complete

Total Blocks Examined :

Total Blocks Processed (Data) :

Total Blocks Failing (Data) :

Total Blocks Processed (Index):

Total Blocks Failing (Index):

Total Blocks Empty :

Total Blocks Marked Corrupt :

Total Blocks Influx :

BBED> quit

使用DBV检查

[oracle@jumper conner]$ dbv file=usersdbf blocksize=

DBVERIFY: Release Production on Sun Sep ::

Copyright (c) Oracle Corporation All rights reserved

DBVERIFY Verification starting : FILE = usersdbf

Page is marked corrupt

***

Corrupt block relative dba: xc (file block )

Bad check value found during dbv:

Data in bad block

type: format: rdba: xc

last change scn: xab seq: x flg: x

consistency value in tail: xb

check value in block header: x computed block checksum: xe

spare: x spare: x spare: x

***

DBVERIFY Verification complete

Total Pages Examined :

Total Pages Processed (Data) :

Total Pages Failing (Data) :

Total Pages Processed (Index):

Total Pages Failing (Index):

Total Pages Processed (Other):

Total Pages Processed (Seg) :

Total Pages Failing (Seg) :

Total Pages Empty :

Total Pages Marked Corrupt :

Total Pages Influx :

全表扫描此时出现ORA错误

重新启动数据库以后执行全表扫描此时错误出现:

SQL> startup force;

ORACLE instance started

Total System Global Area bytes

Fixed Size bytes

Variable Size bytes

Database Buffers bytes

Redo Buffers bytes

Database mounted

Database opened

SQL> select count(*) from bbed;

select count(*) from bbed

*

ERROR at line :

ORA: ORACLE data block corrupted (file # block # )

ORA: data file : /opt/oracle/oradata/conner/usersdbf

SQL>

以上方法仅供测试使用

               

上一篇:AIX 4.3.3 上面安装 oracle 9.2

下一篇:oracle将数据导入指定表空间