ITPub博客

首页 > 数据库 > Oracle > 使用BBED修改块

使用BBED修改块

原创 Oracle 作者:linetsam 时间:2010-08-14 09:58:00 0 删除 编辑
通过BBED修改块,并同RMAN实现块级恢复[@more@]

1、bbed创建坏块

1) 准备测试表空间

Create tablespace ts2 datafile '$ORACLE_BASE/ts2.dbf' size 5m;

Alter user hr quota unlimited ts2;

Conn hr/hr

Create table t1 (id int, name varchar2(20));

Insert into t1 values(1, '390');

2)定位表记录的存储位置

Select file_id,extent_id,block_id,blocks from dba_extents where segment_name='T1' and owner='HR';

FILE_ID EXTENT_ID BLOCK_ID BLOCKS

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

7 0 9 8

select dbms_rowid.rowid_block_number(rowid) from hr.t2;

DBMS_ROWID.ROWID_BLOCK_NUMBER(ROWID)

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

12

Select dump('390',16) from dual;

DUMP('390',16)

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

Typ=96 Len=3: 33,39,30

3)准备bbed

Cat > filelist.txt

1 /u01/app/oracle/ts2.dbf 5120000

Cat > par.bbed

Blocksize=8192

listfile=filelist.txt

Mode=edit

4)通过bbed修改表记录

$ bbed parfile=par.bbed

选定当前要操作的块:

BBED> set file 1 block 12 count 8300;

FILE# 1

BLOCK# 12

COUNT 8300

BBED> dump

File: /u01/app/oracle/ts2.dbf (1)

Block: 12 Offsets: 0 to 8191 Dba:0x0040000c

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

06a20000 0c00c001 7a6b0800 00000206 625b0000 01000000 54cd0000 96690800

找到要修改的记录的offset

BBED> find /x 33 curr

File: /u01/app/oracle/ts2.dbf (1)

Block: 12 Offsets: 8185 to 8191 Dba:0x0040000c

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

33393002 067a6b

<32 bytes per line>

将390改成380,也就是将9(39)改成8(38)。

Bbed> modify /x 38 offset 8186;

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

File: /u01/app/oracle/ts2.dbf (1)

Block: 12 Offsets: 8186 to 8191 Dba:0x0040000c

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

38300206 7a6b

BBED> verify;

DBVERIFY - Verification starting

FILE = /u01/app/oracle/ts2.dbf

BLOCK = 12

Block 12 is corrupt

Corrupt block relative dba: 0x01c0000c (file 0, block 12)

Bad check value found during verification

Data in bad block:

type: 6 format: 2 rdba: 0x01c0000c

last change scn: 0x0000.00086b7a seq: 0x2 flg: 0x06

spare1: 0x0 spare2: 0x0 spare3: 0x0

consistency value in tail: 0x6b7a0602

check value in block header: 0x5b62

computed block checksum: 0x1

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> sum apply;

Check value for File 1, Block 12:

current = 0x5b63, required = 0x5b63

BBED> verify;

DBVERIFY - Verification starting

FILE = /u01/app/oracle/ts2.dbf

BLOCK = 12

DBVERIFY - Verification complete

Total Blocks Examined : 1

Total Blocks Processed (Data) : 1

Total Blocks Failing (Data) : 0

Total Blocks Processed (Index): 0

Total Blocks Failing (Index): 0

Total Blocks Empty : 0

Total Blocks Marked Corrupt : 0

Total Blocks Influx : 0

数据已改,坏块消除。

注:bbed修改,主要针对数字类型。

2、通过RMAN恢复

1) rman检查坏块

只是检查,不产生备份文件。

Rman> backup validate datafile 7;

Starting backup at 2010-08-14 09:25:29

using target database control file instead of recovery catalog

allocated channel: ORA_DISK_1

channel ORA_DISK_1: sid=130 devtype=DISK

channel ORA_DISK_1: starting full datafile backupset

channel ORA_DISK_1: specifying datafile(s) in backupset

input datafile fno=00007 name=/u01/app/oracle/ts2.dbf

channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01

Finished backup at 2010-08-14 09:25:32

通过视图查询记录的坏块:

Select * from v$database_block_corruption;

FILE# BLOCK# BLOCKS CORRUPTION_CHANGE# CORRUPTION_TYPE

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

7 12 1 0 CHECKSUM

select * from v$backup_corruption;

FILE# BLOCK# BLOCKS CORRUPTION_CHANGE# MARKED CORRUPTION_TYPE

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

7 12 1 0 YES CHECKSUM

2) 恢复坏块

Rman> blockrecover datafile 7 block 12 from backupset;

Starting blockrecover at 2010-08-14 09:31:29

using channel ORA_DISK_1

channel ORA_DISK_1: restoring block(s)

channel ORA_DISK_1: specifying block(s) to restore from backup set

restoring blocks of datafile 00007

channel ORA_DISK_1: reading from backup piece /u01/app/oracle/flash_recovery_area/ORCL/backupset/2010_08_14/o1_mf_nnndf_TAG20100814T090608_66cv012b_.bkp

channel ORA_DISK_1: restored block(s) from backup piece 1

piece handle=/u01/app/oracle/flash_recovery_area/ORCL/backupset/2010_08_14/o1_mf_nnndf_TAG20100814T090608_66cv012b_.bkp tag=TAG20100814T090608

channel ORA_DISK_1: block restore complete, elapsed time: 00:00:01

starting media recovery

media recovery complete, elapsed time: 00:00:03

Finished blockrecover at 2010-08-14 09:31:35

注:可以表空间在线恢复。

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

请登录后发表评论 登录
全部评论

注册时间:2008-09-16

  • 博文量
    20
  • 访问量
    43136