本步使oracle具有logminer分析能力加载utl_file_dir参数和生成dbms_logmnr_d.build 数据字典
SQL*Plus: Release 9.2.0.4.0 - Production on Fri Nov 26 10:08:10 2004
Copyright (c) 1982, 2002, Oracle Corporation. All rights reserved.
SQL> connect / as sysdba
Connected to an idle instance.
SQL> startup
ORACLE instance started.
Total System Global Area 236000356 bytes
Fixed Size 451684 bytes
Variable Size 201326592 bytes
Database Buffers 33554432 bytes
Redo Buffers 667648 bytes
Database mounted.
Database opened.
SQL> alter system set utl_file_dir='/oraclebackup'; #没有加scope=spfile参数导致error
alter system set utl_file_dir='/oraclebackup'
*
ERROR at line 1:
ORA-02095: specified initialization parameter cannot be modified
SQL> alter system set utl_file_dir = '/oraclebackup' scope=spfile;
System altered.
SQL> shutdown
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> exit
Disconnected from Oracle9i Enterprise Edition Release 9.2.0.4.0 - Production
With the Partitioning, OLAP and Oracle Data Mining options
JServer Release 9.2.0.4.0 - Production
[oracle@test7 dbs]$ sqlplus /nolog
SQL*Plus: Release 9.2.0.4.0 - Production on Fri Nov 26 10:52:49 2004
Copyright (c) 1982, 2002, Oracle Corporation. All rights reserved.
SQL> connect / as sysdba
Connected to an idle instance.
SQL> startup
ORACLE instance started.
Total System Global Area 236000356 bytes
Fixed Size 451684 bytes
Variable Size 201326592 bytes
Database Buffers 33554432 bytes
Redo Buffers 667648 bytes
Database mounted.
Database opened.
SQL> execute dbms_logmnr_d.build('szdb7.ora',/oraclebackup'); #少打了一个’号的原因
ERROR:
ORA-01756: quoted string not properly terminated
SQL> execute dbms_logmnr_d.build ('szdb7.ora','/oraclebackup');
PL/SQL procedure successfully completed.
#
其中'/oraclebackup'指的是字典信息文件的存放位置,它必须完全匹配UTL_FILE_DIR的值,例如:假设utl_file_dir
=
'/oraclebackup/',则上面这条语句会出错,只因为UTL_FILE_DIR后面多了一个“/”,而在很多其它地方对这一“/”是不敏感
的。
本步主要用于分析DML操作分析DML
1.创建要分析的文件列表,并将log文件添加到分析列表中
SQL> execute dbms_logmnr.add_logfile (logfilename=>'/oracle/oradata/szdb/archive/1_291.dbf',options=>dbms_logmnr.new);
PL/SQL procedure successfully completed.
SQL>
execute dbms_logmnr.add_logfile
(logfilename=>'/oracle/oradata/szdb/archive/1_292.dbf',options=>dbms_logmnr.addfile);
PL/SQL procedure successfully completed.
SQL>
execute dbms_logmnr.add_logfile
(logfilename=>'/oracle/oradata/szdb/archive/1_293.dbf',options=>dbms_logmnr.addfile);
PL/SQL procedure successfully completed.
SQL>
execute dbms_logmnr.add_logfile
(logfilename=>'/oracle/oradata/szdb/archive/1_294.dbf',options=>dbms_logmnr.addfile);
PL/SQL procedure successfully completed.
#这里的options选项有三个参数可以用:
NEW - 表示创建一个新的日志文件列表
ADDFILE - 表示向这个列表中添加日志文件,如下面的例子
REMOVEFILE - 和addfile相反。
2.执行重做日志分析,分析DML操作
SQL> execute dbms_logmnr.start_logmnr(dictfilename=>'/opt/oraclelog/szdb1.ora');
PL/SQL procedure successfully completed.
SQL> execute dbms_logmnr.start_logmnr(options=>dbms_logmnr.dict_from_online_catalog);
PL/SQL procedure successfully completed.
3.根据指定的用户名、表名、操作进行分析
SQL>
select scn,sql_redo from v$logmnr_contents where seg_owner='GAMETEST'
and seg_name='ENDUSER' and upper(operation)='UPDATE';
SCN
----------
SQL_REDO
--------------------------------------------------------------------------------
139430695
update "GAMETEST"."ENDUSER" set "USERID" = '123456' where "USERID" = '98077418'
and ROWID = 'AAAH4fAANAAA4gUAAA';
SQL>
select to_char(timestamp,'YYYY-MM-DD HH24:MI:SS') time,sql_redo from
v$logmnr_contents where seg_owner='GAMETEST' and seg_name='ENDUSER' and
upper(operation)='UPDATE';
TIME
-------------------
SQL_REDO
--------------------------------------------------------------------------------
2005-07-27 15:27:32
update "GAMETEST"."ENDUSER" set "USERID" = '123456' where "USERID" = '98077418'
and ROWID = 'AAAH4fAANAAA4gUAAA';
注
意:seg_name='ENDUSER';中的ENDUSER是被update的表名,并且一定要大写,同时update该表的操作一定要已经被数据库
归档,如果没有被归档,可以在日志分析前用SQL> Alter System Archive Log Current;手动归档。
4.结束LogMiner会话
SQL> execute dbms_logmnr.end_logmnr;
PL/SQL procedure successfully completed.
阅读(842) | 评论(0) | 转发(0) |