[20160805]logminer使用问题2.txt

简介: [20160805]logminer使用问题2.txt --前一阵子看itpub有人想通过logminer来抽取归档同步数据库,实际上这个非常不科学,存在一定的风险,我觉得很多情况下会漏掉一些sql --语句,通过例子来说明。

[20160805]logminer使用问题2.txt

--前一阵子看itpub有人想通过logminer来抽取归档同步数据库,实际上这个非常不科学,存在一定的风险,我觉得很多情况下会漏掉一些sql
--语句,通过例子来说明。

--首先说明logminer用来补救一些异常操作还是可行的。

1.测试环境说明:
SCOTT@book> @ &r/ver1

PORT_STRING                    VERSION        BANNER
------------------------------ -------------- --------------------------------------------------------------------------------
x86_64/Linux 2.4.xx            11.2.0.4.0     Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production

SCOTT@book> alter database add supplemental log data;
Database altered.

SCOTT@book> alter database  FORCE LOGGING ;
Database altered.

SCOTT@book> select SUPPLEMENTAL_LOG_DATA_MIN, FORCE_LOGGING  from v$database ;
SUPPLEME FOR
-------- ---
YES      YES

SCOTT@book> create table emp1 as select * from emp;
Table created.

--//安全期间,我还重启数据库。

2.测试1:
SCOTT@book> alter system archive log current ;

System altered.

SCOTT@book> @ &r/logfile
GROUP# THREAD# SEQUENCE#       BYTES BLOCKSIZE MEMBERS ARC STATUS     FIRST_CHANGE# FIRST_TIME          NEXT_CHANGE# NEXT_TIME           GROUP# STATUS     TYPE       MEMBER                       IS_
------ ------- --------- ----------- --------- ------- --- ---------- ------------- ------------------- ------------ ------------------- ------ ---------- ---------- ---------------------------- ---
     1       1       418    52428800       512       1 NO  CURRENT      13245390164 2016-08-05 10:49:19 2.814750E+14                          1            ONLINE     /mnt/ramdisk/book/redo01.log NO
     2       1       416    52428800       512       1 YES INACTIVE     13245389809 2016-08-05 10:36:39  13245389934 2016-08-05 10:39:39      2            ONLINE     /mnt/ramdisk/book/redo02.log NO
     3       1       417    52428800       512       1 YES ACTIVE       13245389934 2016-08-05 10:39:39  13245390164 2016-08-05 10:49:19      3            ONLINE     /mnt/ramdisk/book/redo03.log NO

--当前使用/mnt/ramdisk/book/redo01.log。seq=418.

SCOTT@book> alter table emp1 move tablespace users;
Table altered.

--我现在移动emp1表,再来分析归档seq=411的日志情况。参看链接http://blog.itpub.net/267265/viewspace-2123023/

--//使用logminer分析:
Begin
  SYS.DBMS_LOGMNR.ADD_LOGFILE( '/u01/app/oracle/archivelog/book/1_411_907434361.dbf', sys.dbms_logmnr.New);
end;

Begin
  SYS.DBMS_LOGMNR.ADD_LOGFILE( '/u01/app/oracle/archivelog/book/1_412_907434361.dbf', sys.dbms_logmnr.AddFile);
end;

Begin
  SYS.DBMS_LOGMNR.START_LOGMNR ( Options => sys.dbms_logmnr.DICT_FROM_ONLINE_CATALOG+sys.dbms_logmnr.COMMITTED_DATA_ONLY);
end;

--注意:我前面的测试在下一个日志才提交的。

