Restore和Recovery的区别
Restoration: A corrupted data file is overwritten from a backup of the data file .The data file is at a prior point of time than the current database.
Recovery: Recovery applies the changes to the individual blocks,using archive and redo information,to move the database forward to the current point in time.
从原理上解释,Restore是使用备份文件,将数据库还原到过去的某个状态。
Recovery是使用redo日志和归档日志将数据库向前恢复,一步步的恢复到现在这个时点。
举个例子
某生产环境的数据库,每天凌晨一点会作一次备份。某天下午两点时数据库文件损害,同时数据库宕机。
接着DBA开始恢复数据库。1.首先,使用最近一次的备份文件还原数据库到当天凌晨一点的状态。但是凌晨一点到下午两点的数据丢失了。
2.接着,使用redo日志和归档日志,把当天凌晨一点开始的数据库操作重做一遍,直到下午两点数据库宕机前。
这样数据库就一点都不差的被恢复起来了。
操作步骤
12345678910111213141516171819202122232425262728293031323334353637 #设置表空间为offlineRMAN> SQL 'alter tablespace tab01 offline immediate';sql statement: alter tablespace tab01 offline immediate#Restore还原物理文件RMAN> restore tablespace tab01;Starting restore at 30-DEC-16using channel ORA_DISK_1skipping datafile 5; already restored to file /home/oracle/app/oracle/oradata/mmpdb3/tab01.dbfrestore not done; all files read only, offline, or already restoredFinished restore at 30-DEC-16#Recover恢复数据RMAN> recover tablespace tab01;Starting recover at 30-DEC-16using channel ORA_DISK_1channel ORA_DISK_1: starting incremental datafile backup set restorechannel ORA_DISK_1: specifying datafile(s) to restore from backup setdestination for restore of datafile 00005: /home/oracle/app/oracle/oradata/mmpdb3/tab01.dbfchannel ORA_DISK_1: reading from backup piece /home/oracle/dbbak/rman/mmpdb3_level_1_database_MMPDB3_20161229_328channel ORA_DISK_1: piece handle=/home/oracle/dbbak/rman/mmpdb3_level_1_database_MMPDB3_20161229_328 tag=TAG20161229T230036channel ORA_DISK_1: restored backup piece 1channel ORA_DISK_1: restore complete, elapsed time: 00:00:07starting media recoverymedia recovery complete, elapsed time: 00:00:00Finished recover at 30-DEC-16#设置表空间为onlineRMAN> SQL 'alter tablespace tab01 online';sql statement: alter tablespace tab01 online