Oracle LogMiner实践记录

Posted Airsolstice

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Oracle LogMiner实践记录相关的知识,希望对你有一定的参考价值。

1、longminer的环境配置

https://www.cnblogs.com/shishanyuan/p/3140440.html

2、sqlplus中执行logminer的命令记录

//login

CONNECT DATAHUB/DATAHUB


//create table and insert data
CREATE TABLE "DATAHUB"."ORACDC"("ID" NUMBER(5),"NAME" VARCHAR2(10));   

INSERT INTO "DATAHUB"."ORACDC" ("ID", "NAME") VALUES (1, 'a');
INSERT INTO "DATAHUB"."ORACDC" ("ID", "NAME") VALUES (2, 'b');
INSERT INTO "DATAHUB"."ORACDC" ("ID", "NAME") VALUES (3, 'c');
INSERT INTO "DATAHUB"."ORACDC" ("ID", "NAME") VALUES (4, 'd');
INSERT INTO "DATAHUB"."ORACDC" ("ID", "NAME") VALUES (5, 'e');
INSERT INTO "DATAHUB"."ORACDC" ("ID", "NAME") VALUES (6, 'f');
INSERT INTO "DATAHUB"."ORACDC" ("ID", "NAME") VALUES (7, 'g');
INSERT INTO "DATAHUB"."ORACDC" ("ID", "NAME") VALUES (8, 'h');
INSERT INTO "DATAHUB"."ORACDC" ("ID", "NAME") VALUES (9, 'i');
INSERT INTO "DATAHUB"."ORACDC" ("ID", "NAME") VALUES (10, 'g');
INSERT INTO "DATAHUB"."ORACDC" ("ID", "NAME") VALUES (11, 'k');
INSERT INTO "DATAHUB"."ORACDC" ("ID", "NAME") VALUES (12, 'l');
INSERT INTO "DATAHUB"."ORACDC" ("ID", "NAME") VALUES (13, 'm');
INSERT INTO "DATAHUB"."ORACDC" ("ID", "NAME") VALUES (14, 'n');
INSERT INTO "DATAHUB"."ORACDC" ("ID", "NAME") VALUES (15, 'o');
INSERT INTO "DATAHUB"."ORACDC" ("ID", "NAME") VALUES (16, 'p');
INSERT INTO "DATAHUB"."ORACDC" ("ID", "NAME") VALUES (17, 'q');
INSERT INTO "DATAHUB"."ORACDC" ("ID", "NAME") VALUES (18, 'r');
INSERT INTO "DATAHUB"."ORACDC" ("ID", "NAME") VALUES (19, 's');
INSERT INTO "DATAHUB"."ORACDC" ("ID", "NAME") VALUES (20, 't');
INSERT INTO "DATAHUB"."ORACDC" ("ID", "NAME") VALUES (21, 'u');
INSERT INTO "DATAHUB"."ORACDC" ("ID", "NAME") VALUES (22, 'v');
INSERT INTO "DATAHUB"."ORACDC" ("ID", "NAME") VALUES (23, 'w');
INSERT INTO "DATAHUB"."ORACDC" ("ID", "NAME") VALUES (24, 'x');


//commit transation
COMMIT;


//rebuild dict.ora
EXECUTE dbms_logmnr_d.build(dictionary_filename => 'dict.ora', dictionary_location =>'/data/oracle/dict');
//set model redolog
EXECUTE DBMS_LOGMNR_D.BUILD(OPTIONS=> DBMS_LOGMNR_D.STORE_IN_REDO_LOGS);


//list log info
select group#, sequence#, bytes, members, status from v$log;
//add redolog file to logminer
EXEC dbms_logmnr.add_logfile('/data/oracle/oradata/ora11/redo01.log');
EXEC dbms_logmnr.add_logfile('/data/oracle/oradata/ora11/redo02.log');
EXEC dbms_logmnr.add_logfile('/data/oracle/oradata/ora11/redo03.log');
//add archivelog file to logminer
EXEC dbms_logmnr.add_logfile('/home/oracle/2018_01_15/o1_mf_1_5_f5rvv949_.arc');