SCOTT@book> @ &r/pt2 'select *from v$logmnr_contents  where seg_name=''EMP1'' and rownum=1';
old   6:     from table(xmlsequence(cursor( &1 )))
new   6:     from table(xmlsequence(cursor( select *from v$logmnr_contents  where seg_name='EMP1' and rownum=1 )))
ROW_NUM      COL_NUM COL_NAME          COL_VALUE
------- ------------ ----------------- ----------------------------------------------------------------------------------------------------
      1            1 SCN               13245387377
                   2 START_SCN         13245387377
                   3 COMMIT_SCN        13245387689
                   4 TIMESTAMP         2016-08-05 09:41:35
                   5 START_TIMESTAMP   2016-08-05 09:41:35
                   6 COMMIT_TIMESTAMP  2016-08-05 09:54:30
                   7 XIDUSN            10
                   8 XIDSLT            30
                   9 XIDSQN            54930
                  10 XID               0A001E0092D60000
                  11 PXIDUSN           10
                  12 PXIDSLT           30
                  13 PXIDSQN           54930
                  14 PXID              0A001E0092D60000
                  15 OPERATION         UPDATE
                  16 OPERATION_CODE    3
                  17 ROLLBACK          0
                  18 SEG_OWNER         SCOTT
                  19 SEG_NAME          EMP1
                  20 TABLE_NAME        EMP1
                  21 SEG_TYPE          2
                  22 SEG_TYPE_NAME     TABLE
                  23 TABLE_SPACE       USERS
                  24 ROW_ID            AAAXY4AAEAAAAIzAAA
                  25 USERNAME          SCOTT
                  26 OS_USERNAME       UNKNOWN
                  27 MACHINE_NAME      UNKNOWN
                  28 AUDIT_SESSIONID   35982267
                  29 SESSION_x0023_    232
                  30 SERIAL_x0023_     5
                  31 SESSION_INFO      UNKNOWN
                  32 THREAD_x0023_     1
                  33 SEQUENCE_x0023_   2
                  34 RBASQN            411
                  35 RBABLK            8
                  36 RBABYTE           16
                  37 UBAFIL            3
                  38 UBABLK            0
                  39 UBAREC            0
                  40 UBASQN            0
                  41 ABS_FILE_x0023_   3
                  42 REL_FILE_x0023_   4
                  43 DATA_BLK_x0023_   563
                  44 DATA_OBJ_x0023_   95800
                  45 DATA_OBJV_x0023_  1
                  46 DATA_OBJD_x0023_  95800
                  47 SQL_REDO          update "SCOTT"."EMP1" set "ENAME" = '1234567DEF' where "ENAME" = 'SMITH' and ROWID = 'AAAXY4AAEAAAAI
                  48 SQL_UNDO          update "SCOTT"."EMP1" set "ENAME" = 'SMITH' where "ENAME" = '1234567DEF' and ROWID = 'AAAXY4AAEAAAAI
                  49 RS_ID              0x00019b.00000008.0010
                  50 SSN               0
                  51 CSF               0
                  52 STATUS            0
                  53 REDO_VALUE        452
                  54 UNDO_VALUE        453
                  55 SAFE_RESUME_SCN   0
                  56 CSCN              13245387689
56 rows selected.

SCOTT@book> select * from dba_objects where owner=user and object_name='EMP1';
OWNER  OBJECT_NAME          SUBOBJECT_    OBJECT_ID DATA_OBJECT_ID OBJECT_TYPE         CREATED             LAST_DDL_TIME       TIMESTAMP           STATUS  T G S    NAMESPACE EDITION_NAME
------ -------------------- ---------- ------------ -------------- ------------------- ------------------- ------------------- ------------------- ------- - - - ------------ ------------------------------
SCOTT  EMP1                                   95800          95806 TABLE               2016-08-05 09:39:11 2016-08-05 10:51:34 2016-08-05:09:39:11 VALID   N N N            1

--我前面移动了对象,DATA_OBJECT_ID已经发生了变化。通过rowid已经无法访问。


SCOTT@book> select * from emp1 where rowid='AAAXY4AAEAAAAIzAAA';
select * from emp1 where rowid='AAAXY4AAEAAAAIzAAA'
              *
ERROR at line 1:
ORA-01410: invalid ROWID

--而现在rowid是:
SCOTT@book> select rowid,emp1.* from emp1 where rownum=1;
ROWID                     EMPNO ENAME      JOB                MGR HIREDATE                     SAL         COMM       DEPTNO
------------------ ------------ ---------- --------- ------------ ------------------- ------------ ------------ ------------
AAAXY+AAEAAAAODAAA         7369 1234567DEF CLERK             7902 1980-12-17 00:00:00          800                        20

SCOTT@book> @ &r/rowid AAAXY+AAEAAAAODAAA
      OBJECT         FILE        BLOCK          ROW DBA                  TEXT
------------ ------------ ------------ ------------ -------------------- ----------------------------------------
       95806            4          899            0 4,899                alter system dump datafile 4 block 899 ;

-- DATA_OBJECT_ID 现在是95806。这样你拿到sql_undo 修改也要注意的。

3.测试2.
--如果删除了对象呢?

SCOTT@book> drop table emp1 purge ;
Table dropped.

SCOTT@book> @ &r/pt2 'select *from v$logmnr_contents  where seg_name=''EMP1'' and rownum=1';
no rows selected

