Logdump工具是GoldenGate提供的一个用于查询、分析、过滤、查看和保存存储在trail文件或extract文件中的数据的工具。
1、启动Logdump工具
[Oracle@rhel6 ~]$ cd /ogg
[oracle@rhel6 ogg]$ ./logdump
Oracle GoldenGate Log File Dump Utility for Oracle
Version 12.2.0.1.1 OGGCORE_12.2.0.1.0_PLATFORMS_151211.1401
Copyright (C) 1995, 2015, Oracle and/or its affiliates. All rights reserved.
Logdump 8 >
2、使用Logdump
#查看数据记录的头信息
Logdump 1 >GHDR ON
#查看列信息,包括数量和长度
Logdump 2 >DETAIL ON
#查看hex和ASCII数据值
Logdump 3 >DETAIL DATA
#查看用户定义的信息
Logdump 5 >USERTOKEN ON
#打开一个trail文件,可以写相对路径也可以写绝对路径
Logdump 6 >OPEN ./dirdat/zx000000006
Current LogTrail is /ogg/dirdat/zx000000006
#顺序查看trail文件中的信息,NEXT或N
Logdump 7 >N
2016/12/08 14:15:10.814.788 FileHeader Len 1359 RBA 0
Name: *FileHeader*
3000 02f0 3000 0008 4747 0d0a 544c 0a0d 3100 0002 | 0...0...GG..TL..1...
0005 3200 0004 2000 0000 3300 0008 02f2 6953 040a | ..2... ...3.....iS..
3644 3400 0018 0016 7572 693a 7268 656c 363a 3a6f | 6D4.....uri:rhel6::o
6767 3a45 5854 5f45 4d50 3600 0016 0014 2e2f 6469 | gg:EXT_EMP6....../di
7264 6174 2f7a 7830 3030 3030 3030 3036 3700 0001 | rdat/zx0000000067...
0138 0000 0400 0000 0639 ff00 0800 0000 0000 0000 | .8.......9..........
003a 0000 8101 3000 0000 0000 0000 0000 0000 0000 | .:....0.............
#指定某个RBA号
Logdump 12 >pos 2239
Reading forward from RBA 2239
Logdump 13 >n
___________________________________________________________________
Hdr-Ind : E (x45) Partition : . (x0c)
UndoFlag : . (x00) BeforeAfter: A (x41)
RecLength : 121 (x0079) IO Time : 2016/12/08 14:16:47.000.000
IOType : 5 (x05) OrigNode : 255 (xff)
TransInd : . (x00) FormatType : R (x52)
SyskeyLen : 0 (x00) Incomplete : . (x00)
AuditRBA : 84 AuditPos : 5428240
Continued : N (x00) RecCount : 1 (x01)
2016/12/08 14:16:47.000.000 Insert Len 121 RBA 2239
Name: ZHAOXU.EMP (TDR Index: 1)
After Image: Partition 12 G b
0000 000a 0000 0000 0000 0000 1cc9 0001 0009 0000 | ....................
0005 534d 4954 4800 0200 0900 0000 0543 4c45 524b | ..SMITH........CLERK
0003 000a 0000 0000 0000 0000 1ede 0004 0015 0000 | ....................
3139 3830 2d31 322d 3137 3a30 303a 3030 3a30 3000 | 1980-12-17:00:00:00.
0500 0a00 0000 0000 0000 0138 8000 0600 0aff ff00 | ...........8........
0000 0000 0000 0000 0700 0a00 0000 0000 0000 0000 | ....................
14 | .
Column 0 (x0000), Len 10 (x000a)
0000 0000 0000 0000 1cc9 | ..........
Column 1 (x0001), Len 9 (x0009)
0000 0005 534d 4954 48 | ....SMITH
Column 2 (x0002), Len 9 (x0009)
0000 0005 434c 4552 4b | ....CLERK
Column 3 (x0003), Len 10 (x000a)
0000 0000 0000 0000 1ede | ..........
Column 4 (x0004), Len 21 (x0015)
0000 3139 3830 2d31 322d 3137 3a30 303a 3030 3a30 | ..1980-12-17:00:00:0
30 | 0
Column 5 (x0005), Len 10 (x000a)
0000 0000 0000 0001 3880 | ........8.
Column 6 (x0006), Len 10 (x000a)
ffff 0000 0000 0000 0000 | ..........
Column 7 (x0007), Len 10 (x000a)
0000 0000 0000 0000 0014 | ..........
3、部分命令介绍
OPEN | FROM <filename> #打开一个trail文件
HISTORY #查看历史命令
POSITION [ <rba> | FIRST | LAST | EOF ] #指定一个地址进行查看,可简写为POS,RBA为指定地址,FIRST和0为开头,LAST和EOF为最后
ENV #查看当前环境设置
SHOW <option> #查看选项
[OPEN] #
[TIME] #查看时间
[ENV] #查看环境设置同ENV
[RECTYPE] #查看操作类型
[FILTER] #查看过滤设置
FILTER [INClude | EXCLude] <filter options> #用于设置过滤,默认为INclude
<filter options> are #过滤选项
RECTYPE <type number | type name> #设置过滤的操作类型,只查找指定类型的记录,FILTER RECTYPE UPDATE
STRING [BOTH] /<text>/ [<column range>] #
HEX <hex string> [<column range>] #
TRANSID <TMF transaction identifier> #
FILENAME <filename template> #设置过滤对象,基于对象名或组名[catalog.]<owner>.<table>,只查找指定对象的信息,FILTER FILENAME SCOTT.EMP(大小写敏感)
PROCESS <processname template> #
INT16 <16-bit integer> #
INT32 <32-bit integer> #
INT64 <64-bit integer> #
STARTTIME <date-time string> #设置开始时间,从指定的时间后开始查找信息,FILTER STARTTIME 2016-12-09 12:00:00
ENDTIME <date-time string> #设置停止时间,只查找指定时间前的数据,FILTER ENDTIME 2016-12-09 13:00:00
SYSKEY [<comparison>] <32/64-bit syskey> #
SYSKEYLEN [<comparison>] [<value>] #
TRANSIND [<comparison>] <nn> #
UNDOFLAG [<comparison>] <nn> #
RECLEN [<comparison>] <nn> #
AUDITRBA [<comparison>] <nnnnnnnn> #
ANSINAME <ansi table name> #
GGSTOKEN <tokenname> [<comparison>] [<tokenvalue>] #
USERTOKEN <tokenname> [<comparison>] [<tokenvalue>] #
CSN | LogCSN [<comparison>] [<value>] #
<column range> #
<start column>:<end column>, ie 0:231 #
<comparison> #
=, ==, !=, <>, <, >, <=, >= EQ, GT, LE, GE, LE, NE #
FILTER SHOW #查看过滤设置,同SHOW FILTER
FILTER ENABLE | ON #启用过滤
FILTER DISABLE | OFF #停用用过滤
FILTER CLEAR [ <filterid> | <ALL> ] #清除过滤设置
FILTER MATCH ANY | ALL #设置匹配任意一项还是所有都要匹配
NEXT [ <count> ] #默认查看下一条记录,NEXT 20查看下20条记录,可简写为N
4、获取命令帮助
Logdump >HELP
官方文档:http://docs.oracle.com/goldengate/c1221/gg-winux/GLOGD/GUID-471CB1E3-B124-44C0-9B81-B8FF42B4EF92.htm#GLOGD109