當我們對db2記憶體使用量清理進行監控檢查的時候,經常需要知道db2當前的記憶體使用量情況。通過參數instance_memory並不能準確的看到這些資訊,因為instance_memory包括了mon_heap, audit_buf_sz and FCM, database shared memory segment (bufferpool, locklist, dbheap, pckcache, util_heap, catalogcache)這些記憶體池集合,而db2mtrk就可以指定資料庫和執行個體層級查看即時的記憶體使用量情況
所以在DB2中,db2mtrk工具就是一個查看當前記憶體使用量情況的非常好的的工具。
db2mtrk的命令文法:(unix,linux,window平台之間可能有稍許差異)
db2inst1@marven ~]$ db2mtrk -h
Usage: db2mtrk -i | -d | -a | -p [-m | -w] [-v] [-r interval [count]] [-h]
-i Display instance level memory usage
-d Display database level memory usage
-a Display application level memory usage
-p Display agent private memory usage
-m Display maximum usage information
-w Display watermark usage information
-v Display verbose memory usage information
-r Run in repeat mode
interval Amount of seconds to wait between reports
count Number of reports to generate before quitting
-h Display this help screen
Notes:
1. One of -i -d -a -p must be specified.
2. The -w and -m flags are optional. An invocation of the application
is invalid if both flags are specified.
3. The -m flag reports the maximum allowable size for a given heap
while the -w flag reports the largest amount of memory allocated
from a given heap at some point in its history.
Usage scenarios:
db2mtrk -i -d
Report current memory usage for instance and all databases
db2mtrk -i -p -m
Report maximum allowable size for instance and agent private memory
db2mtrk -p -r 1 5
Report agent private memory five times at one second intervals
Heap Legend:
When running in normal mode (i.e. -v flag not specified) heaps are named
using the following codes:
agsh - Application Group Shared Heap lockh - Lock Manager Heap
appctlh - Application Control Heap monh - Database Monitor Heap
apph - Application Heap other - Other Memory
appshrh - Applications Shared Heap pckcacheh - Package Cache
bph - Buffer Pool Heap queryh - Query Heap
catcacheh - Catalog Cache Heap shsorth - Shared Sort Heap
dbh - Database Heap sorth - Sort Heap
dlfmh - DFM Heap stath - Statistics Heap
fcmbp - FCMBP Heap stmth - Statement Heap
ip - Import Pool utilh - Backup/Restore/Util Heap
-m 參數選項是顯示最大的記憶體使用量上線
-w 參數選項是顯示使用過程中記憶體達到的最大值,既watermark
-r 參數選項是重複顯示 interval是重複顯示的時間間隔數 count是要重複顯示的次數