|
- --------1、安装
- --设置
- --以SYS用户执行下面两个脚本
- cd $ORACLE_HOME/rdbms/admin/ 用来创建DBMS_LOGMNR包
- SQL> @dbmslm.sql
- cd $ORACLE_HOME/rdbms/admin/ 用来创建数据字典文件。
- SQL> @dbmslmd.sql
- ---------2、sys用户运行脚本,创建数据字典文件 使用平面文件创建数据字典
- ---在线数据字典(这步可以跳过)
- SQL> execute dbms_logmnr_d.build('testtrace.ora', '/tmp',options =>dbms_logmnr_d.store_in_flat_file);
- --ORA-01308: initialization parameter utl_file_dir is not set--
- alter system set utl_file_dir='/tmp' scope=spfile;
- shutdown immediate
- startup
- --------------------------------------------------------------
- ------------3建立日志分析表,使用dbms_logmnr.add_logfile()
- ---第一个文件
- SQL> execute dbms_logmnr.add_logfile(options =>dbms_logmnr.new,logfilename=>'/opt/oracle/oradata/ora9i/archive/1_98225_669562928.dbf');
- ---增加文件
- execute dbms_logmnr.add_logfile(options =>dbms_logmnr.addfile,logfilename=>'/opt/oracle/oradata/ora9i/archive/1_98225_669562928.dbf');
- ----删除文件
- SQL> execute dbms_logmnr.add_logfile(options =>dbms_logmnr.removefile,logfilename=>'/opt/oracle/oradata/ora9i/archive/1_98225_669562928.dbf');
- ---查找文件
- select filename from v$logmnr_logs;
- -------4启动LogMiner进行分析。
- ----加时间
- SQL> execute dbms_logmnr.start_logmnr(dictfilename =>'/opt/oracle/testtrace.ora',starttime =>to_date-('20071031 09:00:00','yyyymmdd hh24:mi:ss'),endtime =>to_date('20071031 12:00:00','yyyymmdd-hh24:mi:ss'));
- ----加scn
- SQL> execute dbms_logmnr.start_logmnr(dictfilename =>'/opt/oracle/testtrace.ora',StartScn=>1111,EndScn=.222);
- ---无限制
- SQL> execute dbms_logmnr.start_logmnr(dictfilename =>'/tmp/testtrace.ora');
- ---在线数据字典(此步骤不用重启,生成数据字典)
- SQL> execute dbms_logmnr.start_logmnr(options=>dbms_logmnr.dict_from_online_catalog);
- ------5查看记录
- SELECT USERNAME,SQL_REDO,SQL_UNDO FROM
- V$LOGMNR_CONTENTS WHERE USERNAME='CHF'
- AND OPERATION<>'INSERT';
- ---建立表
- create table logmnr1 tablespace USERS_NEW
- nologging
- as select * from
- V$LOGMNR_CONTENTS;
- -----6、结束
- SQL> exec dbms_logmnr.end_logmnr
复制代码 |
|