1.rman完全恢复的前提条件:历史的datafile,controlfile和spfile备份,加上完整的archivelog和完好的redolog。
  2.rman备份脚本

  a.RMAN0级备份命令:
  run{
  allocatechannelc1typedisk;
  allocatechannelc2typedisk;
  allocatechannelc3typedisk;
  backupincrementallevel0tag'level0'format"E: ecovery_area fdb fdbAUTOBACKUP man_dirRFDB_level_0_%u_%s_%p"ascompressedbackupset
  database;
  sql"altersystemarchivelogcurrent";
  backupfilesperset3format"E: ecovery_area fdb fdbAUTOBACKUP man_dirarch_%u_%s_%p_%c"
  archivelogalldeleteinput;#备份归档可选,可以单独定期备份
  releasechannelc1;
  releasechannelc2;
  releasechannelc3;
  }
  b.RMAN1级备份命令:
  run{
  allocatechannelc1typedisk;
  allocatechannelc2typedisk;
  allocatechannelc3typedisk;
  backupincrementallevel1tag'level1'format'E: ecovery_area fdb fdbAUTOBACKUP man_dirRFDB_level_1_%u_%s_%p'ascompressedbackupset
  database;
  sql'altersystemarchivelogcurrent';
  backupfilesperset3format'E: ecovery_area fdb fdbAUTOBACKUP man_dirarch_%u_%s_%p'
  archivelogalldeleteinput;#备份归档可选,可以单独定期备份
  releasechannelc1;
  releasechannelc2;
  releasechannelc3;
  }
  c.rman删除备份命令(在保留近备份的情况下,删除其他备份):
  DELETENOPROMPTOBSOLETERECOVERYWINDOWOF1DAYS;
  d.操作系统层面运行rman备份或删除命令:
  rmantargetsys/rf4rfvbgt56yhn@rfdbnocatalogCMDFILE'D:app man man_filelevel_0.txt'log=E: ecovery_area fdb fdbAUTOBACKUP man_dirlog man_level_0.log
  3.rman恢复
  a.拷贝datafile,controlfile和spfile的rman备份,以及完整的archivelog和完好的redolog文件到新的数据库。
  b.切换至oracle用户,进入rman(先设置sid):
  exportORACLE_SID=rfdb
  rlwraprmantarget/
  c.启动一个伪实例:
  RMAN>startupnomount
  connectedtotargetdatabase(notstarted)
  startupfailed:ORA-01078:failureinprocessingsystemparameters
  LRM-00109:couldnotopenparameterfile'/u01/app/oracle/product/11.2.0/db1/dbs/initrfdb.ora'
  startingOracleinstancewithoutparameterfileforretrievalofspfile
  Oracleinstancestarted
  TotalSystemGlobalArea1068937216bytes
  FixedSize2260088bytes
  VariableSize281019272bytes
  DatabaseBuffers780140544bytes
  RedoBuffers5517312bytes
  d.在伪实例下恢复spfile文件(必须要指定rman的备份片):
  RMAN>restorespfilefrom"/u01/ora_bak/ora_bak/autobackup/2015_12_07/o1_mf_s_897845728_c6bnq1rq_.bkp";
  Startingrestoreat14-DEC-15
  usingchannelORA_DISK_1
  channelORA_DISK_1:restoringspfilefromAUTOBACKUP/u01/ora_bak/ora_bak/autobackup/2015_12_07/o1_mf_s_897845728_c6bnq1rq_.bkp
  channelORA_DISK_1:SPFILErestorefromAUTOBACKUPcomplete
  Finishedrestoreat14-DEC-15
  e.关闭伪实例,用spfile文件启动至nomount状态:
  RMAN>shutdownabort
  Oracleinstanceshutdown
  RMAN>startupnomount
  connectedtotargetdatabase(notstarted)
  Oracleinstancestarted
  TotalSystemGlobalArea1068937216bytes
  FixedSize2260088bytes
  VariableSize910164872bytes
  DatabaseBuffers150994944bytes
  RedoBuffers5517312bytes
  f.恢复控制文件(必须要指定rman的备份片,备份片应该和spfile的恢复片是同一个):
  RMAN>restorecontrolfilefrom"/u01/ora_bak/ora_bak/autobackup/2015_12_07/o1_mf_s_897845728_c6bnq1rq_.bkp";
  Startingrestoreat14-DEC-15
  allocatedchannel:ORA_DISK_1
  channelORA_DISK_1:SID=1146devicetype=DISK
  channelORA_DISK_1:restoringcontrolfile
  channelORA_DISK_1:restorecomplete,elapsedtime:00:00:01
  outputfilename=/u01/app/oracle/oradata/ATEST/controlfile/o1_mf_c5fr9b0h_.ctl
  outputfilename=/u01/app/oracle/fast_recovery_area/ATEST/controlfile/o1_mf_c5fr9b6n_.ctl
  Finishedrestoreat14-DEC-15
  g.启动数据库至mount状态:
  RMAN>alterdatabasemount;
  databasemounted
  releasedchannel:ORA_DISK_1