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;

  • 相关阅读:
    Java读写.properties文件实例,解决中文乱码问题
    web项目的getContextPath()
    PWC6345: There is an error in invoking javac. A full JDK (not just JRE) is required
    Eclipse安装与配置
    Linux基础整理 + 注释
    git命令集合
    遍历List集合的三种方法
    使用jqueryUI和corethink实现的类似百度的搜索提示
    corethink功能模块探索开发(十八)前台页面插入jit前端数据可视化库
    corethink功能模块探索开发(十七)opencmf.php 配置文件
  • 原文地址:https://www.cnblogs.com/Wardenking/p/10062765.html
Copyright © 2011-2022 走看看