Oracle RMAN 坏块恢复

查到表t_blockrec数据所在的文件号和数据块

[oracle@zhongwc ~]$ sqlplus / as sysdba

SQL*Plus: Release 11.2.0.3.0 Production on Tue Feb 26 16:40:20 2013

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


Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
With the Partitioning, Automatic Storage Management, OLAP, Data Mining
and Real Application Testing options

SQL> col  name for a50
SQL> select file#,name from v$datafile;

     FILE# NAME
---------- --------------------------------------------------
	 1 +DATADG/zhongwc/datafile/system.256.808400009
	 2 +DATADG/zhongwc/datafile/sysaux.257.808400009
	 3 +DATADG/zhongwc/datafile/undotbs1.258.808400011
	 4 +DATADG/zhongwc/datafile/users.259.808400011
	 5 +DATADG/zhongwc/datafile/example.265.808400179

SQL> create user test identified by test default tablespace users;

User created.

SQL> grant resource,connect to test;

Grant succeeded.

SQL> conn test
Enter password: 
Connected.
SQL> create table t_blockrec(tid integer primary key,tname varchar2(10));

Table created.

SQL> insert into t_blockrec values(1,'aaa');

1 row created.

SQL> insert into t_blockrec values(2,'bbb');

1 row created.

SQL> insert into t_blockrec values(3,'ccc');

1 row created.

SQL> commit;

Commit complete.

SQL> select rowid,dbms_rowid.rowid_relative_fno(rowid) file#,dbms_rowid.rowid_block_number(rowid) block# from t_blockrec;

ROWID			FILE#	  BLOCK#
------------------ ---------- ----------
AAASwgAAEAAAAIPAAA	    4	     527
AAASwgAAEAAAAIPAAB	    4	     527
AAASwgAAEAAAAIPAAC	    4	     527

备份4号文件,标记坏块527

[oracle@zhongwc ~]$ rman target /

Recovery Manager: Release 11.2.0.3.0 - Production on Tue Feb 26 16:55:57 2013

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

connected to target database: ZHONGWC (DBID=183284171)

RMAN> backup datafile 4;

Starting backup at 26-FEB-2013 16:56:06
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=40 device type=DISK
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00004 name=+DATADG/zhongwc/datafile/users.259.808400011
channel ORA_DISK_1: starting piece 1 at 26-FEB-2013 16:56:07
channel ORA_DISK_1: finished piece 1 at 26-FEB-2013 16:56:08
piece handle=+FRADG/zhongwc/backupset/2013_02_26/nnndf0_tag20130226t165607_0.262.808419367 tag=TAG20130226T165607 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
Finished backup at 26-FEB-2013 16:56:08

RMAN> 

RMAN> 

RMAN> list backup;


List of Backup Sets
===================


BS Key  Type LV Size       Device Type Elapsed Time Completion Time     
------- ---- -- ---------- ----------- ------------ --------------------
1       Full    3.39M      DISK        00:00:00     26-FEB-2013 16:56:07
        BP Key: 1   Status: AVAILABLE  Compressed: NO  Tag: TAG20130226T165607
        Piece Name: +FRADG/zhongwc/backupset/2013_02_26/nnndf0_tag20130226t165607_0.262.808419367
  List of Datafiles in backup set 1
  File LV Type Ckp SCN    Ckp Time             Name
  ---- -- ---- ---------- -------------------- ----
  4       Full 1082713    26-FEB-2013 16:56:07 +DATADG/zhongwc/datafile/users.259.808400011

RMAN> 

RMAN> 

RMAN> blockrecover datafile 4 block 527 clear;

Starting recover at 26-FEB-2013 17:03:56
using channel ORA_DISK_1
Finished recover at 26-FEB-2013 17:03:56

使用dbv验证,看到4号文件的527块损坏

ASMCMD [+datadg/zhongwc/datafile] > cp USERS.259.808400011 /home/grid
copying +datadg/zhongwc/datafile/USERS.259.808400011 -> /home/grid/USERS.259.808400011
ASMCMD [+datadg/zhongwc/datafile] > exit
[grid@zhongwc ~]$ dbv file=/home/grid/USERS.259.808400011 