//execute logminer for analyzing log
EXECUTE DBMS_LOGMNR.START_LOGMNR(OPTIONS => DBMS_LOGMNR.DICT_FROM_ONLINE_CATALOG);


//1.execute logminer for analyzing log
EXEC dbms_logmnr.start_logmnr(OPTIONS => DBMS_LOGMNR.DICT_FROM_ONLINE_CATALOG + DBMS_LOGMNR.CONTINUOUS_MINE + DBMS_LOGMNR.NO_SQL_DELIMITER);


//2.execute logminer for analyzing log
EXEC DBMS_LOGMNR.START_LOGMNR( STARTSCN => 989960, ENDSCN => 3004680, OPTIONS => DBMS_LOGMNR.DICT_FROM_ONLINE_CATALOG + DBMS_LOGMNR.CONTINUOUS_MINE + DBMS_LOGMNR.NO_SQL_DELIMITER);


//3.execute logminer for analyzing log
EXEC DBMS_LOGMNR.START_LOGMNR( STARTTIME => to_date('2018-03-06 16:00:00','YYYY-MM-DD HH24:MI:SS'), ENDTIME => to_date('2018-03-06 16:40:00','YYYY-MM-DD HH24:MI:SS'), OPTIONS => DBMS_LOGMNR.DICT_FROM_ONLINE_CATALOG + DBMS_LOGMNR.CONTINUOUS_MINE + DBMS_LOGMNR.NO_SQL_DELIMITER);


//list result
select * from v$logmnr_contents;
select sql_redo,username,timestamp,sql_undo from v$logmnr_contents;


//list result by conditions
SELECT sql_redo FROM v$logmnr_contents WHERE username='datahub' AND table_name='ORACDC';
SELECT sql_redo FROM v$logmnr_contents WHERE table_name='ORACDC';


//close logminer 

EXEC dbms_logmnr.end_logmnr;



3、Oralce中归档内存空间管理

connect datahub/datahub as sysdba
startup mount
select * from v$log;
select v1.group#, member, sequence#, first_change# from v$log v1, v$logfile v2 where v1.group# = v2.group#;
recover database until cancel;
recover database until time '2018-03-05 10:20:00';
alter database open resetlogs;


archive log list;
show parameter db_recover;


//查看归档区大小
select * from V$FLASH_RECOVERY_AREA_USAGE;


//修改恢复区大小
alter system set db_recovery_file_dest_size=1G;


//修改恢复区位置,默认有大小限制,自定义的地方无
alter system set log_archive_dest='location=/data/oracle/arch';


//删除前7天的归档文件,在rman中删除后,需要在对应路径下手动删除这些文件
rman>delete noprompt archivelog all completed before 'sysdate-7';
rman>delete noprompt archivelog until time 'sysdate - 7';


//切换redolog文件
alter system switch logfile;


//手动归档文件
alter system archive log current;


//手动清除无法归档的redolog文件
alter database clear unarchived logfile group 1;


//设置归档文件的路径
alter system set log_archive_dest_1='location=/data/oracle/arch/archive_log' scope=both

//相关链接

https://www.linuxidc.com/Linux/2014-01/95111.html

http://blog.csdn.net/qq_34556414/article/details/78913654


以上是关于Oracle LogMiner实践记录的主要内容,如果未能解决你的问题,请参考以下文章

Oracle Logminer 分析重做日志RedoLog和归档日志ArchiveLog

Oracle LogMiner日志挖掘技术_超越OCP精通Oracle视频课程培训21

LogMiner的使用

oracle logminer探索

实战篇:LogMiner 分析数据泵导入参数 TABLE_EXISTS_ACTION 的秘密

实战篇:LogMiner 分析数据泵导入参数 TABLE_EXISTS_ACTION 的秘密