zoukankan      html  css  js  c++  java
  • RMAN备份恢复之不完全恢复

    ORACLE不完全恢复
    基于时间的不完全恢复
    恢复要求:a、数据库开启归档切要有最近的有效rman全备。b、要有需要恢复到的准确时间点。
    1、 做一个rman全备
    RMAN>backup database;
    2、 构建几个状态
    在数据库里创建scott.t1并插入数据记录状态为a,记录时间t1。
    在数据库里创建scott.t2并插入数据记录状态为b,记录时间t2。
    进入数据库删除scott.t2里的某几个数据记录状态为c,记录时间为t3。
    进入数据库删除用户scott记录状态为d,记录时间为t4。
    3、 目的恢复到状态b,用错时间恢复到状态c。
    RMAN> shutdown immediate;
    RMAN> startup mount;
    RMAN> run
    2> {
    3> allocate channel d1 type disk;
    4> allocate channel d2 type disk;
    5> set until time "to_date('t3','yyyy-mm-dd hh24:mi:ss')"; 指定删除表之前的时间
    6> restore database;
    7> recover database;
    8> alter database open resetlogs;
    9>}
    4、 检查t2数据发现是在状态c,重新 恢复到状态b。
    5、 RMAN模式下查看数据库状态,恢复到未使用rman恢复的状态。
    RMAN> list incarnation;查看数据库的所在状态。因为已经恢复过一次使用要恢复到未恢复的状态,即上一状态,如果查到有三个就恢复到2,如果有五个就恢复到3。
    RMAN> reset database to incarnation 2; 重置数据库的状态
    RMAN> run
    2> {
    3> allocate channel d1 type disk;
    4> allocate channel d2 type disk;
    5> set until time "to_date('t2','yyyy-mm-dd hh24:mi:ss')";
    6> restore database;
    7> recover database;
    8> alter database open resetlogs;
    9>}
    6、进库查看验证即可。

    ###############################################################################
    注:
    RMAN> list incarnation; 查看数据库的状态,使用rman恢复一个就会产生一个状态。
    &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&

    基于SCN号的不完全恢复
    前提:数据库开启归档模式、有一个可用的rman全备、已知数据库损坏前的scn号
    1、模拟故障
    Rma>back up database;做rman全备
    SQL> select current_scn from v$database; 查看当前scn号

    CURRENT_SCN

     475351
    

    Rm –rf *.dbf 删除数据文件

    2、恢复数据库
    SQL> shutdown abort;
    SQL> start mount将数据库强制关机并启动到mount状态
    3、运行脚本
    RMAN> run {
    2> set until scn=475351;
    3> restore database;
    4> recover database;
    5> alter database open resetlogs; }
    4、查看数据库状态,验证数据库是否正常
    SQL> select status from v$instance;

  • 相关阅读:
    hiho 1483 区间计数问题+二分答案
    Educational Codeforces Round 17 D dp
    Educational Codeforces Round 17 C 二分
    hiho 1461 暴力+随机
    (转)重置Mac OS X管理员密码
    解析Xcode把应用程序打包成ipa---解决打包完新版本itunes提示不是有效应用程序的问题
    SVN权限修复
    MAC安装SVNServer
    设置UIScrollView只可以水平或者竖直滚动
    (转)android之Fragment(官网资料翻译)
  • 原文地址:https://www.cnblogs.com/Wardenking/p/10062765.html
Copyright © 2011-2022 走看看