zoukankan      html  css  js  c++  java
  • Using LogMiner

    Oracle links:

    Using LogMiner
    1.date format
    ALTER SESSION SET NLS_DATE_FORMAT = 'dd-mon-yyyy hh24:mi:ss';
    select to_char(sysdate,'yyyy-mm-dd hh24:mi:ss') from dual;
    Requirement:
    ■ Source and mining database
    – Both the source database and the mining database must be running on the same hardware platform.
    – The mining database can be the same as, or completely separate from, the source database.
    – The mining database must run the same release or a later release of the Oracle Database software as the source database.
    – The mining database must use the same character set (or a superset of the character set) used by the source database.
    ■ LogMiner dictionary
    – The dictionary must be produced by the same source database that generates the redo log files that LogMiner will analyze.
    ■ All redo log files:
    – Must be produced by the same source database.
    – Must be associated with the same database RESETLOGS SCN.
    – Must be from a release 8.0 or later Oracle Database. However, several of the LogMiner features introduced as of release 9.0.1 work only with redo log files produced on an Oracle9i or later database.
    LogMiner does not allow you to mix redo log files from different databases or to use a dictionary from a different database than the one that generated the redo log files to be analyzed.

    Steps in a Typical LogMiner Session
    1.SET DATE FORMAT
    ALTER SESSION SET NLS_DATE_FORMAT = 'DD-MON-YYYY HH24:MI:SS';
    SELECT TO_CHAR(SYSDATE,'YYYY-MM-DD HH24:MI:SS') FROM DUAL;
    2.Enable Supplemental Loggining
    At the very least,enable minimal supplemental logging, as follows:
    ALTER DATABASE ADD SUPPLEMENTAL LOG DATA;
    3.Extract a LogMiner Dictionary  --any method
    3.1Using the Online Catalog
    This is the most efficient and easy-to-use option.
    EXECUTE DBMS_LOGMNR.START_LOGMNR(-
       OPTIONS => DBMS_LOGMNR.DICT_FROM_ONLINE_CATALOG);
    3.2Extracting a LogMiner Dictionary to the Redo Log File
    To extract a LogMiner dictionary to the redo log files, the database must be open and in ARCHIVELOG mode and archiving must be enabled.
    EXECUTE DBMS_LOGMNR_D.BUILD( -
       OPTIONS=> DBMS_LOGMNR_D.STORE_IN_REDO_LOGS);
    3.3Extracting the LogMiner Dictionary to a Flat File
    Be sure that no DDL operations occur while the dictionary is being built.
    a.  To specify a directory, set the initialization parameter, UTL_FILE_DIR, in the initialization parameter file.
    For example, to set UTL_FILE_DIR to use /oracle/database as the directory where the dictionary file is placed, place the following in the initialization
    parameter file:UTL_FILE_DIR = /oracle/database
    Remember that for the changes to the initialization parameter file to take effect,
    you must stop and restart the database.
    b. STARTUP
    c. Execute the PL/SQL procedure DBMS_LOGMNR_D.BUILD. Specify a file name for the dictionary and a directory path name for the file. This procedure creates the dictionary file. For example, enter the following to create the file dictionary.ora in /oracle/database:
    EXECUTE DBMS_LOGMNR_D.BUILD('dictionary.ora', -
       '/oracle/database/', -
        DBMS_LOGMNR_D.STORE_IN_FLAT_FILE);
    You could also specify a file name and location without specifying the STORE_IN_FLAT_FILE option. The result would be the same
    3.4Redo Log File Options
    a.■ Automatically
    LogMiner will use the database control file to find and add redo log files that
    satisfy your specified time or SCN range to the LogMiner redo log file list. For example:
    ALTER SESSION SET NLS_DATE_FORMAT = 'DD-MON-YYYY HH24:MI:SS';
    EXECUTE DBMS_LOGMNR.START_LOGMNR( -
       STARTTIME => '01-Jan-2003 08:30:00', -
       ENDTIME => '01-Jan-2003 08:45:00', -
       OPTIONS => DBMS_LOGMNR.DICT_FROM_ONLINE_CATALOG + -
       DBMS_LOGMNR.CONTINUOUS_MINE);
    b.■ Manually
    For example, enter the following to specify /oracle/logs/log1.f :
    EXECUTE DBMS_LOGMNR.ADD_LOGFILE( -
       LOGFILENAME => '/oracle/logs/log1.f', -
       OPTIONS => DBMS_LOGMNR.NEW);
    If add more redo log files.  For example, enter the following to add /oracle/logs/log2.f:
    EXECUTE DBMS_LOGMNR.ADD_LOGFILE( -
       LOGFILENAME => '/oracle/logs/log2.f', -
       OPTIONS => DBMS_LOGMNR.ADDFILE);
    4.Specify Redo Log Files for Analysis
    a.Ensure instance is open.
    b.Create a list of redo log files

    EXECUTE DBMS_LOGMNR.ADD_LOGFILE( -
       LOGFILENAME => '/oracle/logs/log1.f', -
       OPTIONS => DBMS_LOGMNR.NEW);
    c.Add more redo logs
    EXECUTE DBMS_LOGMNR.ADD_LOGFILE( -
       LOGFILENAME => '/oracle/logs/log2.f', -
       OPTIONS => DBMS_LOGMNR.ADDFILE);
    you could simply enter the following:
    EXECUTE DBMS_LOGMNR.ADD_LOGFILE( -
       LOGFILENAME=>'/oracle/logs/log2.f')
    d. If desired, remove redo log file
    EXECUTE DBMS_LOGMNR.REMOVE_LOGFILE( -
       LOGFILENAME => '/oracle/logs/log2.f');
    5.Start LogMiner
    Execute the DBMS_LOGMNR.START_LOGMNR procedure to start LogMiner
    a.If you are specifying the name of a flat file LogMiner dictionary
    EXECUTE DBMS_LOGMNR.START_LOGMNR( -
       DICTFILENAME =>'/oracle/database/dictionary.ora');
    b.If you are not specifying a flat file dictionary name

    EXECUTE DBMS_LOGMNR.START_LOGMNR(OPTIONS =>
       DBMS_LOGMNR.DICT_FROM_ONLINE_CATALOG);
    6.Query V$LOGMNR_CONTENT
    Filtering Data by Time

    ALTER SESSION SET NLS_DATE_FORMAT = 'DD-MON-YYYY HH24:MI:SS';
    EXECUTE DBMS_LOGMNR.START_LOGMNR( -
       DICTFILENAME => '/oracle/database/dictionary.ora', -
       STARTTIME => '01-Jan-2008 08:30:00', -
       ENDTIME => '01-Jan-2008 08:45:00'-
       OPTIONS => DBMS_LOGMNR.CONTINUOUS_MINE);
    SELECT *
    FROM v$logmnr_contents;
    WHERE sql_redo LIKE '%%';
    7.End the LogMiner Session
    EXECUTE DBMS_LOGMNR.END_LOGMNR

  • 相关阅读:
    .NET性能调优 ---- 使用Visual Studio进行代码度量
    博客园程序源代码下载
    C#中 Newtonsoft.Json 高级用法
    C# 自定义Thread挂起线程和恢复线程
    看图知义,Winform开发的技术特点分析
    循序渐进VUE+Element 前端应用开发(33)--- 邮件参数配置和模板邮件发送处理
    循序渐进VUE+Element 前端应用开发(32)--- 手机短信动态码登陆处理
    ABP框架中短信发送处理,包括阿里云短信和普通短信商的短信发送集成
    循序渐进VUE+Element 前端应用开发(31)--- 系统的日志管理,包括登录日志、接口访问日志、实体变化历史日志
    循序渐进VUE+Element 前端应用开发(30)--- ABP后端和Vue+Element前端结合的分页排序处理
  • 原文地址:https://www.cnblogs.com/AlbertCQY/p/2997662.html
Copyright © 2011-2022 走看看