使用BBED

测试环境:Oracle 9.2.0.8 for Windows-64BIT

1. 创建测试表空间

SQL> CREATE TABLESPACE test DATAFILE
  2    'Y:\TEST01.DBF' SIZE 10M AUTOEXTEND OFF
  3  LOGGING
  4  ONLINE
  5  PERMANENT
  6  EXTENT MANAGEMENT LOCAL UNIFORM SIZE 1M
  7  BLOCKSIZE 8K
  8  SEGMENT SPACE MANAGEMENT AUTO;

Tablespace created

2. 创建测试表

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

Table created

SQL> select count(*) from bbed;

  COUNT(*)
----------
      4068

SQL> select segment_name,file_id,block_id from dba_extents where segment_name='BBED';

SEGMENT_NAME              FILE_ID   BLOCK_ID
---------------------- ---------- ----------
BBED                           54          9

SQL> select file_id, file_name, bytes from dba_data_files;
FILE_ID FILE_NAME                                       BYTES
------- ------------------------------------------ ----------
     54 Y:\TEST01.DBF                                10485760

3. 创建BBED参数文件

filelist.txt: 
1 H:\ORADATA\MSLUAT01\SYSTEM\SYSTEM01.DBF   2147483648
2 H:\ORADATA\MSLUAT01\SYSTEM\UNDOTBS01.DBF  6790578176
54 Y:\TEST01.DBF     10485760

par.bbd:
blocksize=8192
listfile=filelist.txt
mode=edit

4. 使用BBED

Z:\dbashell\test>bbed parfile=par.bbd
Password: 	=>blockedit

BBED: Release 2.0.0.0.0 - Limited Production on 星期二 1月 29 17:05:47 2008

Copyright (c) 1982, 2002, Oracle Corporation.  All rights reserved.

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

BBED> set file 54
        FILE#           54

BBED> show
        FILE#           54
        BLOCK#          1
        OFFSET          0
        DBA             0x0d800001 (226492417 54,1)
        FILENAME        Y:\TEST01.DBF
        BIFILE          bifile.bbd
        LISTFILE        filelist.txt
        BLOCKSIZE       8192
        MODE            Edit
        EDIT            Unrecoverable
        IBASE           Dec
        OBASE           Dec
        WIDTH           80
        COUNT           512
        LOGFILE         log.bbd
        SPOOL           No

5. 测试回滚误操作

BBED> modify /x 0x00c00011
 File: Y:\TEST01.DBF (54)
 Block: 1                Offsets:    0 to  511           Dba:0x0d800001
------------------------------------------------------------------------
 00c00011 0100800d 00000000 00000104 33990000 00002009 00000008 73ccae18
 4d534c55 41543031 331f0000 00050000 00200000 36000300 00000000 00000000
 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
 00000000 1e91ca80 00000000 6c707626 b3916626 01000000 00000000 00000000
 00000000 00000000 00000400 1f91ca80 00000000 6c707626 01000000 51060000
 b4b50000 10000000 02000000 00000000 02000000 00000000 01000000 00000000
 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
 00000000 00000000 00000000 00000000 00000000 23000000 04005445 53540000
 00000000 00000000 00000000 00000000 00000000 00000000 36000000 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> revert
All changes made in this session will be rolled back. Proceed? (Y/N) y
Reverted file 'Y:\TEST01.DBF', block 1
Warning: contents of previous BIFILE will be lost. Proceed? (Y/N) y

6. 改写数据块-模拟坏块

BBED> modify 1000 file 54 block 9
 File: Y:\TEST01.DBF (54)
 Block: 9                Offsets:    0 to  511           Dba:0x0d800009
------------------------------------------------------------------------
 03e80000 09000000 00000000 00000105 09070000 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
 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>

7. 检查数据块损坏
使用verify命令,可以发现刚才修改的file 54 block 9已经被标记为损坏。

BBED> verify
DBVERIFY - Verification starting
FILE = Y:\TEST01.DBF
BLOCK = 9

Block 9 is corrupt
***
Corrupt block relative dba: 0x00000009 (file 0, block 9)
Bad header found during verification
Data in bad block -
 type: 3 format: 0 rdba: 0x00000009
 last change scn: 0x0000.00000000 seq: 0x1 flg: 0x05
 consistency value in tail: 0x00000001
 check value in block header: 0x709, computed block checksum: 0xea03
 spare1: 0x0, spare2: 0x0, spare3: 0x0
***

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> quit

8. 使用DBV检查

Z:\dbashell\test>dbv file=y:\test01.dbf blocksize=8192

DBVERIFY: Release 9.2.0.8.0 - Production on 星期二 1月 29 17:14:50 2008

Copyright (c) 1982, 2002, Oracle Corporation.  All rights reserved.

DBVERIFY - Verification starting : FILE = y:\test01.dbf
Page 9 is marked corrupt
***
Corrupt block relative dba: 0x0d800009 (file 54, block 9)
Bad header found during dbv:
Data in bad block -
 type: 3 format: 0 rdba: 0x00000009
 last change scn: 0x0000.00000000 seq: 0x1 flg: 0x05
 consistency value in tail: 0x00000001
 check value in block header: 0x709, computed block checksum: 0xea03
 spare1: 0x0, spare2: 0x0, spare3: 0x0
***

DBVERIFY - Verification complete

Total Pages Examined         : 1280
Total Pages Processed (Data) : 118
Total Pages Failing   (Data) : 0
Total Pages Processed (Index): 0
Total Pages Failing   (Index): 0
Total Pages Processed (Other): 8
Total Pages Processed (Seg)  : 0
Total Pages Failing   (Seg)  : 0
Total Pages Empty            : 1153
Total Pages Marked Corrupt   : 1
Total Pages Influx           : 0
Highest block SCN            : 2160759141 (0.2160759141)

9. 全表扫描此时出现ORA-01578错误
重新启动数据库以后,执行全表扫描,此时错误出现:

SQL> startup force;
ORACLE instance started.

Total System Global Area  840276672 bytes
Fixed Size                   735936 bytes
Variable Size             301989888 bytes
Database Buffers          536870912 bytes
Redo Buffers                 679936 bytes
Database mounted.
Database opened.
SQL> select count(*) from bbed;
select count(*) from bbed
                     *
ERROR at line 1:
ORA-01578: ORACLE data block corrupted (file # 54, block # 9)
ORA-01110: data file 54: 'Y:\TEST01.DBF'
Trackback

no comment untill now

Add your comment now

切换到手机版