logdump是ogg自带的一个用于分析trail文件的工具,该工具还不错,提供了一些列的命令,如下:
我们常用的命令可能并不多,下面简单列一些,来自官方文档:
Logdump 92 >help
FC [ | ] - Edit previous command
HISTORY - List previous commands
OPEN | FROM - Open a Log file
RECORD | REC - Display audit record
NEXT [ ] - Display next data record
SKIP [ ] [FILTER] - Skip down records
FILTER - Apply filter during skip
COUNT - Count the records in the file
[START[time] ,]
[END[time] ,]
[INT[erval] ,]
[LOG[trail] ,]
[FILE ,]
[DETAIL ]
format is
[[yy]yy-mm-dd] [hh[:mm][:ss]]
POSITION [ | FIRST | LAST | EOF ] - Set position in file
REVerse | FORward - Set read direction
RECLEN [ ] - Sets max output length
EXIT | QUIT - Exit the program
FILES | FI | DIR - Display filenames
ENV - Show current settings
VOLUME | VOL | V - Change default volume
DEBUG - Enter the debugger
GHDR ON | OFF - Toggle GHDR display
DETAIL ON | OFF | DATA - Toggle detailed data display
RECLEN - Set data display length
SCANFORHEADER (SFH) [PREV] - Search for the start of a header
SCANFORTYPE (SFT) - Find the next record of
|
[,]
SCANFORRBA (SFR) - Find the next record with
- syskey = -1 scans for next record
,
SCANFORTIME (SFTS) - Find the next record with timestamp
[,]
format is
[[yy]yy-mm-dd] [hh[:mm][:ss]]
SCANFORENDTRANS (SFET) - Find the end of the current transaction
SCANFORNEXTTRANS (SFNT) - Find start of the next transaction
SHOW 我们常用的命令可能并不多,下面简单列一些,来自官方文档:
Logdump 1 >open /u01/ggs/dirdat/ex000019
----打开trail文件
Logdump 1 >ghdr on
---查看header record信息
Logdump 2 >detail on
---Column information includes the number and length in hex and ASCII.
Logdump 3> DETAIL DATA
---To add hex and ASCII data values to the column information:
Logdump 4> USERTOKEN ON
---view user tokens
Logdump 5> RECLEN
----控制显示的长度
Logdump 7> NEXT or N
----To go to the first record and then move through records in sequence
Logdump 35> POS
Logdump 36> N
----To go to an RBA anywhere in the file
Logdump 37> POS FIRST 或 pos 0
----查看file中低一条记录
+++++++ 基于表名进行过滤操作
Logdump 60> FILTER INCLUDE/EXCLUDE FILENAME .
Logdump 61> N
----基于某表名进行过滤
Logdump 62> FILTER CLEAR
----清除当前的过滤设置
+++++++ 多条件进行过滤
Logdump 65> FILTER INCLUDE FILENAME .; FILTER RECTYPE ; FILTER MATCH ALL
Logdump 67> COUNT
---- 统计当前trail文件的记录
+++++++ To save records to a new trail file
----保存整个trail文件
Logdump 68> SAVE
Where: is the name of the new file.
----保存某些record记录
Logdump 69> SAVE RECORDS
To close the current file and open the next one in the trail
Logdump 70> NEXTTRAIL
++++++++ To keep a log of your session
----保存日志
Logdump 71> LOG TO .txt
----To write text to the log:
Logdump 72> WRITELOG “"
Logdump 73> LOG STOP
++++++ To see the current Logdump environment
Logdump 74> ENV
下面来尝试一下,如何使用logdump 来分析某个trail文件。
-bash-3.00$ ./logdump
Oracle GoldenGate Log File Dump Utility for Oracle
Version 11.2.1.0.1 OGGCORE_11.2.1.0.1_PLATFORMS_120423.0230
Copyright (C) 1995, 2012, Oracle and/or its affiliates. All rights reserved.
Logdump 71 >open ./dirdat/rm000018
Current LogTrail is /home/ggs/ggs_home/dirdat/rm000018
Logdump 72 >ghdr on
Logdump 73 >detail on
Logdump 74 >detail data
Logdump 75 >usertoken on
Logdump 84 >FILTER include filename ROGER.T;
Logdump 85 >next
___________________________________________________________________
Hdr-Ind : E (x45) Partition : . (x04)
UndoFlag : . (x00) BeforeAfter: B (x42)
RecLength : 200 (x00c8) IO Time : 2012/08/31 07:35:43.060.853
IOType : 3 (x03) OrigNode : 255 (xff)
TransInd : . (x00) FormatType : R (x52)
SyskeyLen : 0 (x00) Incomplete : . (x00)
AuditRBA : 8 AuditPos : 19677200
Continued : N (x00) RecCount : 1 (x01)
2012/08/31 07:35:43.060.853 Delete Len 200 RBA 37501
Name: ROGER.T
Before Image: Partition 4 G b
0000 000a 0000 0006 5055 424c 4943 0001 0016 0000 | ........PUBLIC......
0012 4756 2444 425f 4341 4348 455f 4144 5649 4345 | ..GV$DB_CACHE_ADVICE
0002 0004 ffff 0000 0003 0008 0000 0004 3230 3437 | ................2047
0004 0004 ffff 0000 0005 000b 0000 0007 5359 4e4f | ................SYNO
4e59 4d00 0600 1500 0032 3030 352d 3036 2d33 303a | NYM......2005-06-30:
3139 3a31 313a 3034 0007 0015 0000 3230 3035 2d30 | 19:11:04......2005-0
362d 3330 3a31 393a 3131 3a30 3400 0800 1700 0000 | 6-30:19:11:04.......
Column 0 (x0000), Len 10 (x000a)
0000 0006 5055 424c 4943 | ....PUBLIC
Column 1 (x0001), Len 22 (x0016)
0000 0012 4756 2444 425f 4341 4348 455f 4144 5649 | ....GV$DB_CACHE_ADVI
4345 | CE
Column 2 (x0002), Len 4 (x0004)
ffff 0000 | ....
Column 3 (x0003), Len 8 (x0008)
0000 0004 3230 3437 | ....2047
Column 4 (x0004), Len 4 (x0004)
ffff 0000 | ....
Column 5 (x0005), Len 11 (x000b)
0000 0007 5359 4e4f 4e59 4d | ....SYNONYM
Column 6 (x0006), Len 21 (x0015)
0000 3230 3035 2d30 362d 3330 3a31 393a 3131 3a30 | ..2005-06-30:19:11:0
34 | 4
Column 7 (x0007), Len 21 (x0015)
0000 3230 3035 2d30 362d 3330 3a31 393a 3131 3a30 | ..2005-06-30:19:11:0
34 | 4
Column 8 (x0008), Len 23 (x0017)
0000 0013 3230 3035 2d30 362d 3330 3a31 393a 3131 | ....2005-06-30:19:11
3a30 34 | :04
Column 9 (x0009), Len 9 (x0009)
0000 0005 5641 4c49 44 | ....VALID
Column 10 (x000a), Len 5 (x0005)
0000 0001 4e | ....N
Column 11 (x000b), Len 5 (x0005)
0000 0001 4e | ....N
Column 12 (x000c), Len 5 (x0005)
0000 0001 4e | ....N
Filtering suppressed 161 records
Logdump 86 >n
___________________________________________________________________
Hdr-Ind : E (x45) Partition : . (x04)
UndoFlag : . (x00) BeforeAfter: B (x42)
RecLength : 197 (x00c5) IO Time : 2012/08/31 07:35:43.060.853
IOType : 3 (x03) OrigNode : 255 (xff)
TransInd : . (x01) FormatType : R (x52)
SyskeyLen : 0 (x00) Incomplete : . (x00)
AuditRBA : 8 AuditPos : 19677888
Continued : N (x00) RecCount : 1 (x01)
2012/08/31 07:35:43.060.853 Delete Len 197 RBA 37810
Name: ROGER.T
Before Image: Partition 4 G m
0000 0007 0000 0003 5359 5300 0100 1900 0000 1547 | ........SYS........G
565f 2453 4741 5f54 4152 4745 545f 4144 5649 4345 | V_$SGA_TARGET_ADVICE
0002 0004 ffff 0000 0003 0008 0000 0004 3230 3438 | ................2048
0004 0004 ffff 0000 0005 0008 0000 0004 5649 4557 | ................VIEW
0006 0015 0000 3230 3035 2d30 362d 3330 3a31 393a | ......2005-06-30:19:
3131 3a30 3400 0700 1500 0032 3030 352d 3036 2d33 | 11:04......2005-06-3
303a 3139 3a31 313a 3034 0008 0017 0000 0013 3230 | 0:19:11:04........20
Column 0 (x0000), Len 7 (x0007)
0000 0003 5359 53 | ....SYS
Column 1 (x0001), Len 25 (x0019)
0000 0015 4756 5f24 5347 415f 5441 5247 4554 5f41 | ....GV_$SGA_TARGET_A
4456 4943 45 | DVICE
Column 2 (x0002), Len 4 (x0004)
ffff 0000 | ....
Column 3 (x0003), Len 8 (x0008)
0000 0004 3230 3438 | ....2048
Column 4 (x0004), Len 4 (x0004)
ffff 0000 | ....
Column 5 (x0005), Len 8 (x0008)
0000 0004 5649 4557 | ....VIEW
Column 6 (x0006), Len 21 (x0015)
0000 3230 3035 2d30 362d 3330 3a31 393a 3131 3a30 | ..2005-06-30:19:11:0
34 | 4
Column 7 (x0007), Len 21 (x0015)
0000 3230 3035 2d30 362d 3330 3a31 393a 3131 3a30 | ..2005-06-30:19:11:0
34 | 4
Column 8 (x0008), Len 23 (x0017)
0000 0013 3230 3035 2d30 362d 3330 3a31 393a 3131 | ....2005-06-30:19:11
3a30 34 | :04
Column 9 (x0009), Len 9 (x0009)
0000 0005 5641 4c49 44 | ....VALID
Column 10 (x000a), Len 5 (x0005)
0000 0001 4e | ....N
Column 11 (x000b), Len 5 (x0005)
0000 0001 4e | ....N
Column 12 (x000c), Len 5 (x0005)
0000 0001 4e | ....N
Logdump 87 >
Logdump 87 >n
___________________________________________________________________
Hdr-Ind : E (x45) Partition : . (x04)
UndoFlag : . (x00) BeforeAfter: B (x42)
RecLength : 202 (x00ca) IO Time : 2012/08/31 07:35:43.060.853
IOType : 3 (x03) OrigNode : 255 (xff)
TransInd : . (x01) FormatType : R (x52)
SyskeyLen : 0 (x00) Incomplete : . (x00)
AuditRBA : 8 AuditPos : 19678284
Continued : N (x00) RecCount : 1 (x01)
2012/08/31 07:35:43.060.853 Delete Len 202 RBA 38093
Name: ROGER.T
Before Image: Partition 4 G m
0000 000a 0000 0006 5055 424c 4943 0001 0018 0000 | ........PUBLIC......
0014 4756 2453 4741 5f54 4152 4745 545f 4144 5649 | ..GV$SGA_TARGET_ADVI
4345 0002 0004 ffff 0000 0003 0008 0000 0004 3230 | CE................20
3439 0004 0004 ffff 0000 0005 000b 0000 0007 5359 | 49................SY
4e4f 4e59 4d00 0600 1500 0032 3030 352d 3036 2d33 | NONYM......2005-06-3
303a 3139 3a31 313a 3034 0007 0015 0000 3230 3035 | 0:19:11:04......2005
2d30 362d 3330 3a31 393a 3131 3a30 3400 0800 1700 | -06-30:19:11:04.....
Column 0 (x0000), Len 10 (x000a)
0000 0006 5055 424c 4943 | ....PUBLIC
Column 1 (x0001), Len 24 (x0018)
0000 0014 4756 2453 4741 5f54 4152 4745 545f 4144 | ....GV$SGA_TARGET_AD
5649 4345 | VICE
Column 2 (x0002), Len 4 (x0004)
ffff 0000 | ....
Column 3 (x0003), Len 8 (x0008)
0000 0004 3230 3439 | ....2049
Column 4 (x0004), Len 4 (x0004)
ffff 0000 | ....
Column 5 (x0005), Len 11 (x000b)
0000 0007 5359 4e4f 4e59 4d | ....SYNONYM
Column 6 (x0006), Len 21 (x0015)
0000 3230 3035 2d30 362d 3330 3a31 393a 3131 3a30 | ..2005-06-30:19:11:0
34 | 4
Column 7 (x0007), Len 21 (x0015)
0000 3230 3035 2d30 362d 3330 3a31 393a 3131 3a30 | ..2005-06-30:19:11:0
34 | 4
Column 8 (x0008), Len 23 (x0017)
0000 0013 3230 3035 2d30 362d 3330 3a31 393a 3131 | ....2005-06-30:19:11
3a30 34 | :04
Column 9 (x0009), Len 9 (x0009)
0000 0005 5641 4c49 44 | ....VALID
Column 10 (x000a), Len 5 (x0005)
0000 0001 4e | ....N
Column 11 (x000b), Len 5 (x0005)
0000 0001 4e | ....N
Column 12 (x000c), Len 5 (x0005)
0000 0001 4e | ....N
Logdump 88 >n
___________________________________________________________________
Hdr-Ind : E (x45) Partition : . (x04)
UndoFlag : . (x00) BeforeAfter: B (x42)
RecLength : 198 (x00c6) IO Time : 2012/08/31 07:35:43.060.853
IOType : 3 (x03) OrigNode : 255 (xff)
TransInd : . (x01) FormatType : R (x52)
SyskeyLen : 0 (x00) Incomplete : . (x00)
AuditRBA : 8 AuditPos : 19678668
Continued : N (x00) RecCount : 1 (x01)
2012/08/31 07:35:43.060.853 Delete Len 198 RBA 38381
Name: ROGER.T
Before Image: Partition 4 G m
0000 0007 0000 0003 5359 5300 0100 1a00 0000 1647 | ........SYS........G
565f 2453 4547 4d45 4e54 5f53 5441 5449 5354 4943 | V_$SEGMENT_STATISTIC
5300 0200 04ff ff00 0000 0300 0800 0000 0432 3035 | S................205
3000 0400 04ff ff00 0000 0500 0800 0000 0456 4945 | 0................VIE
5700 0600 1500 0032 3030 352d 3036 2d33 303a 3139 | W......2005-06-30:19
3a31 313a 3034 0007 0015 0000 3230 3035 2d30 362d | :11:04......2005-06-
3330 3a31 393a 3131 3a30 3400 0800 1700 0000 1332 | 30:19:11:04........2
Column 0 (x0000), Len 7 (x0007)
0000 0003 5359 53 | ....SYS
Column 1 (x0001), Len 26 (x001a)
0000 0016 4756 5f24 5345 474d 454e 545f 5354 4154 | ....GV_$SEGMENT_STAT
4953 5449 4353 | ISTICS
Column 2 (x0002), Len 4 (x0004)
ffff 0000 | ....
Column 3 (x0003), Len 8 (x0008)
0000 0004 3230 3530 | ....2050
Column 4 (x0004), Len 4 (x0004)
ffff 0000 | ....
Column 5 (x0005), Len 8 (x0008)
0000 0004 5649 4557 | ....VIEW
Column 6 (x0006), Len 21 (x0015)
0000 3230 3035 2d30 362d 3330 3a31 393a 3131 3a30 | ..2005-06-30:19:11:0
34 | 4
Column 7 (x0007), Len 21 (x0015)
0000 3230 3035 2d30 362d 3330 3a31 393a 3131 3a30 | ..2005-06-30:19:11:0
34 | 4
Column 8 (x0008), Len 23 (x0017)
0000 0013 3230 3035 2d30 362d 3330 3a31 393a 3131 | ....2005-06-30:19:11
3a30 34 | :04
Column 9 (x0009), Len 9 (x0009)
0000 0005 5641 4c49 44 | ....VALID
Column 10 (x000a), Len 5 (x0005)
0000 0001 4e | ....N
Column 11 (x000b), Len 5 (x0005)
0000 0001 4e | ....N
Column 12 (x000c), Len 5 (x0005)
0000 0001 4e | ....N
由于ogg trail文件都是以事务为单位进行记录的,可以看到,上面的每次n操作的输出信息都是
一条记录,ogg这里确定一个事务是通过IO Time+AuditRBA来确认的,这是惟一的。
下面来完整的解析trail:
Logdump 10 >n
___________________________________________________________________
Hdr-Ind : E (x45) Partition : . (x04)
UndoFlag : . (x00) BeforeAfter: A (x41)
RecLength : 49 (x0031) IO Time : 2012/08/31 06:00:18.737.774
IOType : 15 (x0f) OrigNode : 255 (xff)
TransInd : . (x00) FormatType : R (x52)
SyskeyLen : 0 (x00) Incomplete : . (x00)
AuditRBA : 8 AuditPos : 9637392
Continued : N (x00) RecCount : 1 (x01)
2012/08/31 06:00:18.737.774 FieldComp Len 49 RBA 1600
Name: GGS.MPS
After Image: Partition 4 G b
0000 000a ffff 0000 0000 0000 0000 0007 001f 0000 | ....................
3230 3132 2d30 382d 3331 3a30 363a 3030 3a32 302e | 2012-08-31:06:00:20.
3832 3330 3030 3030 30 | 823000000
Column 0 (x0000), Len 10 (x000a)
ffff 0000 0000 0000 0000 | ..........
Column 7 (x0007), Len 31 (x001f)
0000 3230 3132 2d30 382d 3331 3a30 363a 3030 3a32 | ..2012-08-31:06:00:2
302e 3832 3330 3030 3030 30 | 0.823000000
下面是关于上面输出信息header记录的完整解释:
Hdr-Ind: 该值总是E,表示是extract process创建,如果为其他属性,则表示不可用。
UndoFlag:该属性正常值为0,当为1时则表示先前已经成功的记录进行撤销操作。
这里我不清楚是不是指这种情况:例如一个大事务未commit的情况,数据已经写入
到redo中,而ogg是读取redo进行同步的,在ogg抽取数据以后这个事务又被rollback了。
RecLength:record buffer长度,单位是bytes
IOType:表示操作类型,该属性有如下几种值:
3 - Delete
5 - Insert
10 - Update(full record)
15 - Update(compressed record)
TransInd:事务记录标志,有如下4种可能属性;
x00 - start of transaction
x01 - middle of transaction
x02 - end of transaction
x03 - only record in transaction
SyskeyLen:system key长度。如果system key存在,其第一个bytes表示system key记录,否则该值为0.
AuditRBA:事务record commit地址,同一个事务中,该值均相同。goldengate通过auditRBA+IO Time来确定
一个事务,其值是唯一的。
Continued:该属性有两种值:Y和N,用来定义数据片大大小,通常lob,clob或varchar类型,该值是Y,否则是N。
Partition:该属性是goldengate内部使用的一个标示,并不是指os或数据库层面的逻辑分区和物理分区。windows和unix
平台下,该属性值总是为4。
对于Nonstop的记录,该属性的值取决于如下两个方面:
1)存在Bulk IO操作的情况下,该值表示源端分区已经完成的bulk IO操作的数量。其取值范围为0~15.
2)对于其他非bulk io操作的nonstop record情况下,该属性取值通常为0或4. 为4的情况,表示该数据为
FiledComp record格式 (compress存储格式)。
BeforeAfter: 对于update操作,表示该数据是before image还是after image。对于insert操作,总是after images,
而delete操作总是before images。
IO Time:记录提交时间,同一个事务内的所有记录,该属性值都是相同的,为GMT格式。
OrigNode:Nonstop情况下,表示extract数据抽取端的节点号,整个cluster内,每个节点的节点号都是唯一的。
该属性取值范围是0~255. 除nonstop之外的其他情况,该属性值为0.
FormatType:表示数据是从事务日志读取还是直接从数据库中获取的。取值为F和R,F表示fetched from database。
R表示readable in transaction log。
Incomplete:该属性值从10.4版本就已经废弃了,是向前兼容保留的。
AuditPos: 标示extract process在transaction log中的位置。
RecCount:在windows和unix平台下,ogg处理lob时,是将其split成chunk,然后将chunk写入到file中。
recCount用来表示在读取时对chunk的合并。
对于logdump 看到的record 记录,其实iotype也就4种,3,5,10,15. 其中15表示compress record。
那么如何启用record的压缩存储呢?其实有个参数控制的,那就是auditcompress。
关于ogg中iotype类型,有一个完整的操作列表,如下:
Logdump 72 >show rectype
LogTrail record types
1 - Abort 2 - Commit
3 - Delete 4 - EndRollBack
5 - Insert 6 - Prepared
7 - TMF-Shutdown 8 - TransBegin
9 - TransRelease 10 - Update
11 - UpdateComp 12 - FileAlter
13 - FileCreate 14 - FilePurge
15 - FieldComp 16 - FileRename
17 - AuxPointer 18 - NetworkCommit
19 - NetworkAbort 20 - CurrentPos
90 - GGSSQLCol 100 - GGSPurgedata
108 - GGSPurgedataPartonly 101 - GGSPurgeFile
102 - GGSCreateFile 103 - GGSAlterFile
104 - GGSRenameFile 105 - GGSSetmode
107 - GGSControl 106 - GGSChangeLabel
115 - GGSPKUpdate 117 - GGSPKUpdate32
116 - LargeObject 132 - Sequence OP
150 - RestartAbend 151 - RestartOK
152 - RecoveryEnd 160 - DDLOP
161 - RecordFragment 200 - GGSBulkio
201 - GGSFileClose 202 - GGSLoggerTS
203 - GGSExtractTS 204 - GGSCollectTS
205 - GGSComment 250 - LibOpenTrace
251 - LibCloseTrace 252 - LoggerOpenTrace
253 - LoggerCloseTrace 254 - LoggerAddedInfo
249 - LoggerAddedStats 255 - FileHeader
「喜欢这篇文章,您的关注和赞赏是给作者最好的鼓励」 关注作者 【版权声明】本文为墨天轮用户原创内容,转载时必须标注文章的来源(墨天轮),文章链接,文章作者等基本信息,否则作者和墨天轮有权追究责任。如果您发现墨天轮中有涉嫌抄袭或者侵权的内容,欢迎发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。 评论




