oracle:rman恢复----通过时间set until time

系统 2397 0

 

   试验计划:先做一个0级备份,再创建一个表,插入几条数据,最后删除表,然后通过rman把该表的数据恢复。

 

试验环境:在归档模式,oracle10.2.0.1

 

开始试验:

1.rman level 0备份

      
        
          RMAN> backup incremental level 0
        
      
      
        
          
             database;
          
        
        



Starting backup at 
      
      
        02
      
      -DEC-
      
        13
      
      
        

allocated channel: ORA_DISK_1

channel ORA_DISK_1: sid
      
      =
      
        154
      
       devtype=
      
        DISK

channel ORA_DISK_1: starting incremental level 
      
      
        0
      
      
         datafile backupset

channel ORA_DISK_1: specifying datafile(s) 
      
      
        in
      
      
         backupset

input datafile fno
      
      =
      
        00001
      
       name=/u01/app/oracle/product/
      
        10.2
      
      .
      
        0
      
      /db_2/oradata/orcl/
      
        system01.dbf

input datafile fno
      
      =
      
        00003
      
       name=/u01/app/oracle/product/
      
        10.2
      
      .
      
        0
      
      /db_2/oradata/orcl/
      
        sysaux01.dbf

input datafile fno
      
      =
      
        00002
      
       name=/u01/app/oracle/product/
      
        10.2
      
      .
      
        0
      
      /db_2/oradata/orcl/
      
        undotbs01.dbf

input datafile fno
      
      =
      
        00006
      
       name=/u01/app/oracle/product/
      
        10.2
      
      .
      
        0
      
      /db_2/oradata/orcl/
      
        yn.dbf

input datafile fno
      
      =
      
        00004
      
       name=/u01/app/oracle/product/
      
        10.2
      
      .
      
        0
      
      /db_2/oradata/orcl/
      
        users01.dbf

channel ORA_DISK_1: starting piece 
      
      
        1
      
       at 
      
        02
      
      -DEC-
      
        13
      
      
        

channel ORA_DISK_1: finished piece 
      
      
        1
      
       at 
      
        02
      
      -DEC-
      
        13
      
      
        

piece handle
      
      =/u01/app/oracle/flash_recovery_area/ORCL/backupset/2013_12_02/o1_mf_nnnd0_TAG20131202T211658_99s22c7o_.bkp tag=TAG20131202T211658 comment=
      
        NONE

channel ORA_DISK_1: backup 
      
      
        set
      
       complete, elapsed time: 
      
        00
      
      :
      
        01
      
      :
      
        25
      
      
        

channel ORA_DISK_1: starting incremental level 
      
      
        0
      
      
         datafile backupset

channel ORA_DISK_1: specifying datafile(s) 
      
      
        in
      
      
         backupset

including current control file 
      
      
        in
      
      
         backupset

including current SPFILE 
      
      
        in
      
      
         backupset

channel ORA_DISK_1: starting piece 
      
      
        1
      
       at 
      
        02
      
      -DEC-
      
        13
      
      
        

channel ORA_DISK_1: finished piece 
      
      
        1
      
       at 
      
        02
      
      -DEC-
      
        13
      
      
        

piece handle
      
      =/u01/app/oracle/flash_recovery_area/ORCL/backupset/2013_12_02/o1_mf_ncsn0_TAG20131202T211658_99s252by_.bkp tag=TAG20131202T211658 comment=
      
        NONE

channel ORA_DISK_1: backup 
      
      
        set
      
       complete, elapsed time: 
      
        00
      
      :
      
        00
      
      :
      
        05
      
      
        

Finished backup at 
      
      
        02
      
      -DEC-
      
        13
      
    

2.创建表

      SQL> create table t1(id 
      
        int
      
      ,name varchar2(
      
        20
      
      
        ));



Table created.



SQL
      
      > insert into t1 values(
      
        1
      
      ,
      
        '
      
      
        first
      
      
        '
      
      
        );




      
      
        1
      
      
         row created.



