說明:歸檔模式,rman工具的熱備(開機備份);
1. 準備環境: RMAN 全庫備份[[email protected] ~]$ rman target /
Recovery Manager: Release 11.2.0.4.0 - Production on Sun Oct 2 12:39:43 2016
Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved.
connected to target database: ORA11GR2 (DBID=237843809)
RMAN>
backup as compressed backupset full database;Starting backup at 02-OCT-16
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=58 device type=DISK
channel ORA_DISK_1:
starting compressed full datafile backup setchannel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00001 name=/u01/app/oracle/oradata/ORA11GR2/system01.dbf
input datafile file number=00002 name=/u01/app/oracle/oradata/ORA11GR2/sysaux01.dbf
input datafile file number=00005 name=/u01/app/oracle/oradata/ORA11GR2/example01.dbf
input datafile file number=00003 name=/u01/app/oracle/oradata/ORA11GR2/undotbs01.dbf
input datafile file number=00006 name=/u01/app/oracle/oradata/ORA11GR2/ts_xxf_01.dbf
input datafile file number=00004 name=/u01/app/oracle/oradata/ORA11GR2/users01.dbf
channel ORA_DISK_1: starting piece 1 at 02-OCT-16
channel ORA_DISK_1: finished piece 1 at 02-OCT-16
piece handle=/u01/app/FRA/ORA11GR2/backupset/2016_10_02/o1_mf_nnndf_TAG20161002T124047_cz13yhsh_.bkp tag=TAG20161002T124047 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:55
channel ORA_DISK_1: starting compressed 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 02-OCT-16
channel ORA_DISK_1: finished piece 1 at 02-OCT-16
piece handle=/u01/app/FRA/ORA11GR2/backupset/2016_10_02/o1_mf_ncsnf_TAG20161002T124047_cz1409w7_.bkp tag=TAG20161002T124047 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
Finished backup at 02-OCT-16
2. 準備環境:測試表及資料[email protected]>
create table t1 as select to_char(sysdate,'yyyy-mm-dd hh24:mi:ss') as dd from dual;Table created.
[email protected]>
select * from t1;DD
-------------------
2016-10-02 12:45:10
[email protected]>
select sysdate from dual;SYSDATE
-------------------
2016-10-02 12:47:43[email protected]>
create table t2 as select to_char(sysdate,'yyyy-mm-dd hh24:mi:ss') as dd from dual;Table created.
[email protected]>
select * from t2;DD
-------------------
2016-10-02 12:49:24
——模拟兩分鐘後左右删除 t1 表 [email protected]>set time on;12:51:13 [email protected]>drop table t1 purge;
Table dropped.
——正常關庫:12:51:47 [email protected]>conn / as sysdba
Connected.
[email protected]>
shutdown immediate;Database closed.
Database dismounted.
ORACLE instance shut down.
——删除作業系統中的所有資料檔案[email protected]>
!ls /u01/app/oracle/oradata/ORA11GR2/control01.ctl redo01.log sysaux01.dbf ts_xxf_01.dbf
control02.ctl redo02.log system01.dbf undotbs01.dbf
example01.dbf redo03.log temp01.dbf users01.dbf
[email protected]>
!rm /u01/app/oracle/oradata/ORA11GR2/*.dbf[email protected]>!ls /u01/app/oracle/oradata/ORA11GR2/*.dbf
ls: /u01/app/oracle/oradata/ORA11GR2/*.dbf: No such file or directory
3. 啟動到 mount 模式,進行基于時間的恢複(利用 RMAN 恢複)[email protected]>conn / as sysdba
Connected to an idle instance.
[email protected]>startup mount;
ORACLE instance started.
Total System Global Area 830930944 bytes
Fixed Size 2257800 bytes
Variable Size 503319672 bytes
Database Buffers 322961408 bytes
Redo Buffers 2392064 bytes
Database mounted.
[[email protected] ~]$ rman target /Recovery Manager: Release 11.2.0.4.0 - Production on Sun Oct 2 12:58:43 2016
Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved.
connected to target database: ORA11GR2 (DBID=237843809, not open)
RMAN>
run
{
sql 'alter session set nls_date_format="yyyy-mm-dd hh24:mi:ss"';
set until time = '2016-10-02 12:47:43';
restore database;
recover database;
alter database open resetlogs;
}
using target database control file instead of recovery catalog
sql statement: alter session set nls_date_format="yyyy-mm-dd hh24:mi:ss"
executing command: SET until clause
Starting restore at 02-OCT-16
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=20 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 00001 to /u01/app/oracle/oradata/ORA11GR2/system01.dbf
channel ORA_DISK_1: restoring datafile 00002 to /u01/app/oracle/oradata/ORA11GR2/sysaux01.dbf
channel ORA_DISK_1: restoring datafile 00003 to /u01/app/oracle/oradata/ORA11GR2/undotbs01.dbf
channel ORA_DISK_1: restoring datafile 00004 to /u01/app/oracle/oradata/ORA11GR2/users01.dbf
channel ORA_DISK_1: restoring datafile 00005 to /u01/app/oracle/oradata/ORA11GR2/example01.dbf
channel ORA_DISK_1: restoring datafile 00006 to /u01/app/oracle/oradata/ORA11GR2/ts_xxf_01.dbf
channel ORA_DISK_1: reading from backup piece /u01/app/FRA/ORA11GR2/backupset/2016_10_02/o1_mf_nnndf_TAG20161002T124047_cz13yhsh_.bkp
channel ORA_DISK_1: piece handle=/u01/app/FRA/ORA11GR2/backupset/2016_10_02/o1_mf_nnndf_TAG20161002T124047_cz13yhsh_.bkp tag=TAG20161002T124047
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:01:25
Finished restore at 02-OCT-16
Starting recover at 02-OCT-16
using channel ORA_DISK_1
starting media recovery
media recovery complete, elapsed time: 00:00:01
Finished recover at 02-OCT-16
database opened
4. 驗證結果[email protected]>conn scott/tiger
Connected.
[email protected]>select tname from tab where tname like 'T_';
TNAME
------------------------------
T1
(因為 2016-10-02 12:47:43 之前隻建立了 t1 表, t2 表還沒有建)[email protected]>
測試完成!!!!!
alert:
alert.txt
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/31397003/viewspace-2126538/,如需轉載,請注明出處,否則将追究法律責任。
轉載于:http://blog.itpub.net/31397003/viewspace-2126538/