zoukankan      html  css  js  c++  java
  • RMAN进行基于数据块的恢复

    从ORACLE9i开始,rman支持基于数据库的恢复,这一功能有很大的好处,既不影响业务,甚至不影响有坏块的数据文件,恢复可以是在线恢复。但是恢复是完全恢复,所以要求完整的备份。

    下面测试:

    1. 对数据库进行完整备份

      Rman>backup database;

    2. 破坏数据

      参看日志《RMAN进行基于数据块的恢复》

    3. 使用rman验证数据文件

      RMAN> backup validate datafile 5;

      Starting backup at 29-AUG-14

      using target database control file instead of recovery catalog

      allocated channel: ORA_DISK_1

      channel ORA_DISK_1: sid=159 devtype=DISK

      allocated channel: ORA_DISK_2

      channel ORA_DISK_2: sid=139 devtype=DISK

      channel ORA_DISK_1: starting full datafile backupset

      channel ORA_DISK_1: specifying datafile(s) in backupset

      input datafile fno=00005 name=/opt/oracle/oradata/orcla/xzsp.dbf

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

      Finished backup at 29-AUG-14

      警告日志和数据库中都会记录损坏的数据,如下

      SQL> select * from v$database_block_corruption ;

      FILE# BLOCK# BLOCKS CORRUPTION_CHANGE# CORRUPTIO

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

      5 49316 1 0 CORRUPT

    4. 通过备份基于数据快级的恢复

      RMAN> blockrecover datafile 5 block 49316 from backupset;

      Starting blockrecover at 29-AUG-14

      using channel ORA_DISK_1

      using channel ORA_DISK_2

       

      channel ORA_DISK_1: restoring block(s)

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

      restoring blocks of datafile 00005

      channel ORA_DISK_1: reading from backup piece /opt/oracle/flash_recovery_area1/ORCLA/backupset/2014_08_29/o1_mf_nnndf_TAG20140829T032828_9zz0px68_.bkp

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

      piece handle=/opt/oracle/flash_recovery_area1/ORCLA/backupset/2014_08_29/o1_mf_nnndf_TAG20140829T032828_9zz0px68_.bkp tag=TAG20140829T032828

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

       

      starting media recovery

       

      archive log thread 1 sequence 5 is already on disk as file /opt/oracle/flash_recovery_area1/ORCLA/archivelog/2014_08_29/o1_mf_1_5_9zz2mqwo_.arc

      archive log thread 1 sequence 6 is already on disk as file /opt/oracle/flash_recovery_area1/ORCLA/archivelog/2014_08_29/o1_mf_1_6_9zz2v3jj_.arc

      archive log thread 1 sequence 7 is already on disk as file /opt/oracle/flash_recovery_area1/ORCLA/archivelog/2014_08_29/o1_mf_1_7_9zz3hfff_.arc

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

      Finished blockrecover at 29-AUG-14

    5. 清楚坏块记录

      SQL> select * from v$database_block_corruption ;

      FILE# BLOCK# BLOCKS CORRUPTION_CHANGE# CORRUPTIO

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

      5 49316 1 0 CORRUPT

      RMAN> backup validate datafile 5;

      Starting backup at 29-AUG-14

      using channel ORA_DISK_1

      using channel ORA_DISK_2

      channel ORA_DISK_1: starting full datafile backupset

      channel ORA_DISK_1: specifying datafile(s) in backupset

      input datafile fno=00005 name=/opt/oracle/oradata/orcla/xzsp.dbf

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

      Finished backup at 29-AUG-14

      SQL> select * from v$database_block_corruption ;

       

      no rows selected

       

      注意:

      但有些情况下,BLOCKRECOVER未必可以恢复得了:

      [oracle@ique datafile]$ sqlplus mayp/mayp

      SQL*Plus: Release 10.1.0.5.0 – Production on Mon Jul 14 17:08:06 2008

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

      Connected to:

      Oracle Database 10g Enterprise Edition Release 10.1.0.5.0 – Production

      With the Partitioning, OLAP and Data Mining options

      SQL> select count(*) from mssm;

      select count(*) from mssm

      *

      ERROR at line 1:

      ORA-01578: ORACLE data block corrupted (file # 5, block # 9)

      ORA-01110: data file 5: '/data/mayp/MAYP/datafile/o1_mf_mssm_4789hznr_.dbf'

      [oracle@ique datafile]$ rman target /

      Recovery Manager: Release 10.1.0.5.0 – Production

      Copyright (c) 1995, 2004, Oracle. All rights reserved.

      connected to target database: MAYP (DBID=412172232)

      RMAN> blockrecover datafile 5 block 9;

      Starting blockrecover at 14-JUL-08

      using target database controlfile instead of recovery catalog

      allocated channel: ORA_DISK_1

      channel ORA_DISK_1: sid=378 devtype=DISK

      RMAN-00571: ===========================================================

      RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============

      RMAN-00571: ===========================================================

      RMAN-03002: failure of blockrecover command at 07/14/2008 17:08:37

      ORA-01455: converting column overflows integer datatype

      RMAN-06010: error while looking up datafile: 5

      这个块损坏已经严重破坏了数据的存放规律,发生了逻辑损坏,所以blockrecover没办法恢复,必须首先restore这个文件然后通过recvoer命令进行恢复.

      通过常规方法恢复这个错误:

      RMAN> sql 'alter database datafile 5 offline';

      sql statement: alter database datafile 5 offline

      RMAN> restore datafile 5;

      Starting restore at 14-JUL-08

      using channel ORA_DISK_1

      channel ORA_DISK_1: starting datafile backupset restore

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

      restoring datafile 00005 to /data/mayp/MAYP/datafile/o1_mf_mssm_4789hznr_.dbf

      channel ORA_DISK_1: restored backup piece 1

      piece handle=/home/oracle/product/10.2/dbs/full_2_MAYP.rman tag=TAG20080714T152854

      channel ORA_DISK_1: restore complete

      Finished restore at 14-JUL-08

      RMAN> recover datafile 5;

      Starting recover at 14-JUL-08

      using channel ORA_DISK_1

      starting media recovery

      media recovery complete

      Finished recover at 14-JUL-08

      RMAN> sql 'alter database datafile 5 online';

      sql statement: alter database datafile 5 online

      RMAN> exit

      BLOCKRECOVER 的使用限制:

      1、数据库必须在ARCHIVELOG模式下才可以使用这个功能;

      2、数据库必须是mount或open状态;

      3、不能对一个offline的datafile进行BLOCKRECOVER;

      4、blcokrecover需要通过一个full backups 恢复datra block,不能使用incremental backups进行错误恢复;

      5、blockrecover不能跨越archivelog丢失或损坏,也就是说在恢复的过程中,不能丢失需要的归档日志;

      6、blockrecover不能恢复逻辑坏块,逻辑坏块必须首先restore损坏的数据文件,然后在用recover进行恢复;

      7、blockrecvoer不能恢复file header block.(block=1).

  • 相关阅读:
    初学vue,vue2.0+vue-router+vuex的小项目
    解决安卓键盘将下面元素顶上来的问题
    ng1 与 vue 状态管理比较--个人理解
    js数组内元素移动,适用于拖动排序
    vuex--mutation,action个人理解
    git--删除.DS_Store
    app的设计 有感
    transformClassesWithDexForArmv7Debug --解决办法
    :mergeArmv7DebugResources:Some file crunching failed, see logs for details解决办法
    CET-6 分频周计划生词筛选(Week 2)
  • 原文地址:https://www.cnblogs.com/markfeifei/p/3942394.html
Copyright © 2011-2022 走看看