What is LogMiner

download What is LogMiner

of 3

Transcript of What is LogMiner

  • 8/7/2019 What is LogMiner

    1/3

    What is LogMiner?

    LogMiner is an Oracle utility. Using LogMiner one can query the contents of online redolog files and archived log files. It can be used as a powerful data audit tool, as well as atool for sophisticated data analysis.

    Log Miner Configuration:

    The three basic objects in a LogMiner configuration:

    Source Database LogMiner Directory Redo log files

    To extract a LogMiner dictionary to the redo log files, the database must be open and inARCHIVELOG mode and archiving must be enabled. While the dictionary is being

    extracted to the redo log stream, no DDL statements can be executed.

    SQL> archive log listDatabase log mode Archive Mode

    Automatic archival Enabled Archive destination /u02/techfaq360/archiveOldest online log sequence 129

    Next log sequence to archive 131Current log sequence 131

    Make sure you get the list of archives generated for the day using the below commnand.From the below output identify the archivelogs you are going to mine using logminer..

    SQL>alter session set nls_date_format='yyyy-mm-dd hh24:mi:ss';

    Session altered.SQL>select thread#, sequence#, completion_time from v$archived_logorder by completion_time desc;THREAD# SEQUENCE# COMPLETION_TIME---------- ---------- -------------------1 130 2008-07-10 09:35:201 129 2008-07-07 02:30:351 128 2008-07-06 15:30:231 127 2008-07-06 11:33:401 126 2008-07-06 11:33:12

    1 125 2008-07-06 11:32:561 124 2008-07-06 11:32:411 123 2008-07-06 11:32:141 122 2008-07-03 16:31:171 121 2008-07-03 10:25:531 120 2008-07-01 13:30:411 119 2008-07-01 12:07:131 118 2008-07-01 12:05:391 117 2008-07-01 12:05:331 116 2008-07-01 12:05:25

  • 8/7/2019 What is LogMiner

    2/3

    1 115 2008-07-01 12:05:141 114 2008-07-01 12:05:011 113 2008-07-01 12:04:471 112 2008-07-01 12:04:331 111 2008-07-01 12:04:25

    Set the initialization parameter, UTL_FILE_DIR, in the initialization parameter file. Forexample, to set UTL_FILE_DIR to use /u02/techfaq360 as the directory where thedictionary file is placed, enter the following in the initialization parameter file:

    UTL_FILE_DIR = /u02/techfaq360

    Execute the PL/SQL procedure DBMS_LOGMNR_D.BUILD. Specify a filename for thedictionary and a directory path name for the file. This procedure creates the dictionaryfile. For example, enter the following to create the file dictionary.ora in /u02/techfaq360:

    SQL> execute dbms_logmnr_d.build('dictionary.ora','/u02/techfaq360');

    PL/SQL procedure successfully completed.SQL> executedbms_logmnr.add_logfile('/u02/techfaq360/archive/1_130_658758571.dbf',dbms_logmnr.addfile);PL/SQL procedure successfully completed.SQL> executedbms_logmnr.add_logfile('/u02/techfaq360/archive/1_129_658758571.dbf',dbms_logmnr.addfile);PL/SQL procedure successfully completed.SQL> executedbms_logmnr.add_logfile('/u02/techfaq360/archive/1_128_658758571.dbf',dbms_logmnr.addfile);PL/SQL procedure successfully completed.

    SQL> executedbms_logmnr.add_logfile('/u02/techfaq360/archive/1_127_658758571.dbf',dbms_logmnr.addfile);PL/SQL procedure successfully completed.

    Now from the below view , make sure you have all the registered logs available formining.

    SQL>select log_id, filename from v$logmnr_logs;LOG_ID FILENAME---------- ------------------------------------------127 /u02/techfaq360/archive/1_127_658758571.dbf

    128 /u02/techfaq360/archive/1_128_658758571.dbf129 /u02/techfaq360/archive/1_129_658758571.dbf130 /u02/techfaq360/archive/1_130_658758571.dbf

    Using the below views find the first scn and high scn to mine from the registered logs.

    SQL> alter session set nls_date_format='yyyy-mm-dd hh24:mi:ss';Session altered.

  • 8/7/2019 What is LogMiner

    3/3

    SQL> select low_time,high_time,low_scn,next_scn from v$logmnr_logs;LOW_TIME HIGH_TIME LOW_SCN NEXT_SCN------------------- ------------------- ---------- ----------2008-07-06 11:33:12 2008-07-06 11:33:39 620682 6224002008-07-06 11:33:39 2008-07-06 15:30:22 622400 6300982008-07-06 15:30:22 2008-07-07 02:30:34 630098 6455562008-07-07 02:30:34 2008-07-10 09:35:19 645556 679141

    From the above out gather the details and add it to the below logminer session :

    SQL> execute dbms_logmnr.start_logmnr(dictfilename=>'/u02/techfaq360/dictionary.ora',starttime => to_date('2008-07-0611:33:39', 'yyyy-mm-dd hh24:mi:ss'), endtime => to_date('2008-07-1009:35:19', 'yyyy-mm-dd hh24:mi:ss'));PL/SQL procedure successfully completed.

    As v$logmnr_contents is a temporary view, once you disconnect your session , you wontbe able to see the content, so make sure you create a table of all the contents of the view.

    SQL> create table logmnr_table_1 as select * from v$logmnr_contents;Table created.

    Here I mentioned the exact steps what I performed in my test machine. I used RHEL 4 osand Oracle 10g R2 database. comments are appreciated.