• 人工手动冷备不完全恢复介绍(purge表不完全恢复)


    不完全恢复


    不完全恢复的基本类型:
    1)基于时间点 (until time): 使整个数据库恢复到过去的一个时间点前
    2)基于scn (until change): 使整个数据库恢复到过去的某个SCN前
    3)基于cancel (until cancel): 使整个数据库恢复到归档日志或当前日志的断点前


    不完全恢复(Incomplete recover) 适用环境:
    1)在过去的某个时间点重要的数据被破坏。
    2)在做完全恢复时,丢失了归档日志或当前online redo log
    3)当误删除了表空间时(有控制文件备份)
    4)丢失了所有的控制文件,使用备份的控制文件恢复时  (条件满足时可以完全恢复)


    传统的不完全恢复的操作步骤:
    1)先通过logmnr 找到误操作的时间点
    2)对现在的database做新全备
    3)还原该时间点前所有的datafile
    4)在mount状态下,对database做recover,恢复到误操作的时间点
    5)将恢复出来的table做逻辑备份(exp)
    6)再将全备还原
    7)将导出的表导入database(imp)  


    实验 1:恢复过去某个时间点误操作的table    (基于时间点的不完全恢复)   前提:有冷备份,日志,归档齐全


    1)准备实验数据


    SQL> select * from andy;


            ID
    ----------
             4


    SQL> insert into andy values(5);


    1 row created.


    SQL> commit;


    Commit complete.


    SQL> drop table andy purge;


    Table dropped.


    2)查看日志,归档环境


    SQL> set linesize 400
    SQL> select * from v$log;


        GROUP#    THREAD#  SEQUENCE#      BYTES  BLOCKSIZE    MEMBERS ARC STATUS           FIRST_CHANGE#
    ---------- ---------- ---------- ---------- ---------- ---------- --- ---------------- -------------
             1          1         61   52428800        512          1 NO  CURRENT                1991534
             2          1         59   52428800        512          1 YES INACTIVE               1959769
             3          1         60   52428800        512          1 YES INACTIVE               1966481


    SQL> alter system switch logfile;


    System altered.


    SQL> select name from v$archived_log;
    NAME
    ----------------------------------------------------------------------------------------------------------




    /home/oracle/archivelog/ORCL/archivelog/2014_12_01/o1_mf_1_47_b7rwlclg_.arc
    /home/oracle/app/flash_recovery_area/ORCL/archivelog/2014_12_01/o1_mf_1_48_b7ryjgng_.arc
    /home/oracle/app/flash_recovery_area/ORCL/archivelog/2014_12_01/o1_mf_1_49_b7rykz3l_.arc
    /home/oracle/app/flash_recovery_area/ORCL/archivelog/2014_12_01/o1_mf_1_50_b7ryn3fl_.arc
    /home/oracle/archivelog/1_51_860522448.dbf
    /home/oracle/archivelog/1_52_860522448.dbf
    /home/oracle/archivelog/1_53_860522448.dbf
    /home/oracle/archivelog/1_54_860522448.dbf
    /home/oracle/archivelog/1_55_860522448.dbf


    NAME
    ----------------------------------------------------------------------------------------------------------
    /home/oracle/archivelog/1_56_860522448.dbf
    /home/oracle/archivelog/1_57_860522448.dbf
    /home/oracle/archivelog/1_58_860522448.dbf
    /home/oracle/archivelog/1_59_860522448.dbf
    /home/oracle/archivelog/1_60_860522448.dbf
    /home/oracle/archivelog/1_61_860522448.dbf


    28 rows selected.


    3)logmnr日志挖掘,找出purge时间点。


    --日志挖掘至少要提前开SUPPLEME,如果没开,信息会报错
    SQL> select supplemental_log_data_min,supplemental_log_data_pk,supplemental_log_data_ui from v$database;


    SUPPLEME SUP SUP
    -------- --- ---
    YES      NO  NO
    SQL> col member for a50;
    SQL>  select * from v$logfile;


        GROUP# STATUS  TYPE    MEMBER                                             IS_
    ---------- ------- ------- -------------------------------------------------- ---
             3         ONLINE  /home/oracle/app/oradata/orcl/redo03.log           NO
             2         ONLINE  /home/oracle/app/oradata/orcl/redo02.log           NO
             1         ONLINE  /home/oracle/app/oradata/orcl/redo01.log           NO


    SQL> select group#,status from v$log;


        GROUP# STATUS
    ---------- ----------------
             1 ACTIVE
             2 CURRENT
             3 INACTIVE


    SQL>  select name from v$archived_log where name is not null order by 1;


    NAME
    -----------------------------------------------------------------------------------------
    /home/oracle/app/flash_recovery_area/ORCL/archivelog/2014_12_01/o1_mf_1_48_b7ryjgng_.arc
    /home/oracle/app/flash_recovery_area/ORCL/archivelog/2014_12_01/o1_mf_1_49_b7rykz3l_.arc
    /home/oracle/app/flash_recovery_area/ORCL/archivelog/2014_12_01/o1_mf_1_50_b7ryn3fl_.arc
    /home/oracle/archivelog/1_51_860522448.dbf
    /home/oracle/archivelog/1_52_860522448.dbf
    /home/oracle/archivelog/1_53_860522448.dbf
    /home/oracle/archivelog/1_54_860522448.dbf
    /home/oracle/archivelog/1_55_860522448.dbf
    /home/oracle/archivelog/1_56_860522448.dbf
    /home/oracle/archivelog/1_57_860522448.dbf
    /home/oracle/archivelog/1_58_860522448.dbf


    NAME
    -----------------------------------------------------------------------------------------
    /home/oracle/archivelog/1_59_860522448.dbf
    /home/oracle/archivelog/1_60_860522448.dbf
    /home/oracle/archivelog/1_61_860522448.dbf
    /home/oracle/archivelog/ORCL/archivelog/2014_12_01/o1_mf_1_47_b7rwlclg_.arc


    15 rows selected.


    -- 利用redolog日志进行挖掘


    SQL>  EXECUTE DBMS_LOGMNR.ADD_LOGFILE(LogFileName=>'/home/oracle/app/oradata/orcl/redo01.log',Options=>dbms_logmnr.new);


    PL/SQL procedure successfully completed.


    SQL>EXECUTE DBMS_LOGMNR.ADD_LOGFIL (LogFileName=>'/home/oracle/app/oradata/orcl/redo02.log',Options=>dbms_logmnr.ADDFILE);


    PL/SQL procedure successfully completed.


    SQL>EXECUTE DBMS_LOGMNR.ADD_LOGFILE(LogFileName=>'/home/oracle/app/oradata/orcl/redo03.log',Options=>dbms_logmnr.ADDFILE);


    PL/SQL procedure successfully completed.


    SQL>  execute DBMS_LOGMNR.START_LOGMNR(options=>dbms_logmnr.dict_from_online_catalog);


    PL/SQL procedure successfully completed.


    SQL>  col username for a10;
    SQL> col sql_redo for a45;
    SQL>  select username,scn,timestamp,sql_redo from v$logmnr_contents where seg_name='ANDY' order by scn;


    USERNAME          SCN TIMESTAMP           SQL_REDO
    ---------- ---------- ------------------- ---------------------------------------------
    ANDY          2000934 2014-12-11 09:47:15 drop table andy purge;        //找到purge时间


    --利用归档进行日志挖掘


    SQL> show parameter utl


    NAME                                 TYPE        VALUE
    ------------------------------------ ----------- ------------------------------
    create_stored_outlines               string
    utl_file_dir                         string


    SQL> alter system set utl_file_dir='/home/oracle/logmnr' scope=spfile;


    System altered.


    SQL> startup force;


    SQL> show parameter utl;


    NAME                                 TYPE        VALUE
    ------------------------------------ ----------- ------------------------------
    create_stored_outlines               string
    utl_file_dir                         string      /home/oracle/logmnr


    SQL> execute dbms_logmnr_d.build('dict.ora','/home/oracle/logmnr',dbms_logmnr_d.store_in_flat_file);


    PL/SQL procedure successfully completed.


    SQL> execute dbms_logmnr.add_logfile(logfilename=>'/home/oracle/archivelog/1_61_860522448.dbf',options=>dbms_logmnr.new);


    PL/SQL procedure successfully completed.


    SQL> execute dbms_logmnr.start_logmnr(dictfilename=>'/home/oracle/logmnr/dict.ora',options=>dbms_logmnr.ddl_dict_tracking);


    PL/SQL procedure successfully completed.


    SQL> select username,scn,to_char(timestamp,'yyyy-mm-dd hh24:mi:ss'),sql_redo from v$logmnr_contents WHERE lower(sql_redo) like 'drop table%';


    USERNAME                              SCN TO_CHAR(TIMESTAMP,' SQL_REDO
    ------------------------------ ---------- ------------------- --------------------------------------------------
    ANDY                              2000934 2014-12-11 09:47:15 drop table andy purge;


    SQL>  execute dbms_logmnr.end_logmnr;


    PL/SQL procedure successfully completed.




    4)关闭数据库,删除所有dbf,准备做不完全恢复


    SQL> shutdown immdiate;
    [oracle@11g logmnr]$ cd /home/oracle/app/oradata/orcl/
    [oracle@11g orcl]$ rm -rf *.dbf


    5)还原所有备份的数据文件


    [oracle@11g orcl]$ cp /home/oracle/coldbak/*.dbf  /home/oracle/app/oradata/orcl/


    6)根据log miner提供的信息,做基于时间点的不完全恢复


    SQL> recover database until time '2014-12-11 09:47:15';
    ORA-00279: change 1968596 generated at 12/10/2014 06:26:35 needed for thread 1
    ORA-00289: suggestion : /home/oracle/archivelog/1_60_860522448.dbf
    ORA-00280: change 1968596 for thread 1 is in sequence #60




    Specify log: {<RET>=suggested | filename | AUTO | CANCEL}
    auto
    ORA-00279: change 1991534 generated at 12/10/2014 07:25:45 needed for thread 1
    ORA-00289: suggestion : /home/oracle/archivelog/1_61_860522448.dbf
    ORA-00280: change 1991534 for thread 1 is in sequence #61




    Log applied.
    Media recovery complete.


    说明:如果恢复过程中用到归档日志则输入 auto 。用到当前日志,则输入 filename 。 


    7)resetlogs方式打开数据库


    SQL> alter database open resetlogs;


    Database altered.


    8)验证
    SQL> select * from andy;


            ID
    ----------
             5
             4


    OK,转载请标明出处。















  • 相关阅读:
    Opencv之像素值的获取
    亚像素级角点检测
    Shi-Tomasi角点检测
    卡尔曼滤波
    Harris角点检测理论
    ROS2GO 与WIN10 双系统安装
    数字集成电路物理设计学习总结——物理设计建库域验证
    跨时钟域信号传输(二)——数据信号篇
    跨时钟域信号传输(一)——控制信号篇
    亚稳态与多时钟切换
  • 原文地址:https://www.cnblogs.com/andy6/p/6274603.html
Copyright © 2020-2023  润新知