您好,登錄后才能下訂單哦!
Logminer依賴于2個(gè)包:DBMS_LOGMNR和DBMS_LOGMNR_D,Oracle 11g默認(rèn)已安裝
Logminer 基本使用步驟
<1>. Specify a LogMiner dictionary. 指定Logminer字典
<2>. Specify a list of redo log files for analysis. 指定需要挖掘的redo或者archivelog日志文件
<3>. Start LogMiner. 開始日志挖掘
<4>. Request the redo data of interest. 查詢V$LOGMNR_CONTENTS獲取挖掘的結(jié)果
<5>. End the LogMiner session. 結(jié)束日志挖掘
日志挖掘使用示例:
1.開啟補(bǔ)全日志:
SQL> ALTER DATABASE ADD SUPPLEMENTAL LOG DATA;
2.找出需要挖掘的歸檔日志文件路徑
SQL> SELECT NAME FROM V$ARCHIVED_LOGWHERE FIRST_TIME between to_date('2018-07-06 08:20:00','yyyy-mm-dd hh34:mi:ss') and to_date('2018-07-06 09:40:00','yyyy-mm-dd hh34:mi:ss') order by 1; NAME -------------------------------------------------------------------------------- /u01/app/archive/1_342433_904747849.dbf /u01/app/archive/1_342434_904747849.dbf /u01/app/archive/1_342435_904747849.dbf
3.指定Logminer字典 (三選一)
Oracle 11g 指定Logminer字典有三種方法
1.Using the Online Catalog 使用在線目錄
2.Extracting a LogMiner Dictionary to the Redo Log Files 抽取字典到redo日志文件中
3.Extracting the LogMiner Dictionary to a Flat File 抽取字典到平面文件中(需要設(shè)置UTL_FILE_DIR參數(shù),重啟數(shù)據(jù)庫(kù),不推薦)
EXECUTE DBMS_LOGMNR.START_LOGMNR(OPTIONS => DBMS_LOGMNR.DICT_FROM_ONLINE_CATALOG); OR EXECUTE DBMS_LOGMNR_D.BUILD( OPTIONS=> DBMS_LOGMNR_D.STORE_IN_REDO_LOGS); OR EXECUTE DBMS_LOGMNR_D.BUILD('dictionary.ora', '/oracle/database/', DBMS_LOGMNR_D.STORE_IN_FLAT_FILE);
4.Logminer中添加歸檔日志文件
EXECUTE DBMS_LOGMNR.ADD_LOGFILE( LOGFILENAME => '/u01/app/archive/1_342433_904747849.dbf', OPTIONS => DBMS_LOGMNR.NEW);
繼續(xù)添加日志:
EXECUTE DBMS_LOGMNR.ADD_LOGFILE( LOGFILENAME => '/u01/app/archive/1_342434_904747849.dbf', OPTIONS => DBMS_LOGMNR.ADDFILE); EXECUTE DBMS_LOGMNR.ADD_LOGFILE( LOGFILENAME => '/u01/app/archive/1_342435_904747849.dbf', OPTIONS => DBMS_LOGMNR.ADDFILE);
查看添加的日志列表:
select filename from V$LOGMNR_LOGS;
5.開始日志挖掘 (三選一,與步驟3對(duì)應(yīng))
EXECUTE DBMS_LOGMNR.START_LOGMNR(OPTIONS => DBMS_LOGMNR.DICT_FROM_ONLINE_CATALOG); OR EXECUTE DBMS_LOGMNR.START_LOGMNR(OPTIONS => DBMS_LOGMNR.DICT_FROM_REDO_LOGS ); OR EXECUTE DBMS_LOGMNR.START_LOGMNR(DICTFILENAME =>'/oracle/database/dictionary.ora');
6.獲取挖掘結(jié)果
SELECT username AS USR, (XIDUSN || '.' || XIDSLT || '.' || XIDSQN) AS XID, SQL_REDO, SQL_UNDO FROM V$LOGMNR_CONTENTS WHERE username IN ('HR', 'OE');
把挖取結(jié)果保存到指定表格中: create table logtab as select * from v$logmnr_contents;
7.結(jié)束日志挖掘
EXECUTE DBMS_LOGMNR.END_LOGMNR;
總結(jié)
以上所述是小編給大家介紹的Oracle 日志挖掘(LogMiner)使用詳解,希望對(duì)大家有所幫助,如果大家有任何疑問請(qǐng)給我留言,小編會(huì)及時(shí)回復(fù)大家的。在此也非常感謝大家對(duì)億速云網(wǎng)站的支持!
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。