Oracle 日志挖掘

oracle 11g 日志挖掘测试

需要开启补充日志

alter database add supplemental log data;
SELECT SUPPLEMENTAL_LOG_DATA_MIN, SUPPLEMENTAL_LOG_DATA_PK, SUPPLEMENTAL_LOG_DATA_UI
FROM V$DATABASE;

在用户下执行一些删除,插入等操作

SQL> create table zxy( a int);

Table created.
SQL> insert into zxy values (2);

1 row created.

SQL> insert into zxy values (3);

1 row created.
SQL>  delete from zxy where a=2;

1 row deleted.

SQL> commit;

Commit complete.


手动切换下日志

SQL> alter system switch logfile;

System altered.

找到该段时间的归档文件
-rw-r----- 1 oracle oinstall   3823104 Jun  7 16:07 1_430_1119886393.dbf

日志挖掘

1. 增加需要分析的归档日志,可以一直增加:
exec sys.dbms_logmnr.add_logfile(LogFileName=>'/u01/app/oracle/fast_recovery_area/DBOGG/archivelog/1_430_1119886393.dbf',options => dbms_logmnr.new);

增加多个日志
exec sys.dbms_logmnr.add_logfile(LogFileName=>'/u01/app/oracle/fast_recovery_area/DBOGG/archivelog/1_429_1119886393.dbf',options => dbms_logmnr.addfile);

2. 查看是否增加成功
SQL> select filename from v$logmnr_logs;

FILENAME
--------------------------------------------------------------------------------
/u01/app/oracle/fast_recovery_area/DBOGG/archivelog/1_430_1119886393.dbf

3. 开始日志挖掘:
exec sys.dbms_logmnr.start_logmnr( options => sys.dbms_logmnr.dict_from_online_catalog);

4. 把挖掘到的内容,按需求过滤,存到一张临时表:
create table tmp_logmnr as select * from v$logmnr_contents where seg_name='ZXY';

5. 关闭日志挖掘:
exec sys.dbms_logmnr.end_logmnr;

6. 查看挖掘到的信息:
select TIMESTAMP,OPERATION,USERNAME,SQL_REDO,MACHINE_NAME from tmp_logmnr where TABLE_NAME='ZXY';
TIMESTAMP		OPERATION			 USERNAME			SQL_REDO		       MACHINE_NAME
----------------------- -------------------------------- ------------------------------ ------------------------------ --------------------
07-JUN-2024 16:04:25	DDL				 TEST				create table zxy( a int);      zhang3
07-JUN-2024 16:05:14	INSERT				 TEST				insert into "TEST"."ZXY"("A")  zhang3
											values ('2');

07-JUN-2024 16:05:24	INSERT				 TEST				insert into "TEST"."ZXY"("A")  zhang3
											values ('3');

07-JUN-2024 16:06:29	DELETE				 TEST				delete from "TEST"."ZXY" where zhang3
											 "A" = '2' and ROWID = 'AAAV8H
											AAHAAAFVbAAA';

select * from tmp_logmnr where;

查询是否存在LOGMNR使用的session
SELECT COUNT(*) from v$LOGMNR_SESSION;

相关推荐

  1. Oracle 日志挖掘

    2024-06-11 04:32:02       49 阅读
  2. oracle归档日志清理

    2024-06-11 04:32:02       47 阅读
  3. Oracle数据库日志文件

    2024-06-11 04:32:02       49 阅读
  4. Oracle联机日志文件管理

    2024-06-11 04:32:02       44 阅读
  5. oracle 归档日志删除策略

    2024-06-11 04:32:02       37 阅读

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2024-06-11 04:32:02       172 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2024-06-11 04:32:02       190 阅读
  3. 在Django里面运行非项目文件

    2024-06-11 04:32:02       158 阅读
  4. Python语言-面向对象

    2024-06-11 04:32:02       171 阅读

热门阅读

  1. 13_1 Linux 邮件服务与NTP时间服务

    2024-06-11 04:32:02       39 阅读
  2. C++线程

    2024-06-11 04:32:02       42 阅读
  3. HOT100与剑指Offer

    2024-06-11 04:32:02       50 阅读
  4. 游戏心理学Day10

    2024-06-11 04:32:02       38 阅读
  5. 使用EFCore和Linq查询语句封装复杂的查询结果

    2024-06-11 04:32:02       55 阅读
  6. Python爬虫实现“自动重试”机制的方法(1)

    2024-06-11 04:32:02       33 阅读
  7. OpenAI 发布的 GPT-4o是什么,有什么功能?

    2024-06-11 04:32:02       55 阅读