[20120523]关于11GR2无法通过logminer看到DML的问题.txt

[20120523]关于11GR2无法通过logminer看到DML的问题.txt

昨天工作需要,使用logminer挖掘一些dml信息,我发现漏掉一些信息,也就是一些dml语句无法抓取.
我在测试环境做了一些测试(我的测试环境11.2.0.1),btw,这个问题也存在10.2.0.4版本中.

1.测试脚本:

SQL> select * from v$version
BANNER
--------------------------------------------------------------------------------
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
PL/SQL Release 11.2.0.1.0 - Production
CORE    11.2.0.1.0      Production
TNS for Linux: Version 11.2.0.1.0 - Production
NLSRTL Version 11.2.0.1.0 - Production
SQL> drop table t purge ;
SQL> create table t as select rownum id ,'test' name from dual connect by level
SQL> create unique index pk_t ON t (ID);
SQL> alter table t add constraint pk_t  primary key (id);
SQL> alter system archive log current  ;
System altered.
SQL> insert into t  values(4,'abcd');
1 row created.
SQL> commit ;
SQL> alter system archive log current  ;
System altered.
SQL> select rowid,ora_rowscn,t.* from t;
ROWID              ORA_ROWSCN         ID NAME
------------------ ---------- ---------- ----
AAAWvOAAEAAAAILAAA   11268540          1 test
AAAWvOAAEAAAAILAAB   11268540          2 test
AAAWvOAAEAAAAILAAC   11268540          3 test
AAAWvOAAEAAAAIPAAA   11268598          4 abcd

确定使用archive文件使用rman命令.

RMAN> list  archivelog from scn 11268598    ;
List of Archived Log Copies for database with db_unique_name TEST
=====================================================================
Key     Thrd Seq     S Low Time
------- ---- ------- - -------------------
505     1    505     A 2012-05-27 10:47:20
        Name: /u01/app/oracle11g/flash_recovery_area/TEST/archivelog/2012_05_27/o1_mf_1_505_7w35gdnx_.arc

2.使用logminer分析:
Begin
  SYS.DBMS_LOGMNR.ADD_LOGFILE( '/u01/app/oracle11g/flash_recovery_area/TEST/archivelog/2012_05_27/o1_mf_1_505_7w35gdnx_.arc', sys.dbms_logmnr.New);
end;
Begin
  SYS.DBMS_LOGMNR.START_LOGMNR ( ptions => sys.dbms_logmnr.DICT_FROM_ONLINE_CATALOG+sys.dbms_logmnr.COMMITTED_DATA_ONLY);
end;
SELECT   SCN, TIMESTAMP, seg_owner, seg_name, row_id, session# session_num, username, sql_redo
    FROM v$logmnr_contents
   WHERE row_id = 'AAAWvOAAEAAAAIPAAA' OR (seg_owner = USER AND seg_name = 'T') OR SCN = 11268598
ORDER BY 1;
no rows selected

而执行如下:

