Professional Documents
Culture Documents
LUW 4 - DAMA-UPC - IBM - db2pd - Monitoring PDF
LUW 4 - DAMA-UPC - IBM - db2pd - Monitoring PDF
db2pd -db <database> - tells how long the database has been active
db2pd -db sample
Database Partition 0 -- Database SAMPLE -- Active -- Up 0 days 19:11:07
db2pd -alldbs
Database Partition 0 -- Database XMLDB -- Active -- Up 0 days 19:11:25
Database Partition 0 -- Database SAMPLE -- Active -- Up 0 days 19:11:43
8
5
2
2
Address
AppHandl [nod-index] AgentPid
Priority
Type
State
ClientPid Userid
ClientNm Rowsread
Rowswrtn
LkTmOt
DBName
0x0780000001A35540 0
[000-00000] 2809968
0
Idle
n/a
n/a
n/a
0
0
NotSet
n/a
0x0780000001A16A00 1406
[000-01406] 1134686
0
Coord
Inst-Active 598024
dabrashk db2bp
2
0
NotSet
SAMPLE
0x0780000001A17460 581
[000-00581] 884778
0
Coord
Inst-Active 2969776
dabrashk db2bp
14
0
NotSet
SAMPLE
0x0780000001A34AE0 0
[000-00000] 2076776
0
Coord
Pooled
n/a
n/a
n/a
0
0
NotSet
SAMPLE
ClientPid
1130588
1675376
Userid
ClientNm Rowsread
jmcmahon db2bp
18943
jmcmahon db2bp
3489
Rowswrtn
23998
9898
DBName
SAMPLE
SAMPLE
AppHandl AgentPid
120
1605826
13
1085632
ClientPid
1130588
1675376
Userid
ClientNm Rowsread
jmcmahon db2bp
98941
jmcmahon db2bp
4100
Rowswrtn
100091
9898
DBName
SAMPLE
SAMPLE
AppHandl AgentPid
120
1605826
13
1085632
ClientPid
1130588
1675376
Userid
ClientNm Rowsread
jmcmahon db2bp
100999
jmcmahon db2bp
6777
Rowswrtn
230448
9898
DBName
SAMPLE
SAMPLE
Repeat option is handy for watching activities. Example above watches agents
reads and writes
Combine -repeat option with the file redirection
db2pd -age file=agents.out -rep 10 3
EffISO
1
1
NumEnv
2
NumVar
2
NumRef
4
NumExe
3
Text
create
select
sqltext script
Uses insert time as reported by db2pd dynamic SQL Variations section.
10
11
12
System Information:
AIX
mymachine
5
2
000ABCD123
CPU Information:
TotalCPU
OnlineCPU
4
4
ConfigCPU
4
Speed(MHz)
1453
HMTDegree
1
FreeSwap
16366
Free
38907
ShmIds
131072
ShmSeg
0
13
14
Latch tracking
Purpose: To track latch ownership
Snapshot monitoring
Purpose: To understand point in time status of queries or
entities in the DB2 engine
DB2 trace
To investigate possible movement in DB2 agents
15
0
0
-2146435004
0
0
Not Set
Not Set
0
1
0x4A1
Error code catch flag enabled
Execute sqllib/db2cos callout script
Produce stack trace in db2diag.log
16
Produce dump file and stack trace for all PIDs or chosen PID
db2pd -dump [all|<pid>]
17
LOC
529
LatchType
2254
5169
Filename
sqlbilatch.C
LOC
1150
LatchType
SQLO_LT_SQLB_POOL_CB__writeLatch
Latch Waiters:
Address
Filename
LOC
LatchType
Waiter
18
If status is UOW Waiting, the hang is not occurring at the DB2 server
The client application should be investigated to find out what it is waiting for.
In DPF environment, this may indicate a problem with another partition
Exception is the case when the application being waited on is in UOW Executing and making
no progress
If status is Executing yet no counters are increasing, then the agent or agents
servicing the application may be in an abnormal state
19
Lockname
Type
00020003000000040000000052 Row
00020003000000040000000052 Row
Show locks with a wait status and their waiter (v8.2 FP9)
Lockname
000200040000000D0000000052
00020003000000270000000052
00020003000000270000000052
Type
Row
Row
Row
Mode
.NS
.NS
..X
Sts
W
W
G
Owner
3
0
2
Dur
1
1
1
HldCnt
0
0
0
Att
0
0
8
Rlse
0x0
0x0
0x40
20
Type
Row
TbspaceID 2 TableID 3 RecordID 0x1A
Row
TbspaceID 2 TableID 3 RecordID 0x1F
Internal P Pkg UniqueID 53514c43 32453036 Name c8324abc
Internal P Pkg UniqueID 53514c43 32453036 Name c8324abc
Row
TbspaceID 2 TableID 13 RecordID 0x5
Table
TbspaceID 2 TableID 3
Table
TbspaceID 2 TableID 13
21
22
Bufferpool Statistics for all bufferpools (when BUFFERPOOL monitor switch is ON):
BPID DatLRds
DatPRds
TmpIdxPRds HitRatio
1
78
22
00.00%
IdxPRds
HitRatio TmpIdxLRds
71.79%
58
42.00%
BPID DataWrts
1
0
IdxWrts
0
DirRds
42
BPID AsDatRds
1
0
AsDatRdReq AsIdxRds
0
0
AsIdxRdReq AsRdTime
0
0
BPID TotRdTime
UnRdPFetch
1
104
TotWrtTime VectIORds
VectIOReq
FilesClose NoVictAvl
0
DirRdReqs
5
00.00%
DirRdTime
0
100
DirWrts
0
DirWrtReqs DirWrtTime
0
0
AsDatWrts
0
AsIdxWrts
0
AsWrtTime
0
23
Name
PageSz
PA-NumPgs BA-NumPgs
PgsToRemov CurrentSz PostAlter SuspndTSCt
IBMSYSTEMBP32K
32768
16
0
16
16
0
24
Allows user to check how many pages each object (table, index, etc) has
within any particular bufferpool
Similar to IDS's onstat -b option
25
ObjClass ObjType
Dirty
6
0
0
1
2
0
4
0
1
7
8
9
10
Perm
Perm
Perm
Perm
Perm
Perm
Perm
Perm
Perm
Perm
Perm
Perm
Perm
N
N
N
N
N
N
N
N
N
N
N
N
N
19
19
19
19
19
1
19
19
87
19
19
19
19
6
0
0
1
2
0
4
0
1
7
8
9
10
Index
LOBA
Index
Index
Index
Data
Index
Data
Index
Index
Index
Index
Index
N
N
N
N
N
N
N
N
N
N
N
N
N
26
Defaults
Up to 10 catch points simultaneously
Error catch array is full. Use 'clear' suboption to clear an element"
Up to 255 invocations
Max Count:
255
27
Stats:
TableID TableName SchemaNm ID RootSplits Scans KeyUpdates Merg
2
SYSTABLES SYSIBM
6 0
0
0
0
2
SYSTABLES SYSIBM
5 0
0
0
0
Scans
The number of scans against the index
28
29
1 SYSUSERAUTH
30
4
464
StartLSN
State
Size
0x000000FA0000 0x00000000 1000
Pages
597
1000
1000
Filename
32
5
846
Success
5
n/a
Success
5
n/a
StartLSN
0x000001B58000
0x000001F40000
0x000002328000
State
0x00000000
0x00000000
0x00000000
Size
1000
1000
1000
Pages
1000
1000
1000
Filename
S0000002.LOG
S0000003.LOG
S0000004.LOG
33
UsablePgs UsedPgs
224 96
db2 "insert into staff3 select * from staff
repeat
db2pd -db sample -tab 6 | perl -ane 'if (/TotalPgs * UsablePgs/ .. /^$/) { print "$F[2]
$F[3]\n" } '
UsablePgs UsedPgs
224 160
34
AnchID StmtUID
EnvID
0x0780000020CEBC40 41
CS
0x0780000020BB5D80 42
CS
0x0780000020CE2FC0 235
RR
db2pd -activestatements
EffISO column
0=RR,1=CS,2=UR and 3=RS
Will setting DB2_EVALUNCOMMITTED to ON help?
DB2_EVALUNCOMMITTED enables deferred locking
available if application is using cursor stability or read stability
35
0x07800000000003C0 DBMS
eduah
72
114688
114688
0x07800000100003C0 FMP
undefh
59
786432
245170176
Size
56639488
245284864
134906824
Overhead
PhyHWM
193888
1507328
2496
114688
48000
786432
Key
0x59FE1161
0x0
0x59FE1174
LogSz
1290312
DBP
0
0
0
Type
0
2
-1
LogUpBnd
Bnd BlkCnt CfgParm
1953864
Ovf 0
n/a
112032
Ovf 0
737400
Phy 0
112064
n/a
245163840
n/a
Ov
Y
N
N
OvSize
8241152
0
0
LogHWM
1290312
112032
737400
36
PoolID
PoolName
TotalSize(Bytes)
TotalCount LOC
File
57
ostrack
5160048
3047
698130716
57
ostrack
240048
3034
698130716
57
ostrack
240
2983
698130716
57
ostrack
80
2999
698130716
57
ostrack
80
2970
698130716
57
ostrack
80
3009
698130716
Final section sorts the consumers of memory for the entire set
All memory consumers in DBMS memory set:
PoolID
PoolName
TotalSize(Bytes)
File
57
ostrack
5160048
71.90
0.07
3047
698130716
50
sqlch
778496
10.85
0.07
202
2576467555
50
sqlch
271784
3.79
0.07
260
2576467555
57
ostrack
240048
3.34
0.07
3034
698130716
50
sqlch
144464
2.01
0.07
217
2576467555
69
krcbh
73640
1.03
0.36
547
4210081592
37
39
Phase
CurCount MaxCount Type
Replace 0
2
Offline
Completion field
success indicator for the table reorganization. Possible values:
0. The table reorganization completed successfully
-1. The table reorganization failed
40
0x00000401
S0000000.LOG
000000BB800C
ROLLFORWARD RECOVERY
2
Database Rollforward Recovery
User
2
1
Progress:
PhaseNum Description StartTime
CompletedWork TotalWork
1
Forward
Wed May 5 10:48:09 2004 0 bytes
Unknown
2
Backward
NotStarted
0 bytes
Unknown
Monitoring recovery
db2pd recovery shows several counters to make sure recovery is progressing:
Current Log and Current LSN provide the log position
41
SchemaNm Scans
Inserts
SESSION
124
Type Content AS
BufIDDisk
DMS UsrTmp No
Containers:
Address
TspId ContainNum Type
Container
0x0000000220377CE0 4
0
File
/export/home/jmcmahon/tempspace2a
AR
PageSize
ExtentSize Auto
No
4096
32
Yes
32
9952
42
1072198
1271398
0
7540
3981
3924
2459
57
NumExe
2
24
43
44
SchemaNm ObjClass
n/a
<JMC Temp
n/a
<JMC Temp
n/a
<JMC Temp
TableName
TEMP (00001,00002)
TEMP (00001,00003)
TEMP (00001,00004)
Scans
0
0
0
UDI
0
0
0
PgReorgs
0
0
0
NoChgUpdts
0
0
0
Reads
0
0
0
FscrUpdates
0
0
0
Inserts ...
43219 ...
42485 ...
0
...
45
UsablePgs
UsedPgs
State
6516
6516
0x00000000
IncSize
0
LRF
No
46
db2pd fmp
FMP:
Pool Size:
Max Pool Size:
Keep FMP:
Initialized:
Trusted Path:
Fenced User:
1
250
YES
YES
/home/dabrashk/sqllib/function/unfenced
nobody
FMP Process:
Address
FmpPid
0x07800000007A5FE0 6455492
Bit
64
Flags
ActiveThrd PooledThrd Active
0x00000000 0
0
No
Active Threads:
Address
FmpPid
No active threads.
EduPid
Pooled Threads:
Address
FmpPid
No pooled threads.
ThreadId
ThreadId
47
The output will now contain FCM channel usage statistics, including
the high and low water mark values with respect to the number of
channels used.
49
50
Summary
Understanding requirements for PD and monitoring
Different monitoring scenarios
Tools available in v8.2 and v9.1
db2pd - Monitor and troubleshoot DB2 Universal Database Command
Options either added or extended for each release/fixpack
Proactive FFDC: catching errors
Questions
51
Appendix
52
Light-weight, web-based console for DB2 for Linux, UNIX and Windows
http://sourceforge.net/projects/db2mc
Help: http://sourceforge.net/docman/?group_id=211760
The user interface is character-based and built using the curses library
Unix only
http://dl.alphaworks.ibm.com/technologies/db2top/db2top.pdf
54
db2set DB2_CAPTURE_LOCKTIMEOUT=ON
db2set DB2_CAPTURE_LOCKTIMEOUT=
55
Lock in contention
Lock Requestor
Lock owner or representative
There can be more than one lock owner: the first lock owner is the representative for other lock owners
Report file is generated by the agent receiving the lock timeout error
When the lock timeout reporting function is active and a lock timeout occurs
par is the database partition number. In non-partitioned database environments, par is set to 0.
AGENTID is the agent ID.
yyyy-mm-dd-hh-mm-ss is the time stamp, consisting of the year, month, day, hour, minute, and second.
An example of a lock timeout report file name is
/home/juntang/sqllib/db2dump/db2locktimeout.000.4944050.2006-08-11-11-09-43.
56
Monitoring STMM
http://www.ibm.com/developerworks/db2/library/techarticle/dm-0708naqvi/
57
58
db2top tool
The user interface is character-based and built using the curses library
Unix only
Uses the DB2 snapshot monitoring APIs to retrieve data
aggregation
quick drill-down capabilities
db2top info
db2top h
http://dl.alphaworks.ibm.com/technologies/db2top/db2top.pdf
60
61
62
db2top example
Bufferpool snapshot
b command
lqqqqqqqqqqqqqqwqqqqqqqqqqqqwqqqqqqqqqqqqwqqqqqqqqqqqqwqqqqqqqqqqqk
x
x
25%x
50%x
75%x
100%x
xHit Ratio%
x--------------------------------------------------x
mqqqqqqqqqqqqqqvqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqj
Bufferpool
Delta
Delta
Hit
Async
Delta
Name
l_reads/s
p_reads/s Ratio% Reads%
Writes/s
--------------- ------------ ------------ ------- ------- -----------IBMDEFAULTBP
23015
241 98.95% 100.00%
212
IBMSYSTEMBP16K
0
0
0.00%
0.00%
0
IBMSYSTEMBP32K
0
0
0.00%
0.00%
0
IBMSYSTEMBP4K
0
0
0.00%
0.00%
0
IBMSYSTEMBP8K
0
0
0.00%
0.00%
0
63
Bufferpool performance
db2top -d sample -A -b b
--- Top twenty performance report for 'Bufferpools' between 13:19:52 and 13:20:18
-- Sort criteria 'Pages_VctIOs/s'
-Rank
----1
2
3
4
5
Bufferpool_Name
Percentage fromTime toTime
sum(Pages_VctIOs/s)
------------------------------ ----------- -------- --------- -----------------------------IBMDEFAULTBP
100.0000% 13:19:52 13:20:18
18
IBMSYSTEMBP8K
0.0000% 13:19:52 13:20:18
0
IBMSYSTEMBP4K
0.0000% 13:19:52 13:20:18
0
IBMSYSTEMBP16K
0.0000% 13:19:52 13:20:18
0
IBMSYSTEMBP32K
0.0000% 13:19:52 13:20:18
0
64
db2top -C -d sample
Start collection
Answer N to create named pipe question
db2top -f db2snap-sample-AIX64.bin -d sample
Replay collection in another window
db2top does not need to attach to the DB2 instance in replay mode
65
-=>
=>
=>
=>
=>
=>
=>
=>
=>
=>
=>
=>
=>
Server
Top
Resource Resource
Resource
Agent
Usage
Value
------------ -------- -------- ---------------Cpu
N/A
0%
0
SessionCpu
1223
99.87%
4.844
IO r/w
1223 100.00%
4894
Memory
1223
50.00%
384.0K
Locks
N/A
0%
0
Sorts
N/A
0%
0
Sort Time
N/A
0%
0
Log Used
1223 100.00%
2.1M
Overflows
N/A
0%
0
RowsRead
1223 100.00%
8960
RowsWritten
1223 100.00%
8960
TQ r/w
N/A
0%
0
MaxQueryCost
N/A
0%
0
Application
Name
-------------------N/A
db2bp
db2bp
db2bp
N/A
N/A
N/A
db2bp
N/A
db2bp
db2bp
N/A
N/A
66
db2pdcfg tool
69
71
72
Diagnosing traps
db2cos48621401.0
You can edit the db2cos script to collect more or less information
74
db2diag -g "funcname=pdInvokeCalloutScript
Specify how long to sleep between checking the size of the output file generated by
db2cos
Specify how long of a timeout when checking if the output file generated by db2cos is
growing in size
75
76
77
New options
-bufferpools command: Bufferpool ID that contains the page
-fcm command: high water mark option (hwm)
78
Applications
Transactions
Locks
Tablespaces/Containers
79
Backup slides
80
81
When IP address or port number begin with 0-9, they are changed to G-P respectively.
For example, "0" is mapped to "G", "1 is mapped to "H", and so on.
The IP address, AC10150C.NA04.006D07064947 is interpreted as follows:
The port number is NA04. The first character is "N", which maps to "7". Therefore, port number
is 7A04, which translates to 31236 in decimal form.
The IP address and port can be used with lsof to find out which remote application is
using the application ID
IP Address
Port
Generated ID
AC10150C.NA04.006D07064947
82