• 数据库恢复至某个时间点


    实例详解:

    数据库恢复到某个时间点

    [oracle@lyo1 ~]$ sqlplus / as sysdba

     

    SQL*Plus: Release 11.2.0.4.0 Production on Wed Jul 18 01:16:04 2018

     

    Copyright (c) 1982, 2013, Oracle.  All rights reserved.

     

     

    Connected to:

    Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production

    With the Partitioning, OLAP, Data Mining and Real Application Testing options

     

    SQL> conn scott/oracle

    Connected.

    创建一个表t1

    SQL> create table t1 (x int);

     

    Table created.

    插入一行数据并提交

    SQL> insert into t1 values (1);

     

    1 row created.

     

    SQL> commit;

     

    Commit complete.

     

    SQL> select * from t1;

     

     X

    ----------

     1

     

    连接到SYS

    SQL> conn / as sysdba

    Connected.

    将当期时间转换为SCN

    SQL> select timestamp_to_scn(sysdate) from v$database;

     

    TIMESTAMP_TO_SCN(SYSDATE)

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

      1149633

    将指定时间转换为SCN

    SYS@VDEDU>select timestamp_to_scn(to_date('2018-07-19 10:59:26')) from v$database;

     

    TIMESTAMP_TO_SCN(TO_DATE('2018-07-1910:59:26'))

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

                                            1129373

     

    SQL> conn scott/oracle

    Connected.

    插入一行数据

    SQL> insert into t1 values (2);

     

    1 row created.

     

    SQL> commit;

     

    Commit complete.

    此时t1为两行数据

    SQL> select * from t1;

     

     X

    ----------

     1

     2

     

     

    SQL> conn / as sysdba

    Connected.

    SQL> shutdown immediate;

    Database closed.

    Database dismounted.

    ORACLE instance shut down.

    关闭数据库启动到mount模式

    SQL> startup mount;

    ORACLE instance started.

     

    Total System Global Area 1503199232 bytes

    Fixed Size     2253424 bytes

    Variable Size   922750352 bytes

    Database Buffers   570425344 bytes

    Redo Buffers     7770112 bytes

    Database mounted.

    SQL> quit

     

    启动RMAN

    [oracle@lyo1 ~]$ rman target /

     

    Recovery Manager: Release 11.2.0.4.0 - Production on Wed Jul 18 01:19:03 2018

     

    Copyright (c) 1982, 2011, Oracle and/or its affiliates.  All rights reserved.

     

    connected to target database: VDEDU (DBID=4265126356, not open)

     

    使数据库恢复到刚才的时间点

    RMAN> run{

    2> set until scn = 1149633;

    3> restore database;

    4> recover database;

    5> alter database open resetlogs;

    6> }

     

    executing command: SET until clause

     

    Starting restore at 2018-07-18 01:21:20

    using target database control file instead of recovery catalog

    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/VDEDU/system01.dbf

    channel ORA_DISK_1: restoring datafile 00002 to /u01/app/oracle/oradata/VDEDU/sysaux01.dbf

    channel ORA_DISK_1: restoring datafile 00003 to /u01/app/oracle/oradata/VDEDU/undotbs01.dbf

    channel ORA_DISK_1: restoring datafile 00004 to /u01/app/oracle/oradata/VDEDU/users01.dbf

    channel ORA_DISK_1: restoring datafile 00005 to /u01/app/oracle/oradata/VDEDU/example01.dbf

    channel ORA_DISK_1: reading from backup piece /u01/app/oracle/fast_recovery_area/VDEDU/backupset/2018_07_18/o1_mf_nnndf_TAG20180718T011528_fnxm7jk1_.bkp

    channel ORA_DISK_1: piece handle=/u01/app/oracle/fast_recovery_area/VDEDU/backupset/2018_07_18/o1_mf_nnndf_TAG20180718T011528_fnxm7jk1_.bkp tag=TAG20180718T011528

    channel ORA_DISK_1: restored backup piece 1

    channel ORA_DISK_1: restore complete, elapsed time: 00:00:35

    Finished restore at 2018-07-18 01:21:56

     

    Starting recover at 2018-07-18 01:21:56

    using channel ORA_DISK_1

     

    starting media recovery

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

     

    Finished recover at 2018-07-18 01:21:56

     

    database opened

     

    RMAN> quit

     

    [oracle@lyo1 ~]$ sqlplus scott/oracle

     

    SQL*Plus: Release 11.2.0.4.0 Production on Wed Jul 18 01:22:08 2018

     

    Copyright (c) 1982, 2013, Oracle.  All rights reserved.

     

     

    Connected to:

    Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production

    With the Partitioning, OLAP, Data Mining and Real Application Testing options

     

    查询表t1,发现又变回了一行数据

    SQL> select * from t1;

     

     X

    ----------

     1

  • 相关阅读:
    【文言文】从高考到程序员
    lambda方法引用总结——烧脑吃透
    秒杀苹果carplay baidu车联网API冷艳北京车展
    东君误妾我怜卿(一)
    百度快照投诉技巧案例分析百度快照就是这样刷出来的
    新浪博客是否可以放谷歌广告?如何添加
    与葡萄酒的亲密接触-选购技巧篇
    车联网高速公路智能交通解决方案
    物联网细分领域-车联网(OBD)市场分析
    APP开发选择什么框架好? 请看这里!
  • 原文地址:https://www.cnblogs.com/kawashibara/p/9351750.html
Copyright © 2020-2023  润新知