RMAN> backup datafile 5;
Starting backup at 06-NOV-14
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=43 device type=DISK
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00005 name=/data/oracle/oradata/aaron/example01.dbf
channel ORA_DISK_1: starting piece 1 at 06-NOV-14
channel ORA_DISK_1: finished piece 1 at 06-NOV-14
piece handle=/data/oracle/flash_recovery_area/AARON/backupset/2014_11_06/o1_mf_nnndf_TAG20141106T001531_b5pck41v_.bkp tag=TAG20141106T001531 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:16
Finished backup at 06-NOV-14
Starting Control File and SPFILE Autobackup at 06-NOV-14
piece handle=/data/oracle/flash_recovery_area/AARON/autobackup/2014_11_06/o1_mf_s_862877747_b5pcknj2_.bkp comment=NONE
Finished Control File and SPFILE Autobackup at 06-NOV-14
2 删除测试数据文件
SYS@aaron> !rm /data/oracle/oradata/aaron/example01.dbf
3 重新启动数据库查看错误信息
SYS@aaron> shutdown abort
ORACLE instance shut down.
SYS@aaron> startup
ORACLE instance started.
Total System Global Area 422670336 bytes
Fixed Size 1336960 bytes
Variable Size 314575232 bytes
Database Buffers 100663296 bytes
Redo Buffers 6094848 bytes
Database mounted.
ORA-01157: cannot identify/lock data file 5 - see DBWR trace file
ORA-01110: data file 5: '/data/oracle/oradata/aaron/example01.dbf'
4 重新连接RMAN 并执行 List Failure
RMAN> list failure;
using target database control file instead of recovery catalog
List of Database Failures
=========================
Failure ID Priority Status Time Detected Summary
---------- -------- --------- ------------- -------
522 HIGH OPEN 06-NOV-14 One or more non-system datafiles are missing
5 查看建议脚本
RMAN> advise failure;
List of Database Failures
=========================
Failure ID Priority Status Time Detected Summary
---------- -------- --------- ------------- -------
522 HIGH OPEN 06-NOV-14 One or more non-system datafiles are missing
analyzing automatic repair options; this may take some time
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=17 device type=DISK
analyzing automatic repair options complete
Mandatory Manual Actions
========================
no manual actions available
Optional Manual Actions
=======================
1. If file /data/oracle/oradata/aaron/example01.dbf was unintentionally renamed or moved, restore it
Automated Repair Options
========================
Option Repair Description
------ ------------------
1 Restore and recover datafile 5
Strategy: The repair includes complete media recovery with no data loss
Repair script: /data/oracle/diag/rdbms/aaron/aaron/hm/reco_780979516.hm
[oracle@localhost alert]$ more /data/oracle/diag/rdbms/aaron/aaron/hm/reco_780979516.hm
# restore and recover datafile
restore datafile 5;
recover datafile 5;
6 执行恢复操作
RMAN> restore datafile 5;
Starting restore at 06-NOV-14
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=18 device type=DISK
channel ORA_DISK_1: starting datafile backup set restore
channel ORA_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_DISK_1: restoring datafile 00005 to /data/oracle/oradata/aaron/example01.dbf
channel ORA_DISK_1: reading from backup piece /data/oracle/flash_recovery_area/AARON/backupset/2014_11_06/o1_mf_nnndf_TAG20141106T001531_b5pck41v_.bkp
channel ORA_DISK_1: piece handle=/data/oracle/flash_recovery_area/AARON/backupset/2014_11_06/o1_mf_nnndf_TAG20141106T001531_b5pck41v_.bkp tag=TAG20141106T001531
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:00:07
Finished restore at 06-NOV-14