logminer存储在外部文件(external file)
环境:
OS:Centos 7
DB:11.2.0.4 2节点RAC
logminer与db在同一台机器上
1.设置utl_file_dir参数
修改参数,两个节点都会设置同样的,下面的步骤在2个节点上都可以执行的
alter system set utl_file_dir='/home/oracle' sid='*' scope=spfile;
重启数据库
su - grid
srvctl stop database -d slnngk
srvctl start database -d slnngk
2.创建数据字典
declare begin dbms_logmnr_d.build('dictionary.ora','/home/oracle', options => dbms_logmnr_d.store_in_flat_file); end;
3.添加需要分析的文件
declare begin dbms_logmnr.add_logfile('+DATA/slnngk/archivelog/2021_10_11/thread_1_seq_166.540.1085626067',dbms_logmnr.new); end; declare begin dbms_logmnr.ADDFILE('+RECOC1/dbm01/archivelog/2017_09_13/thread_2_seq_809.1076.954602483',dbms_logmnr.addfile); end;
4.开始分析日志文件
declare
begin
dbms_logmnr.start_logmnr(dictfilename=>'/home/oracle/dictionary.ora',Options=>0);
end;
5.查看
select * from v$logmnr_contents where lower(sql_redo) like '%tb_ff%'
6.结束分析
declare
begin
dbms_logmnr.end_logmnr;
end;
7.若要分析其他数据库的归档日志,需要修改字典文件的dbid
vi /home/oracle/dictionary.ora
INSERT_INTO DICTIONARY_TABLE VALUES ('SLNNGK',1510119012,'09/08/2021 06:00:33','10/11/2021 22:29:58',925702,'09/08/2021 06:00:35','09/08/2021 06:00:33','','','ZHS16GBK','11.2.
0.4.0','Production',88498,86354,1924664,,1931385,0);
红色部分为其他数据库的dbid
然后使用如下方式分析
declare begin dbms_logmnr.start_logmnr(DictFileName=>'/home/oracle/dict.ora'); end;