$ strings /u01/app/oracle11g/flash_recovery_area/TEST/archivelog/2012_05_27/o1_mf_1_505_7w35gdnx_.arc
}|{z
{TEST
Thread 0001, Seq# 0000000505, SCN 0x000000abf1f1-0x000000abf201
HbE#v
SCOTT
hisdg
pts/2
oracle11g
6txd
7978
H_1O
abcd

--可以发现insert的字串abcd确实在redo中.不知道logminer为什么不能抽取DML语句.
--BTW,如果多插入几行,有时候能看到一些,但是不全.

3.修改隐含参数"_in_memory_undo".

SQL> alter system set "_in_memory_undo"=false;
System altered.
SQL> alter system archive log current  ;
System altered.
SQL> insert into t  values(5,'efgh');
1 row created.
SQL> commit ;
Commit complete.
SQL> alter system archive log current  ;
System altered.
SQL> select rowid,ora_rowscn,t.* from t;
ROWID              ORA_ROWSCN         ID NAME
------------------ ---------- ---------- ----
AAAWvOAAEAAAAILAAA   11268540          1 test
AAAWvOAAEAAAAILAAB   11268540          2 test
AAAWvOAAEAAAAILAAC   11268540          3 test
AAAWvOAAEAAAAIPAAA   11268970          4 abcd
AAAWvOAAEAAAAIPAAB   11268970          5 efgh

--重复logminer的分析:

RMAN> list  archivelog from scn 11268598    ;
using target database control file instead of recovery catalog
List of Archived Log Copies for database with db_unique_name TEST
=====================================================================
Key     Thrd Seq     S Low Time
------- ---- ------- - -------------------
505     1    505     A 2012-05-27 10:47:20  Name: /u01/app/oracle11g/flash_recovery_area/TEST/archivelog/2012_05_27/o1_mf_1_505_7w35gdnx_.arc
506     1    506     A 2012-05-27 10:47:40  Name: /u01/app/oracle11g/flash_recovery_area/TEST/archivelog/2012_05_27/o1_mf_1_506_7w364r2p_.arc
507     1    507     A 2012-05-27 10:59:35  Name: /u01/app/oracle11g/flash_recovery_area/TEST/archivelog/2012_05_27/o1_mf_1_507_7w365h78_.arc

$ strings /u01/app/oracle11g/flash_recovery_area/TEST/archivelog/2012_05_27/o1_mf_1_507_7w365h78_.arc
}|{z
{TEST
Thread 0001, Seq# 0000000507, SCN 0x000000abf35c-0x000000abf36f
HbE#v
SCOTT0
hisdg
pts/2
oracle11g
8509
H_"O
'       IS
XQC=-
'       IS
'       IS
efgh

--可以发现insert的字串efgh确实在redo中.

SELECT   SCN, TIMESTAMP, seg_owner, seg_name, row_id, session# session_num, username, sql_redo
    FROM v$logmnr_contents
   WHERE row_id in ( 'AAAWvOAAEAAAAIPAAA','AAAWvOAAEAAAAIPAAB') OR (seg_owner = USER AND seg_name = 'T') OR SCN in ( 11268598,11268970)
ORDER BY 1;
SCN,TIMESTAMP,SEG_OWNER,SEG_NAME,ROW_ID,SESSION_NUM,USERNAME,SQL_REDO
------------------------------------------------------------------------------------------------------------------------
11268965,2012-5-27 10:59:46,SCOTT,T,AAAWvOAAEAAAAIPAAB,0,UNKNOWN,insert into "SCOTT"."T"("ID","NAME") values ('5','efgh');,
11268970,2012-5-27 10:59:57,,,AAAAAAAAAAAAAAAAAA,0,UNKNOWN,commit;,

--可以发现可以找到insert信息.

4.还原参数设置:

SQL> alter system set "_in_memory_undo"=true;
System altered.
SQL> alter system reset "_in_memory_undo" sid='*';
System altered.

5.很明显关闭IMU不是很好.

SELECT supplemental_log_data_all, supplemental_log_data_fk, supplemental_log_data_min, supplemental_log_data_pk,
       supplemental_log_data_ui
    FROM v$database;
SUP SUP SUPPLEME SUP SUP
--- --- -------- --- ---
NO  NO  NO       NO  NO
SQL> ALTER DATABASE ADD SUPPLEMENTAL LOG DATA (PRIMARY KEY, UNIQUE INDEX) COLUMNS;
Database altered.
SELECT supplemental_log_data_all, supplemental_log_data_fk, supplemental_log_data_min, supplemental_log_data_pk,
       supplemental_log_data_ui
  3      FROM v$database;
SUP SUP SUPPLEME SUP SUP
--- --- -------- --- ---
NO  NO  IMPLICIT YES YES

SQL> alter system archive log current  ;
System altered.
SQL> insert into t  values(6,'ijkl');
1 row created.
SQL> commit;
Commit complete.
SQL> alter system archive log current  ;
System altered.
--再次使用logminer分析:
SELECT   SCN, TIMESTAMP, seg_owner, seg_name, row_id, session# session_num, username, sql_redo
    FROM v$logmnr_contents
   WHERE row_id in ( 'AAAWvOAAEAAAAIPAAA','AAAWvOAAEAAAAIPAAB') OR (seg_owner = USER AND seg_name = 'T') OR SCN in ( 11268598,11268970)
ORDER BY 1;
SCN,TIMESTAMP,SEG_OWNER,SEG_NAME,ROW_ID,SESSION_NUM,USERNAME,SQL_REDO
11270096,2012-5-27 11:33:40,SCOTT,T,AAAWvOAAEAAAAIOAAA,136,UNKNOWN,insert into "SCOTT"."T"("ID","NAME") values ('6','ijkl');,
SQL> select rowid,ora_rowscn,t.* from t;
ROWID              ORA_ROWSCN         ID NAME
------------------ ---------- ---------- ----
AAAWvOAAEAAAAILAAA   11268540          1 test
AAAWvOAAEAAAAILAAB   11268540          2 test
AAAWvOAAEAAAAILAAC   11268540          3 test
AAAWvOAAEAAAAIOAAA   11270099          6 ijkl
AAAWvOAAEAAAAIPAAA   11268970          4 abcd
AAAWvOAAEAAAAIPAAB   11268970          5 efgh
6 rows selected.

--但是奇怪的问题是SCN与select rowid,ora_rowscn,t.* from t;查询不一致?why?

SELECT   SCN, TIMESTAMP, seg_owner, seg_name, row_id, session# session_num, username, sql_redo
    FROM v$logmnr_contents
   WHERE scn between 11270090 and  11270100 
ORDER BY 1;
SCN,TIMESTAMP,SEG_OWNER,SEG_NAME,ROW_ID,SESSION_NUM,USERNAME,SQL_REDO
11270093,2012-5-27 11:33:31,,,AAAAAAAAAAAAAAAAAA,136,UNKNOWN,set transaction read write;,
11270093,2012-5-27 11:33:31,SYS,AUD$,AAAAAAAAAAAAAAAAAA,136,UNKNOWN,insert into "SYS"."AUD$"("SESSIONID","ENTRYID","STATEMENT","TIMESTAMP#","USERID","USERHOST","TERMINAL","ACTION#","RETURNCODE","OBJ$CREATOR","OBJ$NAME","AUTH$PRIVILEGES","AUTH$GRANTEE","NEW$OWNER","NEW$NAME","SES$ACTIONS","SES$TID","LOGOFF$LREAD","LOGOFF$PREAD","LOGOFF$LWRITE","LOGOFF$DEAD","LOGOFF$TIME","COMMENT$TEXT","CLIENTID","SPARE1","SPARE2","OBJ$LABEL","SES$LABEL","PRIV$USED","SESSIONCPU","NTIMESTAMP#","PROXY$SID","USER$GUID","INSTANCE#","PROCESS#","XID","AUDITID","SCN","DBID","SQLBIND","SQLTEXT","OBJ$EDITION") values ('666067','2','11',NULL,'SCOTT','hisdg','pts/2','49','0',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'oracle11g',NULL,NULL,NULL,'3',NULL,TO_TIMESTAMP('2012-05-27 03:33:31.252996'),NULL,NULL,'0','10332',NULL,NULL,NULL,'2071943378',EMPTY_CLOB(),EMPTY_CLOB(),NULL);,
11270093,2012-5-27 11:33:31,SYS,AUD$,AAAAF/AABAAAWc1AAU,136,UNKNOWN,update "SYS"."AUD$" set "SQLBIND" = NULL, "SQLTEXT" = NULL where "SESSIONID" = '666067' and "ENTRYID" = '2' and "STATEMENT" = '11' and "TIMESTAMP#" IS NULL and "USERID" = 'SCOTT' and "USERHOST" = 'hisdg' and "TERMINAL" = 'pts/2' and "ACTION#" = '49' and "RETURNCODE" = '0' and "OBJ$CREATOR" IS NULL and "OBJ$NAME" IS NULL and "AUTH$PRIVILEGES" IS NULL and "AUTH$GRANTEE" IS NULL and "NEW$OWNER" IS NULL and "NEW$NAME" IS NULL and "SES$ACTIONS" IS NULL and "SES$TID" IS NULL and "LOGOFF$LREAD" IS NULL and "LOGOFF$PREAD" IS NULL and "LOGOFF$LWRITE" IS NULL and "LOGOFF$DEAD" IS NULL and "LOGOFF$TIME" IS NULL and "COMMENT$TEXT" IS NULL and "CLIENTID" IS NULL and "SPARE1" = 'oracle11g' and "SPARE2" IS NULL and "OBJ$LABEL" IS NULL and "SES$LABEL" IS NULL and "PRIV$USED" = '3' and "SESSIONCPU" IS NULL and "NTIMESTAMP#" = TO_TIMESTAMP('2012-05-27 03:33:31.252996') and "PROXY$SID" IS NULL and "USER$GUID" IS NULL and "INSTANCE#" = '0' and "PROCESS#" = '10332' and "XID" IS NULL and "AUDITID" IS NULL and "SCN" IS NULL and "DBID" = '2071943378' and "OBJ$EDITION" IS NULL and ROWID = 'AAAAF/AABAAAWc1AAU';,
11270094,2012-5-27 11:33:31,,,AAAAAAAAAAAAAAAAAA,136,UNKNOWN,commit;,
11270096,2012-5-27 11:33:40,,,AAAWvOAAAAAAAAAAAA,136,UNKNOWN,set transaction read write;,
11270096,2012-5-27 11:33:40,SCOTT,T,AAAWvOAAEAAAAIOAAA,136,UNKNOWN,insert into "SCOTT"."T"("ID","NAME") values ('6','ijkl');,
11270099,2012-5-27 11:33:43,,,AAAAAAAAAAAAAAAAAA,136,UNKNOWN,commit;,
11270100,2012-5-27 11:33:45,,,AAABbKAAAAAAAAAAAA,196,SYS,set transaction read write;,
11270100,2012-5-27 11:33:45,SYS,SCHEDULER$_JOB,AAABbKAABAAAC2SAAG,196,SYS,update "SYS"."SCHEDULER$_JOB" set "JOB_STATUS" = '3', "LAST_START_DATE" = TO_TIMESTAMP_TZ('2012-05-27 11:33:45.038928'), "RUNNING_INSTANCE" = '1', "RUNNING_SLAVE" = '0' where "OBJ#" = '57372' and "JOB_STATUS" = '1' and "LAST_START_DATE" = TO_TIMESTAMP_TZ('2012-05-27 10:36:09.037681') and "RUNNING_INSTANCE" IS NULL and "RUNNING_SLAVE" IS NULL and ROWID = 'AAABbKAABAAAC2SAAG';,
时间: 2024-09-29 19:38:03

[20120523]关于11GR2无法通过logminer看到DML的问题.txt的相关文章

[20150803]触发器对dml的影响.txt

[20150803]触发器对dml的影响.txt --最近做一个优化项目,这个项目实际上ETL项目,里面出现如下语句: UPDATE patient_medical_cost t    SET t.total_costs = NVL (total_costs, 0),        t.drug_west_costs = NVL (drug_west_costs, 0),        t.drug_middle_costs = NVL (drug_middle_costs, 0),      

[20150705]LOGMINER分析当前日志注意.txt

[20150705]LOGMINER分析当前日志注意.txt SCOTT@test01p> @ver1 PORT_STRING                    VERSION        BANNER                                                                               CON_ID ------------------------------ -------------- --------------

[20141210]使用logminer看远程归档文件补充

[20141210]使用logminer看远程归档文件(补充).txt --如果要在本机看其他主机的归档或者日志文件,由于dbid不一样,是无法查看的.必须要包括字典信息. --如果需要查看别的数据库的归档文件,必须要有别的数据字典文件.正常需要使用utl_file_dir,而经常这个参数没有设置. --在使用如下命令建立数据字典. exec dbms_logmnr.start_logmnr(dictfilename=>'/home/oracle11g/testd/dict_test.ora')

[20160712]logminer 与rman 删除archivelog

[20160712]logminer 与rman 删除archivelog.txt --昨天晚上使用logminer遇到的问题,主要后台的rman脚本正好删除需要的archivelog. --再测试环境下模拟看看: 1.环境: SCOTT@book> @ &r/ver1 PORT_STRING                    VERSION        BANNER ------------------------------ -------------- -------------

[20140529]使用审计记录一些不能DML的记录

[20140529]使用审计记录一些不能DML的记录.txt --前几天看了审计的一些内容,突然想起多年以前一直困扰我的问题. --生产系统存在一个问题,就是录入信息存在大于的信息超出范围的问题,出现这个问题,主要是程序存在单位的转换, --比如是mg的单位,开成了g的单位.这样在转化的过程中出现溢出情况,本来这些问题应该有程序来解决,可惜开发 --一直不去纠正这个问题,我们的做法是要求用户选取一段记录来保存,或者逐条保存.显然这样效率不高,用户抱怨不断. --实际上我对这样的开发团队非常失望!

理解和使用Oracle 8i分析工具-LogMiner

Oracle LogMiner 是Oracle公司从产品8i以后提供的一个实际非常有用的分析工具,使用该工具可以轻松获得Oracle 重作日志文件(归档日志文件)中的具体内容,特别是,该工具可以分析出所有对于数据库操作的DML(insert.update.delete等)语句,另外还可分析得到一些必要的回滚SQL语句.该工具特别适用于调试.审计或者回退某个特定的事务. LogMiner分析工具实际上是由一组PL/SQL包和一些动态视图(Oracle8i内置包的一部分)组成,它作为Oracle数据

浅谈LogMiner的使用

Logminer是每个Dba都应熟悉的工具,当一天由于用户的误操作你需要做不完全的恢复时,由于你无法确定这个操作是哪个时间做的,所以这对你的恢复就带来的很大的难度,丢失的数据也不能完全恢复回来.而LogMiner就可以帮你确定这个误操作的准确时间. 我的测试环境是Aix4.3.3的操作系统,Oracle9.2.0.3的测试库. 一.LogMiner的几点说明1.LogMiner可以帮你确定在某段时间所发的各种DML,DDL操作的具体时间和SCN号,它所依据的是归档日志文件及联机日志文件.2.它只

9i新特性之Flashback Query的应用-------------针对DML误操作的恢复(2)

恢复 用DBMS_FLASHBACK包   DBMS_FLASHBACK 包提供了以下几个函数:   ENABLE_AT_TIME:设置当前SESSION 的闪回查询时间 ENABLE_AT_SYSTEM_CHANGE_NUMBER:设置当前SESSION的闪回查询SCN GET_SYSTEM_CHANGE_NUMBER:取得当前数据库的SCN       DISABLE:关闭当前SESSION 的闪回查询       如: SQL> select dbms_flashback.get_syst

Oracle 8i分析工具:LogMiner

Oracle LogMiner是Oracle公司从产品8i以后提供的一个实际非常有用的分析工具,使用该工具可以轻松获得Oracle重作日志文件(归档日志文件)中的具体内容,特别是,该工具可以分析出所有对于数据库操作的DML(insert.update.delete等)语句,另外还可分析得到一些必要的回滚SQL语句.该工具特别适用于调试.审计或者回退某个特定的事务. LogMiner分析工具实际上是由一组PL/SQL包和一些动态视图(Oracle8i内置包的一部分)组成,它作为Oracle数据库的