- 首先要在开启归档的前提下
- 做全库备份
点击(此处)折叠或打开
- RMAN> backup as compressed backupset full database;
-
- Starting backup at 06-APR-17
- using channel ORA_DISK_1
- channel ORA_DISK_1: starting compressed full datafile backup set
- channel ORA_DISK_1: specifying datafile(s) in backup set
- input datafile file number=00001 name=/u01/app/oracle/oradata/PROD1/system01.dbf
- input datafile file number=00002 name=/u01/app/oracle/oradata/PROD1/sysaux01.dbf
- input datafile file number=00005 name=/u01/app/oracle/oradata/PROD1/example01.dbf
- input datafile file number=00003 name=/u01/app/oracle/oradata/PROD1/undotbs01.dbf
- input datafile file number=00007 name=/u01/app/oracle/oradata/PROD1/test02.dbf
- input datafile file number=00006 name=/u01/app/oracle/oradata/PROD1/test01.dbf
- input datafile file number=00004 name=/u01/app/oracle/oradata/PROD1/users01.dbf
- channel ORA_DISK_1: starting piece 1 at 06-APR-17
- channel ORA_DISK_1: finished piece 1 at 06-APR-17
- piece handle=/u01/app/oracle/product/11.2.0/dbhome_1/dbs/02s10ale_1_1 tag=TAG20170406T091318 comment=NONE
- channel ORA_DISK_1: backup set complete, elapsed time: 00:00:45
- 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 06-APR-17
- channel ORA_DISK_1: finished piece 1 at 06-APR-17
- piece handle=/u01/app/oracle/product/11.2.0/dbhome_1/dbs/03s10amr_1_1 tag=TAG20170406T091318 comment=NONE
- channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
- Finished backup at 06-APR-17
- RMAN> backup as compressed backupset full database;
- 创建表t1 ,并将表t1 删除
点击(此处)折叠或打开
- SQL> create table t1(x int);
-
- Table created.
-
-
- SQL> insert into t1 select rownum from dual connect by rownum<=10;
-
- 10 rows created.
-
- SQL> commit;
-
- Commit complete.
-
- SQL> select to_char(sysdate,'yyyy-mm-dd hh24:mi:ss') from dual;
-
- TO_CHAR(SYSDATE,'YY
- -------------------
- 2017-04-06 09:16:22
-
- SQL> drop table t1;
-
- Table dropped.
-
- SQL> select to_char(sysdate,'yyyy-mm-dd hh24:mi:ss') from dual;
-
- TO_CHAR(SYSDATE,'YY
- -------------------
- 2017-04-06 09:17:01
-
- SQL> shutdown immediate;
- Database closed.
- Database dismounted.
- ORACLE instance shut down.
- SQL> create table t1(x int);
- 在mount状态下 利用rman 做基于时间的恢复
点击(此处)折叠或打开
- RMAN> startup mount;
-
- Oracle instance started
- database mounted
-
- Total System Global Area 217157632 bytes
-
- Fixed Size 2251816 bytes
- Variable Size 159384536 bytes
- Database Buffers 50331648 bytes
- Redo Buffers 5189632 bytes
-
- RMAN> run{
- 2> sql 'alter session set nls_date_format="yyyy-mm-dd hh24:mi:ss"';
- 3> set until time='2017-04-06 09:16:22';
- 4> restore database;
- 5> recover database;
- 6> alter database open resetlogs;
- 7> }
-
- sql statement: alter session set nls_date_format="yyyy-mm-dd hh24:mi:ss"
-
- executing command: SET until clause
-
- Starting restore at 06-APR-17
- allocated channel: ORA_DISK_1
- channel ORA_DISK_1: SID=18 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/PROD1/system01.dbf
- channel ORA_DISK_1: restoring datafile 00002 to /u01/app/oracle/oradata/PROD1/sysaux01.dbf
- channel ORA_DISK_1: restoring datafile 00003 to /u01/app/oracle/oradata/PROD1/undotbs01.dbf
- channel ORA_DISK_1: restoring datafile 00004 to /u01/app/oracle/oradata/PROD1/users01.dbf
- channel ORA_DISK_1: restoring datafile 00005 to /u01/app/oracle/oradata/PROD1/example01.dbf
- channel ORA_DISK_1: restoring datafile 00006 to /u01/app/oracle/oradata/PROD1/test01.dbf
- channel ORA_DISK_1: restoring datafile 00007 to /u01/app/oracle/oradata/PROD1/test02.dbf
- channel ORA_DISK_1: reading from backup piece /u01/app/oracle/product/11.2.0/dbhome_1/dbs/02s10ale_1_1
- channel ORA_DISK_1: piece handle=/u01/app/oracle/product/11.2.0/dbhome_1/dbs/02s10ale_1_1 tag=TAG20170406T091318
- channel ORA_DISK_1: restored backup piece 1
- channel ORA_DISK_1: restore complete, elapsed time: 00:00:55
- Finished restore at 06-APR-17
-
- Starting recover at 06-APR-17
- using channel ORA_DISK_1
-
- starting media recovery
- media recovery complete, elapsed time: 00:00:00
-
- Finished recover at 06-APR-17
-
- database opened
- RMAN> startup mount;
- 验证
点击(此处)折叠或打开
- SQL> select * from t1;
-
- X
- ----------
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
-
- 10 rows selected.
- SQL> select * from t1;
- 此时如果再想恢复到别的时间,会报错
点击(此处)折叠或打开
- RMAN> run{
- 2> sql 'alter session set nls_date_format="yyyy-mm-dd hh24:mi:ss"';
- 3> set until time='2017-04-06 09:16:21';
- 4> restore database;
- 5> recover database;
- 6> alter database open resetlogs;
- 7> }
-
- sql statement: alter session set nls_date_format="yyyy-mm-dd hh24:mi:ss"
-
- executing command: SET until clause
-
- Starting restore at 06-APR-17
- RMAN-00571: ===========================================================
- RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
- RMAN-00571: ===========================================================
- RMAN-03002: failure of restore command at 04/06/2017 09:41:55
- RMAN-20207: UNTIL TIME or RECOVERY WINDOW is before RESETLOGS time
点击(此处)折叠或打开
- RMAN> run{
- 2> sql 'alter session set nls_date_format="yyyy-mm-dd hh24:mi:ss"';
- 3> set until time='2017-04-06 09:16:22';
- 4> restore database;
- 5> recover database;
- 6> alter database open resetlogs;
- 7> }
-
- 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 06-APR-17
- RMAN-00571: ===========================================================
- RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
- RMAN-00571: ===========================================================
- RMAN-03002: failure of restore command at 04/06/2017 09:30:29
- RMAN-20207: UNTIL TIME or RECOVERY WINDOW is before RESETLOGS time
- RMAN> run{
-
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/31405405/viewspace-2136688/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/31405405/viewspace-2136688/