DBVERIFY: Release 11.2.0.3.0 - Production on Tue Feb 26 17:09:53 2013

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

DBVERIFY - Verification starting : FILE = /home/grid/USERS.259.808400011
Page 527 is marked corrupt
Corrupt block relative dba: 0x0100020f (file 4, block 527)
Bad header found during dbv: 
Data in bad block:
 type: 6 format: 2 rdba: 0xf660d0a0
 last change scn: 0x6842.35f385f3 seq: 0x88 flg: 0x8e
 spare1: 0x2e spare2: 0x47 spare3: 0xf
 consistency value in tail: 0x843c0601
 check value in block header: 0xb277
 computed block checksum: 0x5a26



DBVERIFY - Verification complete

Total Pages Examined         : 640
Total Pages Processed (Data) : 95
Total Pages Failing   (Data) : 0
Total Pages Processed (Index): 40
Total Pages Failing   (Index): 0
Total Pages Processed (Other): 486
Total Pages Processed (Seg)  : 0
Total Pages Failing   (Seg)  : 0
Total Pages Empty            : 18
Total Pages Marked Corrupt   : 1
Total Pages Influx           : 0
Total Pages Encrypted        : 0
Highest block SCN            : 1082428 (0.1082428)

查询t_blockrec表,报错data file 4: '+DATADG/zhongwc/datafile/users.259.808400011'

[oracle@zhongwc ~]$ sqlplus test

SQL*Plus: Release 11.2.0.3.0 Production on Tue Feb 26 17:11:25 2013

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

Enter password: 

Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
With the Partitioning, Automatic Storage Management, OLAP, Data Mining
and Real Application Testing options

SQL> select tname from tab;

TNAME
------------------------------
T_BLOCKREC

SQL> select count(*) from t_blockrec;
select count(*) from t_blockrec
                     *
ERROR at line 1:
ORA-01578: ORACLE data block corrupted (file # 4, block # 527)
ORA-01110: data file 4: '+DATADG/zhongwc/datafile/users.259.808400011'

使用RMAN恢复

[oracle@zhongwc ~]$ rman target /

Recovery Manager: Release 11.2.0.3.0 - Production on Tue Feb 26 17:11:54 2013

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

connected to target database: ZHONGWC (DBID=183284171)

RMAN> blockrecover datafile 4 block 527;

Starting recover at 26-FEB-2013 17:12:10
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=41 device type=DISK

channel ORA_DISK_1: restoring block(s)
channel ORA_DISK_1: specifying block(s) to restore from backup set
restoring blocks of datafile 00004
channel ORA_DISK_1: reading from backup piece +FRADG/zhongwc/backupset/2013_02_26/nnndf0_tag20130226t165607_0.262.808419367
channel ORA_DISK_1: piece handle=+FRADG/zhongwc/backupset/2013_02_26/nnndf0_tag20130226t165607_0.262.808419367 tag=TAG20130226T165607
channel ORA_DISK_1: restored block(s) from backup piece 1
channel ORA_DISK_1: block restore complete, elapsed time: 00:00:01

starting media recovery
media recovery complete, elapsed time: 00:00:04

Finished recover at 26-FEB-2013 17:12:17

RMAN> exit


Recovery Manager complete.
[oracle@zhongwc ~]$ sqlplus test

SQL*Plus: Release 11.2.0.3.0 Production on Tue Feb 26 17:12:21 2013

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

Enter password: 

Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
With the Partitioning, Automatic Storage Management, OLAP, Data Mining
and Real Application Testing options

SQL> select tname from tab;

TNAME
------------------------------
T_BLOCKREC

SQL> select count(*) from t_blockrec;

  COUNT(*)
----------
	 3

SQL> select * from t_blockrec;

       TID TNAME
---------- ----------
	 1 aaa
	 2 bbb
	 3 ccc






  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值