ITPub博客

首页 > Linux操作系统 > Linux操作系统 > RMSN 块介质恢复(BMR)--BLOCKRECOVER

RMSN 块介质恢复(BMR)--BLOCKRECOVER

原创 Linux操作系统 作者:keeptrying 时间:2012-05-10 12:59:09 0 删除 编辑

RMANBLOCKRECOVER命令可以对corrupted块进行Block Media Recovery(BMR)块介质恢复。

 

BMR的优点:

1、  BMR将介质恢复的最小可恢复单位从数据文件缩小到块。如果已知数据库中只有少量的块需要介质恢复,只需恢复相应的块即可。

2、  只需将正在恢复的块变成不可用,正在恢复的数据文件继续保持online状态。提高了数据在介质恢复期间的可用性。

3、  由于只需恢复少量的块,从而降低了平均恢复时间(MTTR: mean time to recover)。

 

 

注意You must have a full backup of the file containing the corrupt blocks:

block media recovery cannot use incremental backups.

Level 0,或者在无Level 0 可用的备份下做的Level 1 的增量备份都是一个完整的包含了损坏的块的备份,所以应该也是可以用来执行Block Media Recovery .只是说当使用过Level 0,或者在无Level 0 可用的备份下做的Level 1 的增量备份后不会使用更高Level的增量备份进行恢复,而只会采用应用Archived log files 的方式进行恢复.

 

 

当用户遇到块损坏时,错误消息、预警日志和跟踪文件会指示引发问题的块。DBA随后可以调用BLOCKRECOVER命令,仅还原有问题的块。BLOCKRECOVER命令将执行以下任务:

1、  确定包含要进行恢复的块的备份。

2、  读取备份,并将请求的块累积到内存缓冲区。如果所需的任何块收到损坏(介质损坏或逻辑损坏),RMAN就会读取此文件下一个最旧的备份,以寻找该块的有效副本。

UNTIL选项将可选择的内容限制在指定时间、SCN或日志序列之上或之前执行的备份集或文件副本,从而强制BLOCKRECOVER使用较旧的备份,而不使用最新的备份。

3、  启动并管理块介质恢复会话,以便根据需要从备份中读取归档日志。

4、  始终执行完全恢复。使用BLOCKRECOVER命令时,不能执行时间点恢复。

 

 

示例:

 

1、  构建实验环境

1)、创建表空间test1

SYS@ tsid > create tablespace test1 datafile 'E:\oradata\test\test1.dbf' size 10M;

 

Tablespace created.

2)、在表空间test1上创建表t

SYS@ tsid > alter user test1 default tablespace test1;--修改test1用户默认表空间。

 

User altered.

 

 

TEST1@ tsid > create table t as select * from dba_objects;

 

Table created.

 

TEST1@ tsid > insert into t select * from t;

 

11449 rows created.

 

TEST1@ tsid > insert into t select * from t;

 

22898 rows created.

 

TEST1@ tsid > insert into t select * from t;

insert into t select * from t

*

ERROR at line 1:

ORA-01653: unable to extend table TEST1.T by 128 in tablespace TEST1

 

TEST1@ tsid > commit;

 

Commit complete.

 

这样做的目的是使test1表空间数据文件只包含t表。便于下面的操作。

 

3)、备份数据文件test1.dbf

RMAN> backup datafile 8;

 

Starting backup at 2012-05-10 12:14:03

allocated channel: ORA_DISK_1

channel ORA_DISK_1: sid=143 devtype=DISK

channel ORA_DISK_1: starting full datafile backupset

channel ORA_DISK_1: specifying datafile(s) in backupset

input datafile fno=00008 name=E:\ORADATA\TEST\TEST1.DBF

channel ORA_DISK_1: starting piece 1 at 2012-05-10 12:14:04

channel ORA_DISK_1: finished piece 1 at 2012-05-10 12:14:05

piece handle=E:\ORACLE\PRODUCT\10.2.0\FLASH_RECOVERY_AREA\TEST\BACKUPSET\2012_05_10\O1_MF_NNNDF_TAG20120510T121404_7TPJ4DX6_.

BKP tag=TAG20120510T121404 comment=NONE

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

Finished backup at 2012-05-10 12:14:05

 

 

2、  使用工具Uedit32.exe修改test表空间数据文件test1.dbf

shutdown数据库,这里,用工具修改数据文件4处,注意不能修改数据文件前8个块。

 

 

3、  检查corrupted

打开数据库,检查折断的块。只要不修改数据文件头,数据库可以正常打开。

1)、直接查询表t,可以检查corrupted块。

TEST1@ tsid > select count(*) from t;

select count(*) from t

                     *

ERROR at line 1:

ORA-01578: ORACLE data block corrupted (file # 8, block # 167)

ORA-01110: data file 8: 'E:\ORADATA\TEST\TEST1.DBF'

 

 

2)、使用ANALYZE命令。

TEST1@ tsid > analyze table t validate structure;

analyze table t validate structure

*

