基于时间的不完全恢复

  1. 首先要在开启归档的前提下
  2. 做全库备份

    点击(此处)折叠或打开

    1. RMAN> backup as compressed backupset full database;

    2. Starting backup at 06-APR-17
    3. using channel ORA_DISK_1
    4. channel ORA_DISK_1: starting compressed full datafile backup set
    5. channel ORA_DISK_1: specifying datafile(s) in backup set
    6. input datafile file number=00001 name=/u01/app/oracle/oradata/PROD1/system01.dbf
    7. input datafile file number=00002 name=/u01/app/oracle/oradata/PROD1/sysaux01.dbf
    8. input datafile file number=00005 name=/u01/app/oracle/oradata/PROD1/example01.dbf
    9. input datafile file number=00003 name=/u01/app/oracle/oradata/PROD1/undotbs01.dbf
    10. input datafile file number=00007 name=/u01/app/oracle/oradata/PROD1/test02.dbf
    11. input datafile file number=00006 name=/u01/app/oracle/oradata/PROD1/test01.dbf
    12. input datafile file number=00004 name=/u01/app/oracle/oradata/PROD1/users01.dbf
    13. channel ORA_DISK_1: starting piece 1 at 06-APR-17
    14. channel ORA_DISK_1: finished piece 1 at 06-APR-17
    15. piece handle=/u01/app/oracle/product/11.2.0/dbhome_1/dbs/02s10ale_1_1 tag=TAG20170406T091318 comment=NONE
    16. channel ORA_DISK_1: backup set complete, elapsed time: 00:00:45
    17. channel ORA_DISK_1: starting compressed full datafile backup set
    18. channel ORA_DISK_1: specifying datafile(s) in backup set
    19. including current control file in backup set
    20. including current SPFILE in backup set
    21. channel ORA_DISK_1: starting piece 1 at 06-APR-17
    22. channel ORA_DISK_1: finished piece 1 at 06-APR-17
    23. piece handle=/u01/app/oracle/product/11.2.0/dbhome_1/dbs/03s10amr_1_1 tag=TAG20170406T091318 comment=NONE
    24. channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
    25. Finished backup at 06-APR-17

  3. 创建表t1 ,并将表t1 删除

    点击(此处)折叠或打开

    1. SQL> create table t1(x int);

    2. Table created.


    3. SQL> insert into t1 select rownum from dual connect by rownum<=10;

    4. 10 rows created.

    5. SQL> commit;

    6. Commit complete.

    7. SQL> select to_char(sysdate,'yyyy-mm-dd hh24:mi:ss') from dual;

    8. TO_CHAR(SYSDATE,'YY
    9. -------------------
    10. 2017-04-06 09:16:22

    11. SQL> drop table t1;

    12. Table dropped.

    13. SQL> select to_char(sysdate,'yyyy-mm-dd hh24:mi:ss') from dual;

    14. TO_CHAR(SYSDATE,'YY
    15. -------------------
    16. 2017-04-06 09:17:01

    17. SQL> shutdown immediate;
    18. Database closed.
    19. Database dismounted.
    20. ORACLE instance shut down.

  4. 在mount状态下 利用rman 做基于时间的恢复

    点击(此处)折叠或打开

    1. RMAN> startup mount;

    2. Oracle instance started
    3. database mounted

    4. Total System Global Area 217157632 bytes

    5. Fixed Size 2251816 bytes
    6. Variable Size 159384536 bytes
    7. Database Buffers 50331648 bytes
    8. Redo Buffers 5189632 bytes

    9. RMAN> run{
    10. 2> sql 'alter session set nls_date_format="yyyy-mm-dd hh24:mi:ss"';
    11. 3> set until time='2017-04-06 09:16:22';
    12. 4> restore database;
    13. 5> recover database;
    14. 6> alter database open resetlogs;
    15. 7> }

    16. sql statement: alter session set nls_date_format="yyyy-mm-dd hh24:mi:ss"

    17. executing command: SET until clause

    18. Starting restore at 06-APR-17
    19. allocated channel: ORA_DISK_1
    20. channel ORA_DISK_1: SID=18 device type=DISK

    21. channel ORA_DISK_1: starting datafile backup set restore
    22. channel ORA_DISK_1: specifying datafile(s) to restore from backup set
    23. channel ORA_DISK_1: restoring datafile 00001 to /u01/app/oracle/oradata/PROD1/system01.dbf
    24. channel ORA_DISK_1: restoring datafile 00002 to /u01/app/oracle/oradata/PROD1/sysaux01.dbf
    25. channel ORA_DISK_1: restoring datafile 00003 to /u01/app/oracle/oradata/PROD1/undotbs01.dbf
    26. channel ORA_DISK_1: restoring datafile 00004 to /u01/app/oracle/oradata/PROD1/users01.dbf
    27. channel ORA_DISK_1: restoring datafile 00005 to /u01/app/oracle/oradata/PROD1/example01.dbf
    28. channel ORA_DISK_1: restoring datafile 00006 to /u01/app/oracle/oradata/PROD1/test01.dbf
    29. channel ORA_DISK_1: restoring datafile 00007 to /u01/app/oracle/oradata/PROD1/test02.dbf
    30. channel ORA_DISK_1: reading from backup piece /u01/app/oracle/product/11.2.0/dbhome_1/dbs/02s10ale_1_1
    31. channel ORA_DISK_1: piece handle=/u01/app/oracle/product/11.2.0/dbhome_1/dbs/02s10ale_1_1 tag=TAG20170406T091318
    32. channel ORA_DISK_1: restored backup piece 1
    33. channel ORA_DISK_1: restore complete, elapsed time: 00:00:55
    34. Finished restore at 06-APR-17

    35. Starting recover at 06-APR-17
    36. using channel ORA_DISK_1

    37. starting media recovery
    38. media recovery complete, elapsed time: 00:00:00

    39. Finished recover at 06-APR-17

    40. database opened

  5. 验证

    点击(此处)折叠或打开

    1. SQL> select * from t1;

    2.          X
    3. ----------
    4.          1
    5.          2
    6.          3
    7.          4
    8.          5
    9.          6
    10.          7
    11.          8
    12.          9
    13.         10

    14. 10 rows selected.


  6. 此时如果再想恢复到别的时间,会报错

    点击(此处)折叠或打开

    1. RMAN> run{
    2. 2> sql 'alter session set nls_date_format="yyyy-mm-dd hh24:mi:ss"';
    3. 3> set until time='2017-04-06 09:16:21';
    4. 4> restore database;
    5. 5> recover database;
    6. 6> alter database open resetlogs;
    7. 7> }

    8. sql statement: alter session set nls_date_format="yyyy-mm-dd hh24:mi:ss"

    9. executing command: SET until clause

    10. Starting restore at 06-APR-17
    11. RMAN-00571: ===========================================================
    12. RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
    13. RMAN-00571: ===========================================================
    14. RMAN-03002: failure of restore command at 04/06/2017 09:41:55
    15. RMAN-20207: UNTIL TIME or RECOVERY WINDOW is before RESETLOGS time

    点击(此处)折叠或打开

    1. RMAN> run{
    2. 2> sql 'alter session set nls_date_format="yyyy-mm-dd hh24:mi:ss"';
    3. 3> set until time='2017-04-06 09:16:22';
    4. 4> restore database;
    5. 5> recover database;
    6. 6> alter database open resetlogs;
    7. 7> }

    8. using target database control file instead of recovery catalog
    9. sql statement: alter session set nls_date_format="yyyy-mm-dd hh24:mi:ss"

    10. executing command: SET until clause

    11. Starting restore at 06-APR-17
    12. RMAN-00571: ===========================================================
    13. RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
    14. RMAN-00571: ===========================================================
    15. RMAN-03002: failure of restore command at 04/06/2017 09:30:29
    16. RMAN-20207: UNTIL TIME or RECOVERY WINDOW is before RESETLOGS time




来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/31405405/viewspace-2136688/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/31405405/viewspace-2136688/

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值