Home > Database > Mysql Tutorial > body text

Oracle的日志挖掘

WBOY
Release: 2016-06-07 17:06:01
Original
762 people have browsed it

Oracle日志挖掘(LogMnr) ①在参数文件中设置utl_file_dir路径 ②重启 ③创建directory file,使用execute dbms_

  Oracle日志挖掘(LogMnr)

  ①在参数文件中设置utl_file_dir路径

  ②重启

  ③创建directory file,使用execute dbms_logmnr_d.build()

  ④添加日志文件,使用dbms_logmnr.add_logfile

  或删除日志文件,使用dbms_logmnr.removefile

  ⑤启动logmnr,使用dbms_logmnr.start_logmnr

  ⑥查询,使用V$logmnr_contents(sqlredo/sqlundo)

  设置utl_file_dir目录。

  alter system set utl_file_dir='D:\app\Leo\utl_file_dir' scope=spfile;

  建立日志挖掘的数据字典。

  execute dbms_logmnr_d.build('shwdict.ora','D:\app\Leo\utl_file_dir'); //第二个参数要与参数utl_file_dir的设置完全匹配。

  无此包,则需执行@d:\oracle\ora8\rdbms\admin\dbmslmd.sql;

  创建分析的文件列表(可以是在线或归档日志)

  execute dbms_logmnr.add_logfile('D:\app\Leo\archivelog1\ARC00011_0720116156.001',dbms_logmnr.new);

  execute dbms_logmnr.add_logfile('D:\app\Leo\archivelog1\ARC00012_0720116156.001',dbms_logmnr.addfile);

  execute dbms_logmnr.add_logfile('D:\app\Leo\archivelog1\ARC00013_0720116156.001',dbms_logmnr.addfile);

  option:new-创建一个新的日志列表。addfile-向列表中添加日志文件。

  remove_logfile-删除。

  在视图v$logmnr_logs中可以看到添加的日志列表。

  select log_id,filename from v$logmnr_logs;

  开始分析

  execute dbms_logmnr.start_logmnr(dictfilename=>'D:\app\Leo\utl_file_dir\shwdict.ora');

  execute dbms_logmnr.start_logmnr(dictfilename=>'d:\oracle\shwdict.ora',startscn=>xxxxxx,endscn=>xxxxx,starttime=>to_date('20030501 12:15:00','yyyymmdd hh24:mi:ss'), endtime=>to_date('20030501 15:40:30','yyyymmdd hh24:mi:ss'));

  没有建立数据字典,使用dbms_logmnr.dict_from_online_catalog选项参数,则logminer期望在所指定的dbms_logmnr.add_logfile或重做日志中找到数据字典。

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

  查询分析内容

  select to_char(timestamp,'yyyy-mm-dd hh24:mi:ss') time,sql_redo from v$logmnr_contents where seg_owner='SCOTT';

  结束分析

  execute dbms_logmnr.end_logmnr;

  部分日志归档不出的解决

  ①将数据库至于force logging模式

  alter database force logging;

  select force_logging from v$database;

  ②查看表是否处于归档模式

  select table_name,logging from user_tables;

  ③查看数据库是否处于启用了补充日志(启动了,则每条update写redo时会附加列值唯一信息)

  SQL> select supplemental_log_data_pk,supplemental_log_data_ui from v$database;

  SUPPLEMENTAL_LOG_DATA_PK SUPPLEMENTAL_LOG_DATA_UI

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

  NO NO

  SQL> alter database add supplemental log data (primary key,unique index) columns;

  Database altered

  SQL> select supplemental_log_data_pk,supplemental_log_data_ui from v$database;

  SUPPLEMENTAL_LOG_DATA_PK SUPPLEMENTAL_LOG_DATA_UI

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

  YES YES

linux

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!