Oracle BBED模拟坏块&验证坏块

来源:互联网 发布:linux命令 cp r 编辑:程序博客网 时间:2024/04/30 23:55

BBED模拟表数据块损坏

1.创建测试表 
SQL> create table xccheese(id number(10),name varchar2(10));   
Table created.

SQL>  insert into xccheese values(111111,'aaaaa');   
1 row created.

SQL>  insert into xccheese values(222222,'bbbbb'); 
1 row created.

SQL>  commit; 
Commit complete.

SQL> select * from xccheese;
ID NAME
---------- ----------
    111111 aaaaa
    222222 bbbbb


2. 通过 rowid查看行数据的文件号(rel_fno)、块号(blockno,)和行号(rowno) 

SQL> select rowid, 
                   dbms_rowid.rowid_relative_fno(rowid) rel_fno,        
                     dbms_rowid.rowid_block_number(rowid) blockno,  
                    dbms_rowid.rowid_row_number(rowid) rowno 
   from xccheese;   

ROWID      REL_FNO BLOCKNO      ROWNO
------------------ ---------- ---------- ----------
AAATiLAABAAATTZAAA    1   79065  0
AAATiLAABAAATTZAAB    1   79065  1

3. 生成 BBED需要的数据文件列表 

SQL> select file#||' '||name||' '||bytes from v$datafile ; 

FILE#||''||NAME||''||BYTES
--------------------------------------------------------------------------------
1 /oradata/node1/system01.dbf 2537553920
2 /oradata/node1/sysaux01.dbf 629145600
3 /oradata/node1/undotbs01.dbf 519045120
4 /oradata/node1/users01.dbf 5242880

 
[oracle@node1 lib]$ cat filelist.txt 
1 /oradata/node1/system01.dbf 2537553920
2 /oradata/node1/sysaux01.dbf 629145600
3 /oradata/node1/undotbs01.dbf 519045120
4 /oradata/node1/users01.dbf 5242880
 
[oracle@node1 lib]$ cat bbed.par 
blocksize=8192
listfile=/u01/bbed/filelist.txt
mode=edit

blocksize: 数据库查询的块大小(show parameter db_block_size)
listfile:列表文件
mode: 设置bbed是编辑模式还是浏览模式(edit or browse) 浏览模式不能进行块的修改(以防止浏览时误操作)。也可以在BBED命令行执行  set mode edit。


4. 登陆 BBED 
[oracle@node1 lib]$ ./bbed parfile=/u01/bbed/bbed.par 
Password: blockedit
BBED: Release 2.0.0.0.0 - Limited Production on Wed Nov 4 23:10:44 2015
Copyright (c) 1982, 2011, Oracle and/or its affiliates.  All rights reserved.
************* !!! For Oracle Internal Use only !!! ***************从这句话也能看出bbed是内部使用的工具 
BBED>                                                                       

--密码默认是 blockedit,为了安全bbed设置有密码,可见bbed操作是十分危险的,生产库不到万不得已最好不要使用。 

5.修改数据块

BBED>  modify 1000 file 1 block 79065
Warning: contents of previous BIFILE will be lost. Proceed? (Y/N) y
 File: /oradata/node1/system01.dbf (1)
 Block: 79065            Offsets:    0 to  511           Dba:0x004134d9
------------------------------------------------------------------------
 03e80000 d9344100 97950c00 00000106 b36e0000 01000000 8b380100 91950c00 
 00000000 02000300 00000000 08001c00 c2020000 fd00c000 66004200 02200000 
 97950c00 00000000 00000000 00000000 00000000 00000000 00000000 00010200 
 ffff1600 841f6e1f 6e1f0000 0200921f 841f0000 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>
 
6.提交使修改生效
BBED> sum apply      --使应用生效 
Check value for File 1, Block 79065:
current = 0x24b6, required = 0x24b6

7.验证坏块
BBED> verify      --验证  发现这个块损坏了 
DBVERIFY - Verification starting
FILE = /oradata/node1/system01.dbf
BLOCK = 79065

Block 79065 is corrupt
Corrupt block relative dba: 0x004134d9 (file 0, block 79065)
Bad header found during verification
Data in bad block:
 type: 3 format: 0 rdba: 0x004134d9
 last change scn: 0x0000.000c9597 seq: 0x1 flg: 0x06
 spare1: 0x0 spare2: 0x0 spare3: 0x0
 consistency value in tail: 0x95970601
 check value in block header: 0x24b6
 computed block checksum: 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
Message 531 not found;  product=RDBMS; facility=BBED


8. 使用DBV工具验证

[oracle@node1 backup]$ dbv file=/oradata/node1/system01.dbf blocksize=8192

DBVERIFY: Release 11.2.0.4.0 - Production on Mon Nov 23 02:46:27 2015

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

DBVERIFY - Verification starting : FILE = /oradata/node1/system01.dbf
Page 79065 is marked corrupt
Corrupt block relative dba: 0x004134d9 (file 1, block 79065)
Bad header found during dbv: 
Data in bad block:
 type: 3 format: 0 rdba: 0x004134d9
 last change scn: 0x0000.000c9597 seq: 0x1 flg: 0x06
 spare1: 0x0 spare2: 0x0 spare3: 0x0
 consistency value in tail: 0x95970601
 check value in block header: 0x24b6
 computed block checksum: 0x0


DBVERIFY - Verification complete
Total Pages Examined         : 309760
Total Pages Processed (Data) : 274065
Total Pages Failing   (Data) : 0
Total Pages Processed (Index): 10360
Total Pages Failing   (Index): 0
Total Pages Processed (Other): 3292
Total Pages Processed (Seg)  : 1
Total Pages Failing   (Seg)  : 0
Total Pages Empty            : 22042
Total Pages Marked Corrupt   : 1
Total Pages Influx           : 0
Total Pages Encrypted        : 0
Highest block SCN            : 899559 (0.899559)


9. 执行块读取操作

SQL> select * from xccheese;
select * from xccheese
              *
ERROR at line 1:
ORA-01578: ORACLE data block corrupted (file # 1, block # 79065)
ORA-01110: data file 1: '/oradata/node1/system01.dbf'

 
0 0