根据丢失数据文件场景模拟使用advise
    前提:数据文件之前有相关备份
    参考视图

    1. select * from v$ir_failure;----------查看failure提示信息
    2. select * from v$ir_failure_set; ----------------查看advise_idfailure_id
    3. select * from v$ir_manual_checklist;-------------查看advise消息提示
    4. select * from v$ir_repair;---------------查看恢复脚本

    1.删除数据文件

    1. [oracle@instance-ej1hspdt fd]$ rm -rf /opt/oracle/oradata/ORCLCDB/users01.dbf

    2.查看数据库advise错误提示。

    1. RMAN> list failure all;
    2. Database Role: PRIMARY
    3. List of Database Failures
    4. =========================
    5. Failure ID Priority Status Time Detected Summary
    6. ---------- -------- --------- ------------- -------
    7. 6502 HIGH OPEN 11-SEP-19 One or more non-system datafiles are missing

    3.生成恢复脚本

    1. RMAN> advise failure;
    2. Database Role: PRIMARY
    3. List of Database Failures
    4. =========================
    5. Failure ID Priority Status Time Detected Summary
    6. ---------- -------- --------- ------------- -------
    7. 6502 HIGH OPEN 11-SEP-19 One or more non-system datafiles are missing
    8. analyzing automatic repair options; this may take some time
    9. allocated channel: ORA_DISK_1
    10. channel ORA_DISK_1: SID=237 device type=DISK
    11. analyzing automatic repair options complete
    12. Mandatory Manual Actions
    13. ========================
    14. no manual actions available
    15. Optional Manual Actions
    16. =======================
    17. 1. If file /opt/oracle/oradata/ORCLCDB/users01.dbf was unintentionally renamed or moved, restore it
    18. Automated Repair Options
    19. ========================
    20. Option Repair Description
    21. ------ ------------------
    22. 1 Restore and recover datafile 7
    23. Strategy: The repair includes complete media recovery with no data loss
    24. Repair script: /opt/oracle/diag/rdbms/orclcdb/ORCLCDB/hm/reco_122451071.hm

    4.查看恢复脚本,也可以使用系统命令cat 查看

    1. RMAN> repair failure preview;
    2. Strategy: The repair includes complete media recovery with no data loss
    3. Repair script: /opt/oracle/diag/rdbms/orclcdb/ORCLCDB/hm/reco_122451071.hm
    4. contents of repair script:
    5. # restore and recover datafile
    6. sql 'alter database datafile 7 offline';
    7. restore ( datafile 7 );
    8. recover datafile 7;
    9. sql 'alter database datafile 7 online';

    5.执行repair failure恢复,或者手动执行相关命令

    1. RMAN> repair failure;
    2. Strategy: The repair includes complete media recovery with no data loss
    3. Repair script: /opt/oracle/diag/rdbms/orclcdb/ORCLCDB/hm/reco_122451071.hm
    4. contents of repair script:
    5. # restore and recover datafile
    6. sql 'alter database datafile 7 offline';
    7. restore ( datafile 7 );
    8. recover datafile 7;
    9. sql 'alter database datafile 7 online';
    10. Do you really want to execute the above repair (enter YES or NO)? yes
    11. executing repair script
    12. sql statement: alter database datafile 7 offline
    13. ..............................
    14. ..............................
    15. starting media recovery
    16. archived log for thread 1 with sequence 45 is already on disk as file /opt/oracle/fast_recovery_area/ORCLCDB/archivelog/2019_09_1
    17. 0/o1_mf_1_45_gqgo6kjt_.arc
    18. archived log for thread 1 with sequence 46 is already on disk as file /opt/oracle/fast_recovery_area/ORCLCDB/archivelog/2019_09_1
    19. 0/o1_mf_1_46_gqhc42r5_.arc
    20. archived log for thread 1 with sequence 47 is already on disk as file /opt/oracle/fast_recovery_area/ORCLCDB/archivelog/2019_09_1
    21. 1/o1_mf_1_47_gqhlcy50_.arc
    22. archived log for thread 1 with sequence 48 is already on disk as file /opt/oracle/fast_recovery_area/ORCLCDB/archivelog/2019_09_1
    23. 1/o1_mf_1_48_gqhq2ps9_.arc
    24. archived log file name=/opt/oracle/fast_recovery_area/ORCLCDB/archivelog/2019_09_10/o1_mf_1_45_gqgo6kjt_.arc thread=1 sequence=45
    25. archived log file name=/opt/oracle/fast_recovery_area/ORCLCDB/archivelog/2019_09_10/o1_mf_1_46_gqhc42r5_.arc thread=1 sequence=46
    26. media recovery complete, elapsed time: 00:00:06
    27. Finished recover at 11-SEP-19
    28. sql statement: alter database datafile 7 online
    29. repair failure complete