Basic Oracle LogMiner Steps

.

This is a quick note about using LogMiner for mining archived redo logs on the database itself. (Source and mining databases are same)
- Specify a dictionary file with the following procedure:

EXECUTE DBMS_LOGMNR_D.BUILD('dictionary.ora','/oracle/acs/logmnr', OPTIONS => DBMS_LOGMNR_D.STORE_IN_FLAT_FILE);

- Determine the minimum and maximum archived log sequences that is in the mining scope.


- Specify one archived log file with DBMS_LOGMNR.ADD_LOGFILE procedure, dbms_logmnr.NEW option. Then we can add other archived log sequences with dbms_logmnr.ADDFILE option:

EXECUTE DBMS_LOGMNR.ADD_LOGFILE( LOGFILENAME => '+ARCH1/xx/archivelog/2013_01_28/thread_2_seq_31844.932.805914077', OPTIONS => dbms_logmnr.NEW); 
EXECUTE DBMS_LOGMNR.ADD_LOGFILE( LOGFILENAME => '+ARCH1/xxx/archivelog/2013_01_28/thread_2_seq_31844.932.805914077', OPTIONS => dbms_logmnr.ADDFILE); 
EXECUTE DBMS_LOGMNR.ADD_LOGFILE( LOGFILENAME => '+ARCH1/xxx/archivelog/2013_01_28/thread_2_seq_31845.1334.805914145', OPTIONS => dbms_logmnr.ADDFILE); 
EXECUTE DBMS_LOGMNR.ADD_LOGFILE( LOGFILENAME => '+ARCH1/xxx/archivelog/2013_01_28/thread_2_seq_31846.1062.805914271', OPTIONS => dbms_logmnr.ADDFILE);


- Start LogMiner with the EXECUTE DBMS_LOGMNR.START_LOGMNR procedure:
EXECUTE DBMS_LOGMNR.START_LOGMNR( DICTFILENAME =>'/oracle/acs/logmnr/dictionary.ora');

- It's also possible to start LogMiner by specifying a time or SCN range:
EXECUTE DBMS_LOGMNR.START_LOGMNR( DICTFILENAME => '/oracle/acs/logmnr/dictionary.ora', STARTTIME => to_date('01-Jan-2013 08:30:00', 'DD-MON-YYYY HH:MI:SS'), - ENDTIME => to_date('01-Jan-2013 08:45:00', 'DD-MON-YYYY HH:MI:SS'));
- Now it's possible to query details about the operations inside archived logs. We can use V$LOGMNR_CONTENTS view for this purpose. However it may be slow to return data because it'll do log file sequential read. If several queries will be run for mining log, it'll be better to create a table by selecting all from V$LOGMNR_CONTENTS view. 
CREATE TABLE ORAMINE.LOGMNR as select * from v$logmnr_contents;
- OWhen we're finished with LogMiner, we can stop it with the following procedure:
EXECUTE DBMS_LOGMNR.end_logmnr;


4 comments:

uhesse.com said...

Nice & helpful! I suppose you know that in recent versions (9i onwards, if I recall that right), you don't need a dictionary file anymore:
begin dbms_logmnr.start_logmnr(options=>DBMS_LOGMNR.DICT_FROM_ONLINE_CATALOG);
end;


Just as additional information :)

Kind regards
Uwe

Emre Baransel said...

Thanks for the information Uwe. I didn't know that..

aparna john said...

Hi, Nice Basic Oracle Log Miner Steps.Thanks, its really helped me......

-Aparna
Theosoft

christina jeni said...

This info you provided in the blog that was really unique I love it!!

Oracle Training in Chennai