首页 > 代码库 > 日志挖掘

日志挖掘

3.2日志挖掘

日志挖掘需要DBMS_LOGMNR_D和DBMS_LOGMNR包,如果数据库没有这两包,SYSDBA身份运行下面脚本:

 @$ORACLE_HOME/rdbms/admin/dbmslm.sql;

 @$ORACLE_HOME/rdbms/admin/dbmslmd.sql;

 

alter database add supplemental log data;

 

SYS@ora11g>select ‘exec dbms_logmnr.add_logfile(logfilename=>‘‘‘||member||‘‘‘);‘ as script from v$logfile; 

SCRIPT

----------------------------------------------------------------------------

exec dbms_logmnr.add_logfile(logfilename=>‘+DATA/ora11g/onlinelog/group_3.266.833721683‘);

exec dbms_logmnr.add_logfile(logfilename=>‘+DATA/ora11g/onlinelog/group_3.267.833721685‘);

exec dbms_logmnr.add_logfile(logfilename=>‘+DATA/ora11g/onlinelog/group_2.264.833721681‘);

exec dbms_logmnr.add_logfile(logfilename=>‘+DATA/ora11g/onlinelog/group_2.265.833721683‘);

exec dbms_logmnr.add_logfile(logfilename=>‘+DATA/ora11g/onlinelog/group_1.262.833721677‘);

exec dbms_logmnr.add_logfile(logfilename=>‘+DATA/ora11g/onlinelog/group_1.263.833721679‘);

 

SYS@ora11g>select ‘exec dbms_logmnr.add_logfile(logfilename=>‘‘‘||name||‘‘‘);‘ as script from v$archived_log;

SCRIPT

----------------------------------------------------------------

exec dbms_logmnr.add_logfile(logfilename=>‘+DATA/ora11g/archivelog/2013_12_09/thread_1_seq_3.271.833735639‘);

exec dbms_logmnr.add_logfile(logfilename=>‘+DATA/ora11g/archivelog/2013_12_10/thread_1_seq_4.272.833820011‘);

exec dbms_logmnr.add_logfile(logfilename=>‘+DATA/ora11g/archivelog/2013_12_10/thread_1_seq_5.273.833839337‘);

exec dbms_logmnr.add_logfile(logfilename=>‘+DATA/ora11g/archivelog/2013_12_11/thread_1_seq_6.274.833879619‘);

exec dbms_logmnr.add_logfile(logfilename=>‘+DATA/ora11g/archivelog/2013_12_11/thread_1_seq_7.275.833894857‘);

exec dbms_logmnr.add_logfile(logfilename=>‘+DATA/ora11g/archivelog/2013_12_31/thread_1_seq_8.276.835635195‘);

exec dbms_logmnr.add_logfile(logfilename=>‘+DATA/ora11g/archivelog/2013_12_31/thread_1_seq_9.277.835637541‘);

exec dbms_logmnr.add_logfile(logfilename=>‘+DATA/ora11g/archivelog/2013_12_31/thread_1_seq_10.278.835637551‘);

exec dbms_logmnr.add_logfile(logfilename=>‘+DATA/ora11g/archivelog/2013_12_31/thread_1_seq_11.279.835637553‘);

exec dbms_logmnr.add_logfile(logfilename=>‘+DATA/ora11g/archivelog/2013_12_31/thread_1_seq_12.280.835637555‘);

exec dbms_logmnr.add_logfile(logfilename=>‘+DATA/ora11g/archivelog/2013_12_31/thread_1_seq_13.281.835637559‘);

 

exec sys.dbms_logmnr.start_logmnr(options=>sys.dbms_logmnr.dict_from_online_catalog);

 

select scn,sql_redo,sql_undo from v$logmnr_contents;

 

exec sys.dbms_logmnr.end_logmnr();

日志挖掘