您好,登錄后才能下訂單哦!
1. 我們先做一個全備
RMAN> backup database ; Starting backup at 2015/07/09 13:40:47 allocated channel: ORA_DISK_1 channel ORA_DISK_1: SID=28 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=00001 name=/u01/app/oracle/oradata/devdb/system01.dbf input datafile file number=00002 name=/u01/app/oracle/oradata/devdb/sysaux01.dbf input datafile file number=00005 name=/u01/app/oracle/oradata/devdb/example01.dbf input datafile file number=00003 name=/u01/app/oracle/oradata/devdb/undotbs01.dbf input datafile file number=00004 name=/u01/app/oracle/oradata/devdb/users01.dbf channel ORA_DISK_1: starting piece 1 at 2015/07/09 13:40:48 channel ORA_DISK_1: finished piece 1 at 2015/07/09 13:42:34 piece handle=/u01/app/oracle/fast_recovery_area/DEVDB/backupset/2015_07_09/o1_mf_nnndf_TAG20150709T134048_bsw2c0xq_.bkp tag=TAG20150709T134048 comment=NONE channel ORA_DISK_1: backup set complete, elapsed time: 00:01:46 channel ORA_DISK_1: starting full datafile backup set channel ORA_DISK_1: specifying datafile(s) in backup set including current control file in backup set including current SPFILE in backup set channel ORA_DISK_1: starting piece 1 at 2015/07/09 13:42:35 channel ORA_DISK_1: finished piece 1 at 2015/07/09 13:42:36 piece handle=/u01/app/oracle/fast_recovery_area/DEVDB/backupset/2015_07_09/o1_mf_ncsnf_TAG20150709T134048_bsw2gcly_.bkp tag=TAG20150709T134048 comment=NONE channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01 Finished backup at 2015/07/09 13:42:36
2. 創建一個表,往里面插入一些數據。記錄下時間,等待一會再將表truncate。
SQL> alter user scott account unlock; User altered. SQL> alter user scott identified by tiger; User altered. SQL> conn scott/tiger Connected. SQL> select sysdate from dual; SYSDATE ------------------- 2015/07/09 13:44:30 SQL> create table t1 as select * from emp; Table created. SQL> select sysdate from dual; SYSDATE ------------------- 2015/07/09 13:45:32 SQL> truncate table t1; Table truncated.
在2015/07/09 13:45:32以前,表t1中有14條數據。之后做了truncate。我們現在來看看能不能將數據庫恢復到2015/07/09 13:45:32這一時刻。也就是t1被truncate掉之前。
3. 關閉數據庫,再啟動到mount狀態
SQL> conn / as sysdba Connected. SQL> shutdown immediate Database closed. Database dismounted. ORACLE instance shut down. SQL> startup mount; ORACLE instance started. Total System Global Area 839282688 bytes Fixed Size 2233000 bytes Variable Size 494931288 bytes Database Buffers 339738624 bytes Redo Buffers 2379776 bytes Database mounted.
4. 恢復數據庫
RMAN> RUN { ALLOCATE CHANNEL c1 TYPE DISK; ALLOCATE CHANNEL c2 TYPE DISK; SET UNTIL TIME = '2015/07/09 13:45:32'; RESTORE DATABASE; RECOVER DATABASE; ALTER DATABASE OPEN RESETLOGS; }2> 3> 4> 5> 6> 7> 8> using target database control file instead of recovery catalog allocated channel: c1 channel c1: SID=20 device type=DISK allocated channel: c2 channel c2: SID=21 device type=DISK executing command: SET until clause Starting restore at 2015/07/09 13:50:59 channel c1: starting datafile backup set restore channel c1: specifying datafile(s) to restore from backup set channel c1: restoring datafile 00001 to /u01/app/oracle/oradata/devdb/system01.dbf channel c1: restoring datafile 00002 to /u01/app/oracle/oradata/devdb/sysaux01.dbf channel c1: restoring datafile 00003 to /u01/app/oracle/oradata/devdb/undotbs01.dbf channel c1: restoring datafile 00004 to /u01/app/oracle/oradata/devdb/users01.dbf channel c1: restoring datafile 00005 to /u01/app/oracle/oradata/devdb/example01.dbf channel c1: reading from backup piece /u01/app/oracle/fast_recovery_area/DEVDB/backupset/2015_07_09/o1_mf_nnndf_TAG20150709T134048_bsw2c0xq_.bkp channel c1: piece handle=/u01/app/oracle/fast_recovery_area/DEVDB/backupset/2015_07_09/o1_mf_nnndf_TAG20150709T134048_bsw2c0xq_.bkp tag=TAG20150709T134048 channel c1: restored backup piece 1 channel c1: restore complete, elapsed time: 00:01:15 Finished restore at 2015/07/09 13:52:14 Starting recover at 2015/07/09 13:52:15 starting media recovery media recovery complete, elapsed time: 00:00:01 Finished recover at 2015/07/09 13:52:16 database opened released channel: c1 released channel: c2
5. 驗證數據是否存在。
SQL> conn scott/tiger Connected. SQL> select count(*) from t1; COUNT(*) ---------- 14 SQL>
可見數據已經找回。
基于時間點的恢復,是不完全恢復的一種,我們還可以基于SCN和日志sequence恢復。
UNTIL SEQUENCE or UNTIL SCN
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。