--这样无法查询到。
SCOTT@book> @ &r/pt2 'select *from v$logmnr_contents where row_id=''AAAXY4AAEAAAAIzAAA''';
ROW_NUM COL_NUM COL_NAME          COL_VALUE
------- ------- ----------------- ----------------------------------------------------------------------------------------------------
      1       1 SCN               13245387377
              2 START_SCN         13245387377
              3 COMMIT_SCN        13245387689
              4 TIMESTAMP         2016-08-05 09:41:35
              5 START_TIMESTAMP   2016-08-05 09:41:35
              6 COMMIT_TIMESTAMP  2016-08-05 09:54:30
              7 XIDUSN            10
              8 XIDSLT            30
              9 XIDSQN            54930
             10 XID               0A001E0092D60000
             11 PXIDUSN           10
             12 PXIDSLT           30
             13 PXIDSQN           54930
             14 PXID              0A001E0092D60000
             15 OPERATION         UPDATE
             16 OPERATION_CODE    3
             17 ROLLBACK          0
             18 SEG_OWNER         UNKNOWN
             19 SEG_NAME          OBJ# 95800
             20 TABLE_NAME        OBJ# 95800
             21 SEG_TYPE          0
             22 SEG_TYPE_NAME     UNKNOWN
             23 TABLE_SPACE       UNKNOWN
             24 ROW_ID            AAAXY4AAEAAAAIzAAA
             25 USERNAME          SCOTT
             26 OS_USERNAME       UNKNOWN
             27 MACHINE_NAME      UNKNOWN
             28 AUDIT_SESSIONID   35982267
             29 SESSION_x0023_    232
             30 SERIAL_x0023_     5
             31 SESSION_INFO      UNKNOWN
             32 THREAD_x0023_     1
             33 SEQUENCE_x0023_   2
             34 RBASQN            411
             35 RBABLK            8
             36 RBABYTE           16
             37 UBAFIL            3
             38 UBABLK            0
             39 UBAREC            0
             40 UBASQN            0
             41 ABS_FILE_x0023_   3
             42 REL_FILE_x0023_   4
             43 DATA_BLK_x0023_   563
             44 DATA_OBJ_x0023_   95800
             45 DATA_OBJV_x0023_  1
             46 DATA_OBJD_x0023_  95800
             47 SQL_REDO          update "UNKNOWN"."OBJ# 95800" set "COL 2" = HEXTORAW('31323334353637444546') where "COL 2" = HEXTORA
             48 SQL_UNDO          update "UNKNOWN"."OBJ# 95800" set "COL 2" = HEXTORAW('534d495448') where "COL 2" = HEXTORAW('3132333
             49 RS_ID              0x00019b.00000008.0010
             50 SSN               0
             51 CSF               0
             52 INFO              Dictionary Mismatch
             53 STATUS            2
             54 REDO_VALUE        934
             55 UNDO_VALUE        935
             56 SAFE_RESUME_SCN   0
             57 CSCN              13245387689
57 rows selected.

--虽然能取到,显示的是UNKNOWN。

目录
相关文章
|
机器学习/深度学习 Oracle 关系型数据库
[20180412]logminer使用问题(10g).txt
[20180412]logminer使用问题(10g).txt --//今天使用logminer下遇到一个问题,做一个记录: 1.环境: SYSTEM@xxx> @ &r/ver1 PORT_STRING                    VERSION...
1642 0
|
Oracle 关系型数据库 Linux
[20180115]RMAN-06820.txt
[20180115]RMAN-06820.txt --//在备库做归档备份出现RMAN-06820的问题。就是如果在备库做全表,因为要做主库日志切换,一般执行rman target /会出现问题。
1420 0
|
Oracle 关系型数据库 测试技术
[20171225]RMAN-06808.txt
[20171225]RMAN-06808: SECTION SIZE cannot be used when piece limit is in effect.txt --//朋友拿我的一些例子来测试遇到的RMAN-06808: SECTION SIZE cannot be used when piece limit is in effect问题.
951 0
|
关系型数据库
[20171221]RMAN-05501.txt
[20171221]RMAN-05501 aborting duplication of target database.txt --//昨天使用rman duplicate建立dg,出现如下错误: rman > duplicate target database for standby from active database; .
1070 0
|
Oracle 关系型数据库 Linux
[20171208]rman与truncate3.txt
[20171208]rman与truncate3.txt --//前几天测试truncate表依旧备份一部分信息,测试几次确定备份8extent.当时的测试几个extents是相邻的.
896 0
|
Oracle 关系型数据库 测试技术
[20171206]rman与truncate.txt
[20171206]rman与truncate.txt --//昨天下班在回家的路上,突然想起以前遇到的问题,就是truncate表后,rman做备份时会备份多少truncate表的信息, --//当时在itpub上,还存在讨论,就是rman会备份空block吗?参考链接:http://www.
1003 0
|
Oracle 关系型数据库 Linux
[20171206]rman与truncate2.txt
[20171206]rman与truncate2.txt --//上午测试发现truncate的表在做rman备份时还要做8个extents的备份. --//不知道自己的猜测是否正确,选择一个使用UNIFORM SIZE 的表空间测试看看.
1074 0
|
Oracle 关系型数据库
[20171130]关于rman的一些总结.txt
[20171130]关于rman的一些总结.txt --//最近一直做rman相关测试,测试那个乱,没办法.无法从周围的人获得帮助,纯粹是自己的乱猜,乱测,不知道别人是否能看懂我写的东西.
1090 0
|
Oracle 关系型数据库 API
[20170208]rman tape.txt
[20170208]rman tape.txt --前一阵子,同事测试使用磁带做rman备份,留下一些备份信息在控制文件,要清除. --我依稀记得我以前也干过这些事情,晚上看了一下书: Apress.
986 0
|
监控 Oracle 关系型数据库
[20170203]关于flashback的问题.txt
[20170203]关于flashback的问题.txt --今天生产系统遇到的问题,dataguard机器磁盘空间不足,需要释放磁盘空间,无论如何删除日志,空间回收都是很少.
898 0

热门文章

最新文章