恢復向导恢复数据文件
一、恢复一般数据文件(users等)
1.模拟删除users01.dbf数据文件:
[oracle@testA /]$ rm /home/oracle/app/oracle/oradata/orcl/users01.dbf
再次查询表的时候会报错:
SQL> select * from dept;
ERROR at line 1:ORA-01116: error in opening database file 4ORA-01110: data file 4: '/home/oracle/app/oracle/oradata/orcl/users01.dbf'ORA-27041: unable to open fileLinux-x86_64 Error: 2: No such file or directoryAdditional information: 3提示datafile 4 有问题,也就是刚删除users01.dbf文件;
2.连进rman:rman target /
3.查看问题列表:
RMAN> list failure;
using target database control file instead of recovery catalogList of Database Failures=========================Failure ID Priority Status Time Detected Summary---------- -------- --------- ------------- -------62 HIGH OPEN 11-MAY-18 One or more non-system datafiles are missing
4.查看恢复建议:
RMAN> advise failure;
List of Database Failures=========================Failure ID Priority Status Time Detected Summary---------- -------- --------- ------------- -------62 HIGH OPEN 11-MAY-18 One or more non-system datafiles are missinganalyzing automatic repair options; this may take some timeallocated channel: ORA_DISK_1channel ORA_DISK_1: SID=101 device type=DISKanalyzing automatic repair options completeMandatory Manual Actions========================no manual actions availableOptional Manual Actions=======================1. If file /home/oracle/app/oracle/oradata/orcl/users01.dbf was unintentionally renamed or moved, restore itAutomated Repair Options========================Option Repair Description------ ------------------1 Restore and recover datafile 4Strategy: The repair includes complete media recovery with no data lossRepair script: /home/oracle/app/oracle/diag/rdbms/orcl/orcl/hm/reco_1978000856.hm+可以看到有找到修复脚本(红色字体)
5.修复
RMAN> repair failure;
Strategy: The repair includes complete media recovery with no data lossRepair script: /home/oracle/app/oracle/diag/rdbms/orcl/orcl/hm/reco_1978000856.hmcontents of repair script:# restore and recover datafilesql 'alter database datafile 4 offline';restore datafile 4;recover datafile 4;sql 'alter database datafile 4 online';Do you really want to execute the above repair (enter YES or NO)? yesexecuting repair scriptsql statement: alter database datafile 4 offlineStarting restore at 11-MAY-18using channel ORA_DISK_1channel ORA_DISK_1: starting datafile backup set restorechannel ORA_DISK_1: specifying datafile(s) to restore from backup setchannel ORA_DISK_1: restoring datafile 00004 to /home/oracle/app/oracle/oradata/orcl/users01.dbfchannel ORA_DISK_1: reading from backup piece /home/oracle/app/oracle/fast_recovery_area/ORCL/backupset/2018_05_11/o1_mf_nnndf_TAG20180511T102914_fh9zzv00_.bkpchannel ORA_DISK_1: piece handle=/home/oracle/app/oracle/fast_recovery_area/ORCL/backupset/2018_05_11/o1_mf_nnndf_TAG20180511T102914_fh9zzv00_.bkp tag=TAG20180511T102914channel ORA_DISK_1: restored backup piece 1channel ORA_DISK_1: restore complete, elapsed time: 00:00:01Finished restore at 11-MAY-18Starting recover at 11-MAY-18using channel ORA_DISK_1starting media recoverymedia recovery complete, elapsed time: 00:00:00Finished recover at 11-MAY-18sql statement: alter database datafile 4 onlinerepair failure complete
至此,数据文件已恢复成功,可以正常访问db(红色部分为恢复时执行的脚本);
二、恢复系统数据文件(system、undo)
恢复系统数据文件时需要在mount状态下执行,其他操作同上。
PS:此种修复向导的方法只能针对恢复数据文件,对controlfil或spfile等无效;