ERROR at line 1:

ORA-01578: ORACLE data block corrupted (file # 8, block # 167)

ORA-01110: data file 8: 'E:\ORADATA\TEST\TEST1.DBF'

 

 

3)、使用DBVERIFY

C:\>dbv file=E:\oradata\test\test1.dbf

 

DBVERIFY: Release 10.2.0.3.0 - Production on Thu May 10 12:25:35 2012

 

Copyright (c) 1982, 2005, Oracle.  All rights reserved.

 

DBVERIFY - Verification starting : FILE = E:\oradata\test\test1.dbf

Page 167 is marked corrupt

Corrupt block relative dba: 0x020000a7 (file 8, block 167)

Bad check value found during dbv:

Data in bad block:

 type: 6 format: 2 rdba: 0x020000a7

 last change scn: 0x0000.00436f4a seq: 0x1 flg: 0x06

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

 consistency value in tail: 0x6f4a0601

 check value in block header: 0x1860

 computed block checksum: 0x1a3b

 

Page 398 is marked corrupt

Corrupt block relative dba: 0x0200018e (file 8, block 398)

Bad check value found during dbv:

Data in bad block:

 type: 6 format: 2 rdba: 0x0200018e

 last change scn: 0x0000.00436f4a seq: 0x1 flg: 0x06

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

 consistency value in tail: 0x6f4a0601

 check value in block header: 0xe5fd

 computed block checksum: 0x9161

 

Page 609 is marked corrupt

Corrupt block relative dba: 0x02000261 (file 8, block 609)

Bad check value found during dbv:

Data in bad block:

 type: 6 format: 2 rdba: 0x02000261

 last change scn: 0x0000.00436e22 seq: 0x1 flg: 0x04

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

 consistency value in tail: 0x6e220601

 check value in block header: 0x8067

 computed block checksum: 0xbb2f

 

Page 988 is marked corrupt

Corrupt block relative dba: 0x020003dc (file 8, block 988)

Bad check value found during dbv:

Data in bad block:

 type: 6 format: 2 rdba: 0x020003dc

 last change scn: 0x0000.00436ea8 seq: 0x2 flg: 0x04

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

 consistency value in tail: 0x6ea80602

 check value in block header: 0x7994

 computed block checksum: 0xa06d

 

 

 

DBVERIFY - Verification complete

 

Total Pages Examined         : 1280

Total Pages Processed (Data) : 1122

Total Pages Failing   (Data) : 0

Total Pages Processed (Index): 0

Total Pages Failing   (Index): 0

Total Pages Processed (Other): 34

Total Pages Processed (Seg)  : 0

Total Pages Failing   (Seg)  : 0

Total Pages Empty            : 120

Total Pages Marked Corrupt   : 4

Total Pages Influx           : 0

Highest block SCN            : 4422381 (0.4422381)

 

这里检查到4个块折断。

 

关于DBVERIFY utility的使用http://space.itpub.net/25744374/viewspace-722938

 

 

4)、使用RMAN  backup validate datafile 8

RMAN> backup validate datafile 8;

 

Starting backup at 2012-05-10 12:45:25

using target database control file instead of recovery catalog

allocated channel: ORA_DISK_1

channel ORA_DISK_1: sid=158 devtype=DISK

channel ORA_DISK_1: starting full datafile backupset

channel ORA_DISK_1: specifying datafile(s) in backupset

input datafile fno=00008 name=E:\ORADATA\TEST\TEST1.DBF

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

Finished backup at 2012-05-10 12:45:29

 

执行后,可以同过视图v$database_block_corruption查询到折断的块。

SYS@ tsid > select * from v$database_block_corruption;

 

     FILE#     BLOCK#     BLOCKS CORRUPTION_CHANGE# CORRUPTIO

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

         8        398          1                  0 CHECKSUM

         8        988          1                  0 CHECKSUM

         8        167          1                  0 CHECKSUM

             8        609          1                  0 CHECKSUM

 

 

4、  使用RAMN  BLOCKRECOVER命令进行块介质恢复

 

RMAN> blockrecover datafile 8 block 167;

 

RMAN> blockrecover datafile 8 block 398;

 

RMAN> blockrecover datafile 8 block 609;

 

RMAN> blockrecover datafile 8 block 988;

 

5、  验证恢复结果

RMAN> backup validate datafile 8;

 

Starting backup at 2012-05-10 12:56:03

using channel ORA_DISK_1

channel ORA_DISK_1: starting full datafile backupset

channel ORA_DISK_1: specifying datafile(s) in backupset

input datafile fno=00008 name=E:\ORADATA\TEST\TEST1.DBF

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

Finished backup at 2012-05-10 12:56:04

 

SYS@ tsid > select * from v$database_block_corruption;

 

no rows selected

 

 

TEST1@ tsid > select count(*) from t;

 

  COUNT(*)

----------

     45796

 

块介质恢复成功。

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

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

注册时间:2011-04-25

  • 博文量
    130
  • 访问量
    941072