Data Recovery Advisor(数据恢复顾问)

Data Recovery Advisor 是11g新特性,是Oracle顾问程序架构的一部分,它会在遇到错误时自动收集有关故障信息。如果主动运行Data Recovery Advisor,通常可以在用户查询或备份操作检查到故障前检测和修复故障。Data Recovery Advisor可以检测到诸如块受损的相对较小的错误,也可以检测到导致数据库无法成功启动的错误,如缺少联机重做日志文件,数据文件等。Data Recovery Advisor会主动捕获这些错误。

 

Data Recovery Advisor确定故障后,可以使用EM或RMAN界面查看故障详情,在Rman中可以使用list backup,advise failure,repair failure和

change failure命令,下面说下这些命令的作用:

 

list failure:列出Data Recovery Advisor记录的故障;

advise failure:显示建议修复的选项;

repair failure:使用rman的建议和关闭故障;

change failure:更改状态或关闭故障。

 

一、list failure命令包含多个选项,具体使用的选项取决于需要查看的错误类型:

(1)  failnum:列出每个故障的详细信息,按故障编号列出,如list failure 42。

(2)  ALL:列出所有故障,如list failure all。

(3)  CRITICAL:列出导致数据库不可用的故障。

(4)  HIGH:列出导致数据库不可用的严重故障,如缺少数据文件或redo文件

(5)  LOW:列出可以在解决较严重故障问题后再予以解决的间歇性故障或优先级较低的故障,如很少使用到的坏块。

(6)  CLOSED:仅列出关闭的故障。

(7)  EXCLUDE FAILURE:从列表中排除指定的故障号。

(8)  DETAIL:通过展开合并的故障列出故障。例如,如果一个文件中有多个块损坏,则DETAIL选项将列出每个块损坏。

注:其中CRITICAL,HIGH,LOW指故障的优先级。

 

如:

RMAN> LIST FAILURE;

RMAN> LIST FAILURE DETAIL;

RMAN> LIST FAILURE 42;

RMAN>LIST FAILURE ALL;

 

二、advise failure

1)  显示输入故障列表概要

(2)  包括警告(如果ADR 中出现新故障)

(3)  显示手动核对清单

(4)  列出一个建议的修复选项

(5)  生成修复脚本(用于自动或手动修复)

 

如:

RMAN>ADVISE FAILURE

 

三、repair failure

repair failure默认会使用本次会话中advise failure所产生的脚本

repair failure preview:不执行修复,而是显示先前生成的包含所有修复操作和注释的RMAN 脚本。

repair failure noprompt:不要求确认,repare failure 默认需要确认

 

四、change failure

CHANGE FAILURE 命令用于更改故障优先级或关闭一个或多个故障。

 

语法:

CHANGE FAILURE

{ ALL | CRITICAL | HIGH | LOW |failnum[,failnum,…] }

[ EXCLUDE FAILURE failnum[,failnum,…] ]

{ PRIORITY {CRITICAL | HIGH | LOW} |

CLOSE } - 将故障的状态更改为已关闭

[ NOPROMPT ] - 不要求用户进行确认

 

可以使用change  failure改变故障优先级,但只能从high更改为low或low改为high,不能更改citical的优先级。

例如:

RMAN>change failure 307 priority  low;

 

 

五、与DRA相关的视图:

(1)  V$IR_FAILURE:所有故障的列表,包括已关闭的故障(LIST FAILURE 命令的结果)

(2)  V$IR_MANUAL_CHECKLIST:手动建议的列表(ADVISE FAILURE命令的结果)

(3)  V$IR_REPAIR:修复列表(ADVISE FAILURE 命令的结果)

(4)  V$IR_FAILURE_SET:故障和建议标识符的交叉引用

 

 

 六、下面模拟一个数据故障,然后用RMAN修复该故障:

 1.创建表空间test;

SQL> create tablespace tbs_test01 datafile '+DATA/c1/datafile/tbs_test01.dbf' size 50M;

Tablespace created.

 2.创建用户

SQL> create user test identified by xyc default tablespace tbs_test01;

User created.

3.创建表并插入数据提交

SQL> conn test/xyc
Connected.
SQL> create table test01(
  2  id int,
  3  name varchar2(32));

Table created.

SQL> insert into test01 values(1,'xyc');

1 row created.

SQL> commit;

4.脱机表空间tbs_test01中数据文件

SQL> alter database datafile 5 offline;

Database altered.

5. 再次插入数据报错

SQL>  insert into test01   select * from test01;
 insert into test01   select * from test01
             *
ERROR at line 1:
ORA-00376: file 5 cannot be read at this time
ORA-01110: data file 5: '+DATA/c1/datafile/tbs_test01.dbf'

6.list failure

RMAN> list failure;

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

Failure ID Priority Status    Time Detected Summary
---------- -------- --------- ------------- -------
42         HIGH     OPEN      10-SEP-13     One or more non-system datafiles need media recovery

7.advise failure

RMAN> advise failure;

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

Failure ID Priority Status    Time Detected Summary
---------- -------- --------- ------------- -------
42         HIGH     OPEN      10-SEP-13     One or more non-system datafiles need media recovery

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

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

Optional Manual Actions
=======================
1. If you restored the wrong version of data file +DATA/c1/datafile/tbs_test01.dbf, then replace it with the correct one

Automated Repair Options
========================
Option Repair Description
------ ------------------
1      Recover datafile 5 
  Strategy: The repair includes complete media recovery with no data loss
  Repair script: /u01/app/oracle/diag/rdbms/c1/c1/hm/reco_1783687286.hm

8.repair failure

RMAN> repair failure
2> ;

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

contents of repair script:
   # recover datafile
   sql 'alter database datafile 5 offline';
   recover datafile 5;
   sql 'alter database datafile 5 online';

Do you really want to execute the above repair (enter YES or NO)? yes
executing repair script

sql statement: alter database datafile 5 offline

Starting recover at 10-SEP-13
using channel ORA_DISK_1

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

Finished recover at 10-SEP-13

sql statement: alter database datafile 5 online
repair failure complete

9.再次插入数据

SQL>  insert into test01   select * from test01;

1 row created.

 

 

你可能感兴趣的:(数据恢复)