1. 找到相关时段归档文件
2. 导出生产库的数据字典
3. 传送到测试库上,挖掘
4. 将结果告知客户
-
生产库上:
-
-
找到所需的归档日志
-
col name for a50
-
set pages 100 lin 120
-
select thread#,sequence#,name,to_char(completion_time,'yyyy-mm-dd hh24:mi:ss')riqi from v$archived_log where dest_id=1 and completion_time>sysdate-1 order by 1,2;
-
-
创建数据字典
-
CREATE DIRECTORY my_dictionary_dir AS '/u01/app/oracle/oradata';
-
EXECUTE dbms_logmnr_d.build( DICTIONARY_FILENAME=>'dictionary.ora', DICTIONARY_LOCATION=>'MY_DICTIONARY_DIR', options => dbms_logmnr_d.store_in_flat_file);
-
-
将归档文件和数据字典scp到测试库上/home/oracle目录下
-
-
测试库上:
-
-
EXECUTE DBMS_LOGMNR.ADD_LOGFILE( LOGFILENAME => '/home/oracle/1_42_1088407163.dbf', OPTIONS => DBMS_LOGMNR.NEW);
-
EXECUTE DBMS_LOGMNR.ADD_LOGFILE( LOGFILENAME => '/home/oracle/1_43_1088407163.dbf', OPTIONS => DBMS_LOGMNR.ADDFILE);
-
EXECUTE DBMS_LOGMNR.ADD_LOGFILE( LOGFILENAME => '/home/oracle/2_35_1088407163.dbf', OPTIONS => DBMS_LOGMNR.ADDFILE);
-
EXECUTE DBMS_LOGMNR.ADD_LOGFILE( LOGFILENAME => '/home/oracle/2_36_1088407163.dbf', OPTIONS => DBMS_LOGMNR.ADDFILE);
-
-
ALTER SESSION SET NLS_DATE_FORMAT = 'YYYY-mm-dd HH24:MI:SS';
-
-
EXECUTE DBMS_LOGMNR.START_LOGMNR( -
-
DICTFILENAME => '/home/oracle/dictionary.ora', -
-
STARTTIME => '2021-11-24 00:59:53', -
-
ENDTIME => '2021-11-24 06:59:53'-
-
);
-
-- create table logminer1 tablespace users as
-
SELECT username AS USR, (XIDUSN || '.' || XIDSLT || '.' || XIDSQN) AS XID, SQL_REDO, SQL_UNDO FROM V$LOGMNR_CONTENTS where SEG_OWNER='A';
-
-
EXECUTE DBMS_LOGMNR.end_logmnr;
-