rman中的自动恢复详解

rman中有一套自动检测,建议和恢复机制对数据库进行恢复
下面我们就通过丢失系统表空间的文件来看看怎么实现
首先,模拟丢失文件
[oracle@localhost orcl]$ rm system01.dbf
[oracle@localhost orcl]$ pwd
/u01/app/oracle/oradata/orcl
重启之后报错
SQL> startup force
ORACLE instance started.

Total System Global Area  780824576 bytes
Fixed Size            2217424 bytes
Variable Size          545262128 bytes
Database Buffers      230686720 bytes
Redo Buffers            2658304 bytes
Database mounted.
ORA-01157: cannot identify/lock data file 1 - see DBWR trace file
ORA-01110: data file 1: '/u01/app/oracle/oradata/orcl/system01.dbf
= =是不是完全不知道system01.dbf文件怎么啦?
不用怕,直接进入rman中查看错误
RMAN> list failure;

using target database control file instead of recovery catalog
List of Database Failures
=========================

Failure ID Priority Status    Time Detected Summary
---------- -------- --------- ------------- -------
102        CRITICAL OPEN      06-DEC-16     System datafile 1: '/u01/app/oracle/oradata/orcl/system01.dbf' is missing
5          CRITICAL OPEN      30-AUG-16     System datafile 1: '/u01/app/oracle/oradata/orcl/system01.dbf' needs media recovery
瞧!明确给出了错误原因,system01.dbf文件丢失,且该文件需要介质恢复
之后我们可以看rman给出的建议
RMAN>  advise failure;

List of Database Failures
=========================

Failure ID Priority Status    Time Detected Summary
---------- -------- --------- ------------- -------
102        CRITICAL OPEN      06-DEC-16     System datafile 1: '/u01/app/oracle/oradata/orcl/system01.dbf' is missing
5          CRITICAL OPEN      30-AUG-16     System datafile 1: '/u01/app/oracle/oradata/orcl/system01.dbf' needs media recovery

analyzing automatic repair options; this may take some time
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=20 device type=DISK
analyzing automatic repair options complete

Mandatory Manual Actions
========================
no manual actions available

Optional Manual Actions
=======================
1. If file /u01/app/oracle/oradata/orcl/system01.dbf was unintentionally renamed or moved, restore it
2. If you restored the wrong version of data file /u01/app/oracle/oradata/orcl/system01.dbf, then replace it with the correct one

Automated Repair Options
========================
Option Repair Description
------ ------------------
1      Restore and recover datafile 1 
  Strategy: The repair includes complete media recovery with no data loss
  Repair script: /u01/app/oracle/diag/rdbms/orcl/orcl/hm/reco_2728352127.hm

rman明确告诉我们解决方法
Optional Manual Actions     手工方式
Automated Repair Options     自动方式
自动方式中有一个Repair script(修复脚本),我们打开看看
[oracle@localhost orcl]$ cat /u01/app/oracle/diag/rdbms/orcl/orcl/hm/reco_2728352127.hm
   # restore and recover datafile
   restore datafile 1;
   recover datafile 1;
里面正是自动修复所需要的语句。
但是我们有更方便的方式,执行repair failure,它会自动帮我们执行脚本里的语句。
RMAN>  repair failure;

Strategy: The repair includes complete media recovery with no data loss
Repair script: /u01/app/oracle/diag/rdbms/orcl/orcl/hm/reco_2728352127.hm

contents of repair script:
   # restore and recover datafile
   restore datafile 1;
   recover datafile 1;

Do you really want to execute the above repair (enter YES or NO)? y
executing repair script
...............
repair failure complete

Do you want to open the database (enter YES or NO)?yes
database opened

SQL> select status from v$instance;

STATUS
------------
OPEN

RMAN> list failure all;

no failures found that match specification

ps:这几个命令是不是很好用啊!不过在一些场景这几个命令是没用的。比如日志文件的丢失或损坏,是检测不出的。
      那么那时我们就只能乖乖地按原来的方式进行恢复啦!

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

转载于:http://blog.itpub.net/31386161/viewspace-2129876/

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

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值