SQL
      
      >
      
         commit;



SQL
      
      > insert into t1 values(
      
        2
      
      ,
      
        '
      
      
        second
      
      
        '
      
      
        );




      
      
        1
      
      
         row created.



SQL
      
      >
      
         commit;



Commit complete.




        
          SQL
        
      
      
        > alter system switch
      
      
        
           logfile;
        
        



System altered.



SQL
      
      > 
      
        select
      
       * 
      
        from
      
      
         t1;



    ID NAME


      
      ---------- --------------------

     
      
        1
      
      
         first

     
      
      
        2
      
       second
      

3.查询当前系统时间

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



TO_CHAR(SYSDATE,
      
      
        '
      
      
        YY
      
      

-------------------


      
        2013
      
      -
      
        12
      
      -
      
        02
      
      
        21
      
      :
      
        41
      
      :
      
        55
      
    

 

4.删除表,关闭数据库,重启数据库

      
        SQL>
      
      
        
           drop table t1;
        
        



Table dropped.



SQL
      
      >
      
         shutdown immediate     

Database closed.

Database dismounted.

ORACLE instance shut down.

SQL
      
      >
      
         startup mount

ORACLE instance started.



Total System Global Area  
      
      
        599785472
      
      
         bytes

Fixed Size            
      
      
        2022632
      
      
         bytes

Variable Size          
      
      
        243270424
      
      
         bytes

Database Buffers      
      
      
        352321536
      
      
         bytes

Redo Buffers            
      
      
        2170880
      
      
         bytes

Database mounted.

SQL
      
      > 
      
        select
      
       status 
      
        from
      
      
         v$instance;



STATUS


      
      ------------
      
        

MOUNTED
      
    

5.rman恢复

      
        RMAN> run{

2> allocate channel c1 type disk;

3> set until time "to_date('2013-12-02 21:41:55','yyyy-mm-dd hh24:mi:ss')";

4> restore database;

5> recover database;

6> sql 'alter database open resetlogs';


      
      
        7
      
      >
      
         }



allocated channel: c1

channel c1: sid
      
      =
      
        155
      
       devtype=
      
        DISK



executing command: SET until clause



Starting restore at 
      
      
        02
      
      -DEC-
      
        13
      
      
        



channel c1: starting datafile backupset restore

channel c1: specifying datafile(s) to restore 
      
      
        from
      
       backup 
      
        set
      
      
        

restoring datafile 
      
      
        00001
      
       to /u01/app/oracle/product/
      
        10.2
      
      .
      
        0
      
      /db_2/oradata/orcl/
      
        system01.dbf

restoring datafile 
      
      
        00002
      
       to /u01/app/oracle/product/
      
        10.2
      
      .
      
        0
      
      /db_2/oradata/orcl/
      
        undotbs01.dbf

restoring datafile 
      
      
        00003
      
       to /u01/app/oracle/product/
      
        10.2
      
      .
      
        0
      
      /db_2/oradata/orcl/
      
        sysaux01.dbf

restoring datafile 
      
      
        00004
      
       to /u01/app/oracle/product/
      
        10.2
      
      .
      
        0
      
      /db_2/oradata/orcl/
      
        users01.dbf

restoring datafile 
      
      
        00006
      
       to /u01/app/oracle/product/
      
        10.2
      
      .
      
        0
      
      /db_2/oradata/orcl/
      
        yn.dbf

channel c1: reading 
      
      
        from
      
       backup piece /u01/app/oracle/flash_recovery_area/ORCL/backupset/2013_12_02/
      
        o1_mf_nnnd0_TAG20131202T211658_99s22c7o_.bkp

channel c1: restored backup piece 
      
      
        1
      
      
        

piece handle
      
      =/u01/app/oracle/flash_recovery_area/ORCL/backupset/2013_12_02/o1_mf_nnnd0_TAG20131202T211658_99s22c7o_.bkp tag=
      
        TAG20131202T211658

channel c1: restore complete, elapsed time: 
      
      
        00
      
      :
      
        00
      
      :
      
        45
      
      
        

Finished restore at 
      
      
        02
      
      -DEC-
      
        13
      
      
        



Starting recover at 
      
      
        02
      
      -DEC-
      
        13
      
      
        



starting media recovery



archive log thread 
      
      
        1
      
       sequence 
      
        56
      
      
        is
      
       already on disk 
      
        as
      
       file /u01/app/oracle/flash_recovery_area/ORCL/archivelog/2013_12_02/
      
        o1_mf_1_56_99s2jvny_.arc

archive log thread 
      
      
        1
      
       sequence 
      
        57
      
      
        is
      
       already on disk 
      
        as
      
       file /u01/app/oracle/flash_recovery_area/ORCL/archivelog/2013_12_02/
      
        o1_mf_1_57_99s2lpbk_.arc

archive log thread 
      
      
        1
      
       sequence 
      
        58
      
      
        is
      
       already on disk 
      
        as
      
       file /u01/app/oracle/flash_recovery_area/ORCL/archivelog/2013_12_02/
      
        o1_mf_1_58_99s3d5ph_.arc

archive log thread 
      
      
        1
      
       sequence 
      
        1
      
      
        is
      
       already on disk 
      
        as
      
       file /u01/app/oracle/flash_recovery_area/ORCL/archivelog/2013_12_02/
      
        o1_mf_1_1_99s3j6fg_.arc

archive log filename
      
      =/u01/app/oracle/flash_recovery_area/ORCL/archivelog/2013_12_02/o1_mf_1_56_99s2jvny_.arc thread=
      
        1
      
       sequence=
      
        56
      
      
        

archive log filename
      
      =/u01/app/oracle/flash_recovery_area/ORCL/archivelog/2013_12_02/o1_mf_1_57_99s2lpbk_.arc thread=
      
        1
      
       sequence=
      
        57
      
      
        

archive log filename
      
      =/u01/app/oracle/flash_recovery_area/ORCL/archivelog/2013_12_02/o1_mf_1_58_99s3d5ph_.arc thread=
      
        1
      
       sequence=
      
        58
      
      
        

media recovery complete, elapsed time: 
      
      
        00
      
      :
      
        00
      
      :
      
        02
      
      
        

Finished recover at 
      
      
        02
      
      -DEC-
      
        13
      
      
        



sql statement: alter database open resetlogs

released channel: c1



RMAN
      
      >    
    

 

6.查询被删除的数据

      SQL> 
      
        select
      
       * 
      
        from
      
      
         t1;



    ID NAME


      
      ---------- --------------------

     
      
        1
      
      
         first

     
      
      
        2
      
      
         second



SQL
      
      > 
    

 

7.重新备份数据库

   在生产环境中,不完全恢复后,是要用rman重新备份的。因为该备份是以后数据恢复的一个起点。

 

oracle:rman恢复----通过时间set until time


更多文章、技术交流、商务合作、联系博主

微信扫码或搜索:z360901061

微信扫一扫加我为好友

QQ号联系: 360901061

您的支持是博主写作最大的动力,如果您喜欢我的文章,感觉我的文章对您有帮助,请用微信扫描下面二维码支持博主2元、5元、10元、20元等您想捐的金额吧,狠狠点击下面给点支持吧,站长非常感激您!手机微信长按不能支付解决办法:请将微信支付二维码保存到相册,切换到微信,然后点击微信右上角扫一扫功能,选择支付二维码完成支付。

【本文对您有帮助就好】

您的支持是博主写作最大的动力,如果您喜欢我的文章,感觉我的文章对您有帮助,请用微信扫描上面二维码支持博主2元、5元、10元、自定义金额等您想捐的金额吧,站长会非常 感谢您的哦!!!

发表我的评论
最新评论 总共0条评论