无RMAN备份集情况下的坏块恢复(5)


SQL> select * from corrupt_test;
select * from corrupt_test
              *
ERROR at line 1:
ORA-01578: ORACLE data block corrupted (file # 6, block # 12)
ORA-01110: data file 6: '/u01/app/oracle/oradata/ora10g/zlm01.dbf'


但是一旦我们把它刷到磁盘,就报ORA-01578的错误了,提示6号文件的第12个块损坏了,就是之前指定的那个数据块


SQL> exit
Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options
[oracle@ora10g backupsets]$ rman target /


Recovery Manager: Release 10.2.0.1.0 - Production on 16 16:30:19 2014


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


connected to target database: ORA10G (DBID=4175411955)


RMAN> blockrecover datafile 6 block 12;


Starting blockrecover at 2014-11-26
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=159 devtype=DISK


RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of blockrecover command at 11/26/2014 16:30:51
RMAN-06026: some targets not found - aborting restore
RMAN-06023: no backup or copy of datafile 6 found to restore


此时直接用blockrecover来恢复坏块是不行的,首先我们没有可用的备份集,其次,控制文件中也不知道从哪里去找可用的备份文件,那么我们就要先把之前做过的热备文件catalog到控制文件中


RMAN> catalog datafilecopy '/u01/zlm01_bak.dbf';


cataloged datafile copy
datafile copy filename=/u01/zlm01_bak.dbf recid=17 stamp=864664486


RMAN> blockrecover datafile 6 block 12;


Starting blockrecover at 2014-11-26
using channel ORA_DISK_1


channel ORA_DISK_1: restoring block(s) from datafile copy /u01/zlm01_bak.dbf


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


Finished blockrecover at 2014-11-26


RMAN> exit

Recovery Manager complete.


再做一次blockrecover,现在就顺利地介质恢复完了


[oracle@ora10g backupsets]$ sqlplus zlm/zlm


SQL*Plus: Release 10.2.0.1.0 - Production on 16 16:35:23 2014


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


Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options


SQL> select * from corrupt_test;


        ID NAME
---------- ---------------
        1 aaron8219


SQL>

可以看到,之前丢失的数据,又回来了

总结:

虽然在没有RMAN备份集的情况下,通过热备文件可以把丢失的数据恢复出来,但这毕竟还是很不靠谱的。在生产环境中,我们几乎不可能经常去对某个数据文件做热备,也不会知道什么时候,哪个文件就会出现坏块。所以,平时做好RMAN全备还是非常非常重要的,只要有备份集和归档,我们的数据就不会丢失。当执行blockrecover datafile xxx block xxx时,Oracle会直接去RMAN备份集中恢复,不需要额外的catalog步骤,也不用我们过多地人为干预。

--------------------------------------推荐阅读 --------------------------------------

RMAN 配置归档日志删除策略

Oracle基础教程之通过RMAN复制数据库

RMAN备份策略制定参考内容

RMAN备份学习笔记

Oracle数据库备份加密 RMAN加密

--------------------------------------分割线 --------------------------------------

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/6d29b0b5cd7132448789a378b02e4a73.html