Logmnr 用法介绍及其注意事项(ORA-01306)
2012-04-21 15:17
423 查看
Logmnr用法介绍及其注意事项
转载请注明出处:http://blog.csdn.net/xiaofan23z
Environment:linux+oracle10gtwonodesrac
一、安装LogMiner工具,以下两个脚本以SYSDBA身份运行
SQL>@$ORACLE_HOME/rdbms/admin/dbmslm.sql;
Packagecreated.
Grantsucceeded.
##创建DBMS_LOGMNR包,该包用来分析日志文件。
SQL>@$ORACLE_HOME/rdbms/admin/dbmslmd.sql;
Packagecreated.
##创建DBMS_LOGMNR_D包,该包用来创建数据字典文件。
二、使用LogMiner工具
下面将详细介绍如何使用LogMiner工具。
1、创建数据字典文件(data-dictionary)
1).首先在init.ora初始化参数文件中,指定数据字典文件的位置,也就是添加一个参数UTL_FILE_DIR,该参数值为服务器中放置数据字典文件的目录。如:UTL_FILE_DIR=($ORACLE_HOME\logs),重新启动数据库,使新加的参数生效:
SQL>shutdownimmediate;
Databaseclosed.
Databasedismounted.
ORACLEinstanceshutdown.
SQL>startupmount
ORACLEinstancestarted.
TotalSystemGlobalArea922746880bytes
FixedSize1222624bytes
VariableSize209717280bytes
DatabaseBuffers704643072bytes
RedoBuffers7163904bytes
Databasemounted.
SQL>altersystemsetutl_file_dir='/u01/app/oracle/product/10.2.0/db_1/log'scope=spfile;
Systemaltered.
SQL>shutdownimmediate
ORA-01109:databasenotopen
Databasedismounted.
ORACLEinstanceshutdown.
SQL>
SQL>startupmount
ORACLEinstancestarted.
TotalSystemGlobalArea922746880bytes
FixedSize1222624bytes
VariableSize209717280bytes
DatabaseBuffers704643072bytes
RedoBuffers7163904bytes
Databasemounted.
SQL>
SQL>showparameterutl
NAMETYPEVALUE
-----------------------------------------------------------------------------
create_stored_outlinesstring
utl_file_dirstring/u01/app/oracle/product/10.2.0
/db_1/log
SQL>
SQL>alterdatabaseopen;
Databasealtered.
SQL>
也可以不使用数据字典,但是oracle推荐使用。
From:HowtoSetupLogMiner[ID111886.1]
转载请注明出处:http://blog.csdn.net/xiaofan23z
2).然后创建数据字典文件
SQL>executedbms_logmnr_d.build(dictionary_filename=>'dict.ora',dictionary_location=>'/u01/app/oracle/product/10.2.0/db_1/log');
PL/SQLproceduresuccessfullycompleted.
2.创建要分析的日志文件列表
1).创建分析列表,即所要分析的日志
SQL>executedbms_logmnr.add_logfile(LogFileName=>'+DATA/ldbrac/onlinelog/group_3.266.732154759',Options=>dbms_logmnr.new);##根据时间点或者在v$log,v$archived_log中查询出要分析的log
PL/SQLproceduresuccessfullycompleted.
###为了验证效果删除一个表然后切换log
droptableaskey_id;
SQL>altersystemswitchlogfile;
Systemaltered.
将切换的log加入到分析列表
SQL>executedbms_logmnr.add_logfile(LogFileName=>'+DATA/ldbrac/onlinelog/group_2.262.732154617',Options=>dbms_logmnr.ADDFILE);
PL/SQLproceduresuccessfullycompleted.
Alertlog中会有如下信息显示
SatApr2111:35:192012
LOGMINER:Beginmininglogfile:+DATA/ldbrac/onlinelog/group_2.262.732154617
SatApr2111:35:192012
LOGMINER:Beginmininglogfile:+DATA/ldbrac/onlinelog/group_3.266.732154759
3、使用logMiner进行日志分析
1).无限制条件,即用数据字典文件对要分析的日志文件所有内容做分析
SQL>executedbms_logmnr.start_logmnr(DictFileName=>'/u01/app/oracle/product/10.2.0/db_1/log/dict.ora');
PL/SQLproceduresuccessfullycompleted.
2).带限制条件,可以用scn号或时间做限制条件,也可组合使用
--分析日志列表中时间从20120420从10:00到13:00的内容
SQL>executedbms_logmnr.start_logmnr(startTime=>to_date('20120421100000','yyyy-mm-ddhh24:mi:ss'),endTime=>to_date('20120421130000','yyyy-mm-ddhh24:mi:ss'),DictFileName=>'/u01/app/oracle/product/10.2.0/db_1/log/dict01.ora');
PL/SQLproceduresuccessfullycompleted
dbms_logmnr.start_logmnr函数的原型为:
PROCEDUREstart_logmnr(
startScnINNUMBERdefault0,
endScnINNUMBERdefault0,
startTimeINDATEdefault'',
endTimeINDATEdefault'',
DictFileNameINVARCHAR2default'',
OptionsINBINARY_INTEGERdefault0);
4.分析数据
V$LOGMNR_LOGS是分析日志列表视图
分析结果在GV$LOGMNR_CONTENTS视图中
根据条件查询分析结果
SQL>select*fromV$LOGMNR_CONTENTSwheresql_redolike'drop%';
SCNCSCNTIMESTAMPCOMMIT_TITHREAD#LOG_IDXIDUSN
--------------------------------------------------------------------
XIDSLTXIDSQNPXIDUSNPXIDSLTPXIDSQNRBASQNRBABLK
----------------------------------------------------------------------
RBABYTEUBAFILUBABLKUBARECUBASQNABS_FILE#REL_FILE#
信息存储在这个session的PGA中,在别的session里面是查不到的。
如果在别的session中视图查询这个视图得到如下错误
SQL>select*fromV$LOGMNR_CONTENTS;
select*fromV$LOGMNR_CONTENTS
ERRORatline1:
ORA-01306:dbms_logmnr.start_logmnr()mustbeinvokedbeforeselectingfrom
v$logmnr_contents
视图v$logmnr_contents中的分析结果仅在我们运行过程'dbms_logmrn.start_logmnr'这个
会话的生命期中存在。这是因为所有的LogMiner存储都在PGA内存中,所有其他的进程是看
不到它的,同时随着进程的结束,分析结果也随之消失。最后,使用过程DBMS_LOGMNR.END_LOGMNR
终止日志分析事务,此时PGA内存区域被清除,分析结果也随之不再存在。
可以创建临时表解决这个问题
SQL>createtablelogmnr_tab1asselect*fromV$LOGMNR_CONTENTS;
Tablecreated.
SQL>
然后在临时表中分析
selectscn,timestamp,log_id,seg_owner,seg_name,table_name,seg_type_name,operation,sql_redo
fromsys.logmnr_tab1wheresql_redolike'drop%';
根据条件查询特定的DDL/DML操作
5.分析后释放内存
SQL>executedbms_logmnr.end_logmnr;
PL/SQLproceduresuccessfullycompleted
6.其它
1).删除日志分析文件
execdbms_logmnr.add_logfile('+DATA/ldbrac/onlinelog/group_2.262.732154617',dbms_logmnr.removefile);
注意:
BEGIN
DBMS_LOGMNR.REMOVE_LOGFILE(LOGFILENAME=>'/oracle/logs/log2.f');
END;
/
Note:Ifalogfileisremovedfromthesession,youmustcallthe
DBMS_LOGMNR.START_LOGMNRprocedureagainbeforeaccessingv$logmnr_contents.
Ifyoudonot,youwillreceiveanerror:
SQL>selectcount(*)fromv$logmnr_contents;
selectcount(*)fromv$logmnr_contents
*
ERRORatline1:
ORA-01306:dbms_logmnr.start_logmnr()mustbeinvokedbeforeselectingfrom
v$logmnr_contents
也就是说当你删除掉一个redolog后你需要重新启动logmnr否则也会得到ORA01306错误。
转载请注明出处:http://blog.csdn.net/xiaofan23z
附录:我写的不够详细,更详细的可以查看oracle官方文档
OracleServer-StandardEdition-Version:8.1.5.0to11.2.0.2.0[Release:8.1.5to11.2]
Informationinthisdocumentappliestoanyplatform.
ToprovidethestepsforsettingupLogMineronthedatabase.
转载请注明出处:http://blog.csdn.net/xiaofan23z
转载请注明出处:http://blog.csdn.net/xiaofan23z
Environment:linux+oracle10gtwonodesrac
一、安装LogMiner工具,以下两个脚本以SYSDBA身份运行
SQL>@$ORACLE_HOME/rdbms/admin/dbmslm.sql;
Packagecreated.
Grantsucceeded.
##创建DBMS_LOGMNR包,该包用来分析日志文件。
SQL>@$ORACLE_HOME/rdbms/admin/dbmslmd.sql;
Packagecreated.
##创建DBMS_LOGMNR_D包,该包用来创建数据字典文件。
二、使用LogMiner工具
下面将详细介绍如何使用LogMiner工具。
1、创建数据字典文件(data-dictionary)
1).首先在init.ora初始化参数文件中,指定数据字典文件的位置,也就是添加一个参数UTL_FILE_DIR,该参数值为服务器中放置数据字典文件的目录。如:UTL_FILE_DIR=($ORACLE_HOME\logs),重新启动数据库,使新加的参数生效:
SQL>shutdownimmediate;
Databaseclosed.
Databasedismounted.
ORACLEinstanceshutdown.
SQL>startupmount
ORACLEinstancestarted.
TotalSystemGlobalArea922746880bytes
FixedSize1222624bytes
VariableSize209717280bytes
DatabaseBuffers704643072bytes
RedoBuffers7163904bytes
Databasemounted.
SQL>altersystemsetutl_file_dir='/u01/app/oracle/product/10.2.0/db_1/log'scope=spfile;
Systemaltered.
SQL>shutdownimmediate
ORA-01109:databasenotopen
Databasedismounted.
ORACLEinstanceshutdown.
SQL>
SQL>startupmount
ORACLEinstancestarted.
TotalSystemGlobalArea922746880bytes
FixedSize1222624bytes
VariableSize209717280bytes
DatabaseBuffers704643072bytes
RedoBuffers7163904bytes
Databasemounted.
SQL>
SQL>showparameterutl
NAMETYPEVALUE
-----------------------------------------------------------------------------
create_stored_outlinesstring
utl_file_dirstring/u01/app/oracle/product/10.2.0
/db_1/log
SQL>
SQL>alterdatabaseopen;
Databasealtered.
SQL>
Ps:LogMinerusesadictionaryfile,whichisaspecialfilethat
indicatesthedatabasethatcreateditaswellasthetimethefilewas
created.Thedictionaryfileisnotrequired,butisrecommended.Withouta
dictionaryfile,theequivalentSQLstatementswilluseOracleinternalobject
IDsfortheobjectnameandpresentcolumnvaluesashexdata.
也可以不使用数据字典,但是oracle推荐使用。
From:HowtoSetupLogMiner[ID111886.1]
转载请注明出处:http://blog.csdn.net/xiaofan23z
2).然后创建数据字典文件
SQL>executedbms_logmnr_d.build(dictionary_filename=>'dict.ora',dictionary_location=>'/u01/app/oracle/product/10.2.0/db_1/log');
PL/SQLproceduresuccessfullycompleted.
2.创建要分析的日志文件列表
1).创建分析列表,即所要分析的日志
SQL>executedbms_logmnr.add_logfile(LogFileName=>'+DATA/ldbrac/onlinelog/group_3.266.732154759',Options=>dbms_logmnr.new);##根据时间点或者在v$log,v$archived_log中查询出要分析的log
PL/SQLproceduresuccessfullycompleted.
###为了验证效果删除一个表然后切换log
droptableaskey_id;
SQL>altersystemswitchlogfile;
Systemaltered.
将切换的log加入到分析列表
SQL>executedbms_logmnr.add_logfile(LogFileName=>'+DATA/ldbrac/onlinelog/group_2.262.732154617',Options=>dbms_logmnr.ADDFILE);
PL/SQLproceduresuccessfullycompleted.
Alertlog中会有如下信息显示
SatApr2111:35:192012
LOGMINER:Beginmininglogfile:+DATA/ldbrac/onlinelog/group_2.262.732154617
SatApr2111:35:192012
LOGMINER:Beginmininglogfile:+DATA/ldbrac/onlinelog/group_3.266.732154759
3、使用logMiner进行日志分析
1).无限制条件,即用数据字典文件对要分析的日志文件所有内容做分析
SQL>executedbms_logmnr.start_logmnr(DictFileName=>'/u01/app/oracle/product/10.2.0/db_1/log/dict.ora');
PL/SQLproceduresuccessfullycompleted.
2).带限制条件,可以用scn号或时间做限制条件,也可组合使用
--分析日志列表中时间从20120420从10:00到13:00的内容
SQL>executedbms_logmnr.start_logmnr(startTime=>to_date('20120421100000','yyyy-mm-ddhh24:mi:ss'),endTime=>to_date('20120421130000','yyyy-mm-ddhh24:mi:ss'),DictFileName=>'/u01/app/oracle/product/10.2.0/db_1/log/dict01.ora');
PL/SQLproceduresuccessfullycompleted
dbms_logmnr.start_logmnr函数的原型为:
PROCEDUREstart_logmnr(
startScnINNUMBERdefault0,
endScnINNUMBERdefault0,
startTimeINDATEdefault'',
endTimeINDATEdefault'',
DictFileNameINVARCHAR2default'',
OptionsINBINARY_INTEGERdefault0);
4.分析数据
V$LOGMNR_LOGS是分析日志列表视图
分析结果在GV$LOGMNR_CONTENTS视图中
根据条件查询分析结果
SQL>select*fromV$LOGMNR_CONTENTSwheresql_redolike'drop%';
SCNCSCNTIMESTAMPCOMMIT_TITHREAD#LOG_IDXIDUSN
--------------------------------------------------------------------
XIDSLTXIDSQNPXIDUSNPXIDSLTPXIDSQNRBASQNRBABLK
----------------------------------------------------------------------
RBABYTEUBAFILUBABLKUBARECUBASQNABS_FILE#REL_FILE#
注意:
使用logminer查询表v$logmnr_contents必须在同一个会话中进行,因为分析的那些信息存储在这个session的PGA中,在别的session里面是查不到的。
如果在别的session中视图查询这个视图得到如下错误
SQL>select*fromV$LOGMNR_CONTENTS;
select*fromV$LOGMNR_CONTENTS
ERRORatline1:
ORA-01306:dbms_logmnr.start_logmnr()mustbeinvokedbeforeselectingfrom
v$logmnr_contents
视图v$logmnr_contents中的分析结果仅在我们运行过程'dbms_logmrn.start_logmnr'这个
会话的生命期中存在。这是因为所有的LogMiner存储都在PGA内存中,所有其他的进程是看
不到它的,同时随着进程的结束,分析结果也随之消失。最后,使用过程DBMS_LOGMNR.END_LOGMNR
终止日志分析事务,此时PGA内存区域被清除,分析结果也随之不再存在。
可以创建临时表解决这个问题
SQL>createtablelogmnr_tab1asselect*fromV$LOGMNR_CONTENTS;
Tablecreated.
SQL>
然后在临时表中分析
selectscn,timestamp,log_id,seg_owner,seg_name,table_name,seg_type_name,operation,sql_redo
fromsys.logmnr_tab1wheresql_redolike'drop%';
根据条件查询特定的DDL/DML操作
5.分析后释放内存
SQL>executedbms_logmnr.end_logmnr;
PL/SQLproceduresuccessfullycompleted
6.其它
1).删除日志分析文件
execdbms_logmnr.add_logfile('+DATA/ldbrac/onlinelog/group_2.262.732154617',dbms_logmnr.removefile);
注意:
BEGIN
DBMS_LOGMNR.REMOVE_LOGFILE(LOGFILENAME=>'/oracle/logs/log2.f');
END;
/
Note:Ifalogfileisremovedfromthesession,youmustcallthe
DBMS_LOGMNR.START_LOGMNRprocedureagainbeforeaccessingv$logmnr_contents.
Ifyoudonot,youwillreceiveanerror:
SQL>selectcount(*)fromv$logmnr_contents;
selectcount(*)fromv$logmnr_contents
*
ERRORatline1:
ORA-01306:dbms_logmnr.start_logmnr()mustbeinvokedbeforeselectingfrom
v$logmnr_contents
也就是说当你删除掉一个redolog后你需要重新启动logmnr否则也会得到ORA01306错误。
转载请注明出处:http://blog.csdn.net/xiaofan23z
附录:我写的不够详细,更详细的可以查看oracle官方文档
HowtoSetupLogMiner[ID111886.1] | ||
Modified31-JAN-2012TypeBULLETINStatusPUBLISHED |
Appliesto:
OracleServer-EnterpriseEdition-Version:8.1.5.0to11.2.0.0.-Release:8.1.5to11.2OracleServer-StandardEdition-Version:8.1.5.0to11.2.0.2.0[Release:8.1.5to11.2]
Informationinthisdocumentappliestoanyplatform.
Purpose
Checkedforrelevanceon24-Jun-2010ToprovidethestepsforsettingupLogMineronthedatabase.
ScopeandApplication
ThisisintendedtohelpusersetupLogMiner.HowtoSetupLogMiner
RELATEDDOCUMENTS
Oracle8iAdministrator'sGuide,Release8.1.6
Oracle8iAdministrator'sGuide,Release8.1.7
Oracle9iDatabaseAdministrator'sGuideRelease2(9.2)
Oracle®DatabaseUtilities10gRelease1(10.1)
Oracle®DatabaseUtilities10gRelease2(10.2)
Oracle®DatabaseUtilities11gRelease1(11.1)
Oracle®DatabaseUtilities11gRelease2(11.2)
Introduction:
=============
LogMinerrunsinanOracleinstancewiththedatabaseeithermountedor
unmounted.LogMinerusesadictionaryfile,whichisaspecialfilethat
indicatesthedatabasethatcreateditaswellasthetimethefilewas
created.Thedictionaryfileisnotrequired,butisrecommended.Withouta
dictionaryfile,theequivalentSQLstatementswilluseOracleinternalobject
IDsfortheobjectnameandpresentcolumnvaluesashexdata.
Forexample,insteadoftheSQLstatement:
INSERTINTOemp(name,salary)VALUES('JohnDoe',50000);
LogMinerwilldisplay:
insertintoObject#2581(col#1,col#2)values(hextoraw('4a6f686e20446f65'),
hextoraw('c306'));"
Createadictionaryfilebymountingadatabaseandthenextractingdictionary
informationintoanexternalfile.
Youmustcreatethedictionaryfilefromthesamedatabasethatgeneratedthe
logfilesyouwanttoanalyze.Oncecreated,youcanusethedictionaryfile
toanalyzeredologs.
Whencreatingthedictionary,specifythefollowing:
*DICTIONARY_FILENAMEtonamethedictionaryfile.
*DICTIONARY_LOCATIONtospecifythelocationofthefile.
LogMineranalyzesredologfilesfromanyversion8.0.xandlaterOracle
databasethatusesthesamedatabasecharactersetandisrunningonthesame
hardwareastheanalyzinginstance.
Note:TheLogMinerpackagesareownedbytheSYSschema.Therefore,ifyou
arenotconnectedasuserSYS,youmustincludeSYSinyourcall.For
example:
EXECUTESYS.DBMS_LOGMNR_D.BUILD
ToCreateaDictionaryFileonanOracle8Database:
===================================================
AlthoughLogMineronlyrunsondatabasesofrelease8.1orhigher,youcan
useittoanalyzeredologsfromrelease8.0databases.
1.UseanO/Scommandtocopythedbmslmd.sqlscript,whichiscontainedinthe
$ORACLE_HOME/rdbms/admindirectoryontheOracle8idatabase,tothesame
directoryintheOracle8database.
Forexample,enter:
%cp/8.1/oracle/rdbms/admin/dbmslmd.sql/8.0/oracle/rdbms/admin/dbmslmd.sql
Note:In8.1.5thescriptisdbmslogmnrd.sql.
In8.1.6thescriptisdbmslmd.sql.
2.UseSQL*Plustomountandthenopenthedatabasewhosefilesyouwantto
analyze.Forexample,enter:
STARTUP
3.Executethecopieddbmslmd.sqlscriptonthe8.0databasetocreatethe
DBMS_LOGMNR_Dpackage.
Forexample,enter:@dbmslmd.sql
4.MakesuretospecifyanexistingdirectorythatOraclehaspermissions
towritetobythePL/SQLprocedurebysettingtheinitialization
parameterUTL_FILE_DIRintheinit.ora.
Forexample,setthefollowingtouse/8.0/oracle/logs:
UTL_FILE_DIR=/8.0/oracle/logs
BesuretoshutdownandrestarttheinstanceafteraddingUTL_FILE_DIR
totheinit.ora.
Ifyoudonotreferencethisparameter,theprocedurewillfail.
5.ExecutethePL/SQLprocedureDBMS_LOGMNR_D.BUILD.Specifybothafilename
forthedictionaryandadirectorypathnameforthefile.Thisprocedure
createsthedictionaryfile,whichyoushouldusetoanalyzelogfiles.
Forexample,enterthefollowingtocreatefiledictionary.orain
/8.0/oracle/logs:
(REMEMBERTOINCULDETHEDASH'-'CONTINUATIONCHARACTERATTHEENDOF
EACHLINEWHENENTERINGAMULTI-LINEPL/SQLCOMMANDINSQL*PLUS)
EXECUTEDBMS_LOGMNR_D.BUILD(-
DICTIONARY_FILENAME=>'dictionary.ora',-
DICTIONARY_LOCATION=>'/8.0/oracle/logs');
AftercreatingthedictionaryfileontheOracle8.0.xinstance,the
dictionaryfileandanyarchivedlogstobeminedmustbemovedtothe
serverrunningthe8.1.xdatabaseonwhichLogMinerwillberunifitis
differentfromtheserverwhichgeneratedthearchivedlogs.
ToCreateaDictionaryFileonanOracle8iDatabase:
====================================================
1.MakesuretospecifyanexistingdirectorythatOraclehaspermissions
towritetobythePL/SQLprocedurebysettingtheinitialization
parameterUTL_FILE_DIRintheinit.ora.
Forexample,setthefollowingtouse/oracle/logs:
UTL_FILE_DIR=/oracle/logs
BesuretoshutdownandrestarttheinstanceafteraddingUTL_FILE_DIR
totheinit.ora.
Ifyoudonotreferencethisparameter,theprocedurewillfail.
2.UseSQL*Plustomountandthenopenthedatabasewhosefilesyouwantto
analyze.Forexample,enter:
STARTUP
3.ExecutethePL/SQLprocedureDBMS_LOGMNR_D.BUILD.Specifybothafilename
forthedictionaryandadirectorypathnameforthefile.Thisprocedure
createsthedictionaryfile,whichyoushouldusetoanalyzelogfiles.
Forexample,enterthefollowingtocreatefiledictionary.orain
/oracle/logs:
(REMEMBERTOINCULDETHEDASH'-'CONTINUATIONCHARACTERATTHEENDOF
EACHLINEWHENENTERINGAMULTI-LINEPL/SQLCOMMANDINSQL*PLUS)
EXECUTEDBMS_LOGMNR_D.BUILD(-
DICTIONARY_FILENAME=>'dictionary.ora',-
DICTIONARY_LOCATION=>'/oracle/logs');
ToCreateaDictionaryontheOracleDatabase(9iandlater)
====================================================
Inthe9iandlaterreleases,theabilitytoextractthedictionarytoaflatfileaswellascreatingadictionarywiththeredologsisavailable.
Forexample,enterthefollowingtocreatethefiledictionary.orain/oracle/database:
1.MakesuretospecifyanexistingdirectorythatOraclehaspermissions
towritetobythePL/SQLprocedurebysettingtheinitialization
parameterUTL_FILE_DIRintheinit.ora.
Forexample,setthefollowingtouse/oracle/logs:
UTL_FILE_DIR=/oracle/database
BesuretoshutdownandrestarttheinstanceafteraddingUTL_FILE_DIRtotheinitorspfile.
Ifyoudonotreferencethisparameter,theprocedurewillfail.
2.UseSQL*Plustomountandthenopenthedatabasewhosefilesyouwantto
analyze.Forexample,enter:
STARTUP
3.ExecutethePL/SQLprocedureDBMS_LOGMNR_D.BUILD.Specifybothafilename
forthedictionaryandadirectorypathnameforthefile.Thisprocedure
createsthedictionaryfile,whichyoushouldusetoanalyzelogfiles.
Forexample,enterthefollowingtocreatefiledictionary.orain
'/oracle/database/:
Example:
-------------
SQL>EXECUTEDBMS_LOGMNR_D.BUILD('dictionary.ora',-
2'/oracle/database/',-
3OPTIONS=>DBMS_LOGMNR_D.STORE_IN_FLAT_FILE);
Ifextractingthedatabasedictionaryinformationtotheredologs,usetheDBMS_LOGMNR_D.BUILDprocedurewiththeSTORE_IN_REDO_FILESoptionanddonotspecifyafilenameorlocation.
Example:
-------------
SQL>EXECUTEDBMS_LOGMNR_D.BUILD(-
2OPTIONS=>DBMS_LOGMNR_D.STORE_IN_REDO_LOGS);
Pleasenotethattoextractadictionarytotheredologs,thedatabasemustbeopenandinARCHIVELOGmodeandarchivingmustbeenabled
Alsotomakesurethattheredologscontaininformationthatwillprovidethemostvaluetoyou,youshouldenableatleastminimalsupplementallogging.
SQL>ALTERDATABASEADDSUPPLEMENTALLOGDATA
SpecifyingRedoLogsforAnalysis
=================================
Onceyouhavecreatedadictionaryfile,youcanbeginanalyzingredologs.
Yourfirststepistospecifythelogfilesthatyouwanttoanalyzeusing
theADD_LOGFILEprocedure.Usethefollowingconstants:
*NEWtocreateanewlist.
*ADDFILEtoaddredologstoalist.
*REMOVEFILEtoremoveredologsfromthelist.
ToUseLogMiner:
1.UseSQL*PlustostartanOracleinstance,withthedatabaseeithermounted
orunmounted.
Forexample,enter:
STARTUP
2.CreatealistoflogsbyspecifyingtheNEWoptionwhenexecutingthe
DBMS_LOGMNR.ADD_LOGFILEprocedure.Forexample,enterthefollowingto
specify/oracle/logs/log1.f:
(INCLUDETHE'-'WHENENTERINGTHEFOLLOWING)
EXECUTEDBMS_LOGMNR.ADD_LOGFILE(-
LOGFILENAME=>'/oracle/logs/log1.f',-
OPTIONS=>dbms_logmnr.NEW);
3.Ifdesired,addmorelogsbyspecifyingtheADDFILEoption.
Forexample,enterthefollowingtoadd/oracle/logs/log2.f:
(INCLUDETHE'-'WHENENTERINGTHEFOLLOWING)
EXECUTEDBMS_LOGMNR.ADD_LOGFILE(-
LOGFILENAME=>'/oracle/logs/log2.f',-
OPTIONS=>dbms_logmnr.ADDFILE);
4.Ifdesired,removelogsbyspecifyingtheREMOVEFILEoption.
Forexample,enterthefollowingtoremove/oracle/logs/log2.f:
(INCLUDETHE'-'WHENENTERINGTHEFOLLOWING)
EXECUTEDBMS_LOGMNR.ADD_LOGFILE(-
LOGFILENAME=>'/oracle/logs/log2.f',-
OPTIONS=>dbms_logmnr.REMOVEFILE);
UsingLogMiner:
===============
Onceyouhavecreatedadictionaryfileandspecifiedwhichlogstoanalyze,
youcanstartLogMinerandbeginyouranalysis.Usethefollowingoptionsto
narrowtherangeofyoursearchatstarttime:
ThisoptionSpecifies
====================
STARTSCNThebeginningofanSCNrange.
ENDSCNTheterminationofanSCNrange.
STARTTIMEThebeginningofatimeinterval.
ENDTIMETheendofatimeinterval.
DICTFILENAMEThenameofthedictionaryfile.
OnceyouhavestartedLogMiner,youcanmakeuseofthefollowingdata
dictionaryviewsforanalysis:
ThisviewDisplaysinformationabout
=====================================================================
V$LOGMNR_DICTIONARYThedictionaryfileinuse.
V$LOGMNR_PARAMETERSCurrentparametersettingsforLogMiner.
V$LOGMNR_LOGSWhichredologfilesarebeinganalyzed.
V$LOGMNR_CONTENTSThecontentsoftheredologfilesbeinganalyzed.
ToUseLogMiner:
================
1.IssuetheDBMS_LOGMNR.START_LOGMNRproceduretostartLogMinerutility.
Forexample,ifusingtheonlinecatalogasyourdictionarysource,issue:
(INCLUDETHE'-'WHENENTERINGTHEFOLLOWING)
EXECUTEDBMS_LOGMNR.START_LOGMNR(-
OPTIONS=>DBMS_LOGMNR.DICT_FROM_ONLINE_CATALOG);
Ifusingadictionaryfile(e.g./oracle/dictionary.ora),youwouldissueissue:
EXECUTEDBMS_LOGMNR.START_LOGMNR(-
DICTFILENAME=>'/oracle/dictionary.ora');
Optionally,settheSTARTTIMEandENDTIMEparameterstofilterdatabytime.
Notethattheprocedureexpectsdatevalues:usetheTO_DATEfunctionto
specifydateandtime,asinthisexample:
(INCLUDETHE'-'WHENENTERINGTHEFOLLOWING)
EXECUTEDBMS_LOGMNR.START_LOGMNR(-
DICTFILENAME=>'/oracle/dictionary.ora',-
STARTTIME=>to_date('01-Jan-199808:30:00','DD-MON-YYYYHH:MI:SS'),-
ENDTIME=>to_date('01-Jan-199808:45:00','DD-MON-YYYYHH:MI:SS'));
UsetheSTARTSCNandENDSCNparameterstofilterdatabySCN,asinthis
example:
(INCLUDETHE'-'WHENENTERINGTHEFOLLOWING)
EXECUTEDBMS_LOGMNR.START_LOGMNR(-
DICTFILENAME=>'/oracle/dictionary.ora',-
STARTSCN=>100,-
ENDSCN=>150);
2.ViewtheoutputviatheV$LOGMNR_CONTENTStable.LogMinerreturnsallrows
inSCNorder,whichisthesameorderappliedinmediarecovery.
Forexample,thefollowingquerylistsinformationaboutoperations:
SELECToperation,sql_redoFROMv$logmnr_contents;
OPERATIONSQL_REDO
-------------------------------------------------------------------
INTERNAL
INTERNAL
STARTsettransactionreadwrite;
UPDATEupdateSYS.UNDO$setNAME='RS0',USER#=1,FILE#=1,BLOCK#=2450,SCNBAS=
COMMITcommit;
STARTsettransactionreadwrite;
UPDATEupdateSYS.UNDO$setNAME='RS0',USER#=1,FILE#=1,BLOCK#=2450,SCNBAS=
COMMITcommit;
STARTsettransactionreadwrite;
UPDATEupdateSYS.UNDO$setNAME='RS0',USER#=1,FILE#=1,BLOCK#=2450,SCNBAS=
COMMITcommit;
11rowsselected.
AnalyzingArchivedRedoLogFilesfromOtherDatabases:
=======================================================
YoucanrunLogMineronaninstanceofadatabasewhileanalyzingredolog
filesfromadifferentdatabase.Toanalyzearchivedredologfilesfromother
databases,
LogMinermust:
*Accessadictionaryfilethatisbothcreatedfromthesamedatabaseasthe
redologfilesandcreatedwiththesamedatabasecharacterset.
*Runonthesamehardwareplatformthatgeneratedthelogfiles,althoughit
doesnotneedtobeonthesamesystem.
*UseredologfilesthatcanbeappliedforrecoveryfromOracleversion8.0
andlater.
REFERENCES:
==========
<148616.1>-Oracle9iLogMinerNewFeatures
<249001.1>-Oracle10gNewFeaturesofLogMiner
<174504.1>-LogMiner-FrequentlyAskedQuestions(FAQ)
Related Products OracleDatabaseProducts>OracleDatabase>OracleDatabase>OracleServer-EnterpriseEdition OracleDatabaseProducts>OracleDatabase>OracleDatabase>OracleServer-StandardEdition Keywords
|
相关文章推荐
- 扩展方法用法及其原理和注意事项
- richface的配置、用法介绍和注意事项
- PHP中header函数的用法及其注意事项详解
- PHP header 函数的用法及其注意事项
- Android学习笔记- Application对象介绍、用法及注意事项
- Android:ListView.addHeaderView()用法及其注意事项
- PHP header 函数的用法及其注意事项
- vector.erase()用法介绍及注意事项;
- PHP中header函数的用法及其注意事项详解
- Android:ListView.addHeaderView()用法及其注意事项
- Android:ListView.addHeaderView()用法及其注意事项
- Android:ListView.addHeaderView()用法及其注意事项
- PHP header 函数的用法及其注意事项
- CTS、CTS-V、GTS版本更新,及其注意事项
- substring()的用法和注意事项
- PyCharm简单使用介绍及注意事项
- Erlang入门第二期:Erlang“记录”的用法及注意事项
- sql记录查询重复注意事项(经验提升),in的用法和效率
- 关于VML一些用法的注意事项
- 关于TabHost的用法以及注意事项