问题描述
通过test用户使用toad连到数据库做的一些操作,最下面是sys用户通过sqlplus连到数据库进行日志挖掘。(中间我把4个redolog拷贝到了对应/tmp路径下) 问题:不管我加不加这个scn范围 都无法搜寻到上图对test的的操作! 上图是开启附加日志后的操作,我觉得开不开启附加日志都应该能搜寻的到吧? (不晓得是否开启正确,附最后一个截图),难道不能挖掘在线日志么?
专家解答
logmnr可以挖在线日志的,都不需要拷贝到其他地方,add的时候直接写在线日志的路径,我怀疑是你在操作系统拷贝文件的时候,文件还没有刷新。
可以在commit后,尝试checkpoint和switch logfile一下。
挖掘完成后查询v$logmnr_contents视图是否有数据,最大SCN到哪里了,对比下是否和操作时间一直。
另外,要清空v$logmnr_contents重新挖掘分析才是最新的数据,一旦加载到v$logmnr_contents就不会变了。
参考我刚才在测试环境做的示例。
设置utl_file_dir参数重启
SQL> !mkdir -p /oracle/logmnr SQL> alter system set utl_file_dir='/oracle/logmnr' scope=spfile; System altered. SQL> startup force
创建测试账号和表并做相关DML
SQL> create user steven identified by oracle; User created. SQL> grant dba to steven; Grant succeeded. SQL> conn steven/oracle; Connected. SQL> create table test (id number,serial# number); Table created. SQL> select CURRENT_SCN from v$database; CURRENT_SCN -------------------- 2425305 SQL> insert into test values(1,2); 1 row created. SQL> insert into test values(3,4); 1 row created. SQL> update test set id=100 where id=1; 1 row updated. SQL> delete from test where id=3; 1 row deleted. SQL> select * from test; ID SERIAL# ---------- ---------- 100 2 SQL> commit; Commit complete. SQL> select CURRENT_SCN from v$database; CURRENT_SCN -------------------- 2425339 SQL> alter system checkpoint; System altered. SQL> alter system switch logfile; System altered. SQL> select member from v$logfile; MEMBER -------------------------------------------------- /oracle/oradata/ora11g/redo03.log /oracle/oradata/ora11g/redo02.log /oracle/oradata/ora11g/redo01.log
创建字典并添加redo
SQL> exec dbms_logmnr_d.build('dictionary.ora','/oracle/logmnr'); PL/SQL procedure successfully completed. SQL> exec dbms_logmnr.add_logfile(LogFileName=>'/oracle/oradata/ora11g/redo01.log',Options=>dbms_logmnr.new); PL/SQL procedure successfully completed. SQL> exec dbms_logmnr.add_logfile(LogFileName=>'/oracle/oradata/ora11g/redo02.log',Options=>dbms_logmnr.addfile); PL/SQL procedure successfully completed. SQL> exec dbms_logmnr.add_logfile(LogFileName=>'/oracle/oradata/ora11g/redo03.log',Options=>dbms_logmnr.addfile); PL/SQL procedure successfully completed.
开始挖掘
SQL> exec dbms_logmnr.start_logmnr(dictfilename=>'/oracle/logmnr/dictionary.ora'); PL/SQL procedure successfully completed.
查看数据
SQL> select count(*) from v$logmnr_contents; COUNT(*) ---------- 984 SQL> select OPERATION,SQL_REDO,SQL_UNDO from v$logmnr_contents where TABLE_NAME='TEST'; OPERATION -------------------------------- SQL_REDO ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- SQL_UNDO ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- DDL create table test (id number,serial# number); INSERT insert into "STEVEN"."TEST"("ID","SERIAL#") values ('1','2'); delete from "STEVEN"."TEST" where "ID" = '1' and "SERIAL#" = '2' and ROWID = 'AAAWrLAAEAAAACvAAA'; INSERT insert into "STEVEN"."TEST"("ID","SERIAL#") values ('3','4'); delete from "STEVEN"."TEST" where "ID" = '3' and "SERIAL#" = '4' and ROWID = 'AAAWrLAAEAAAACvAAB'; UNSUPPORTED Unsupported Unsupported UNSUPPORTED Unsupported Unsupported DELETE delete from "STEVEN"."TEST" where "ID" = '3' and "SERIAL#" = '4' and ROWID = 'AAAWrLAAEAAAACvAAB'; insert into "STEVEN"."TEST"("ID","SERIAL#") values ('3','4'); 6 rows selected.
最后修改时间:2019-04-12 14:33:52
「喜欢这篇文章,您的关注和赞赏是给作者最好的鼓励」
关注作者
【版权声明】本文为墨天轮用户原创内容,转载时必须标注文章的来源(墨天轮),文章链接,文章作者等基本信息,否则作者和墨天轮有权追究责任。如果您发现墨天轮中有涉嫌抄袭或者侵权的内容,欢迎发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。