IBM Support

[Db2] How to rotate Db2 diagnostic file (db2diag.log)

Question & Answer


Question

Db2 diagnostic log (db2diag.log) is growing. How can I rotate this file ?

Answer

Db2 diagnostic log file (db2diag.log) keeps growing by default. 
The size of the file can grow rapidly, for example when error occurred repeatedly, or some kind of operation such as LOAD was performed many times (Some operations record log records in db2diag.log).
You can take one of the following 2 methods to maintain db2diag.log file.
a) Rotate diagnostic log files by DIAGSIZE parameter (available in V9.7 or later)

You can set DIAGSIZE database configuration parameter, Db2 automatically rotates Db2 diagnostic log (db2diag.log) and administration notification log in specified size of file.
Login to the system as instance owner user ID, then run the following command from command line or DB2 Command Window.

db2 update dbm cfg using DIAGSIZE [size (MB)]
Note: Unit of the file size is MB. You have to restart instance to take effect the change.

In UNIX/Linux systems, 90% of specified size is allocated for Db2 diagnostic log (db2diag.log) file, and rest (10%) for administration notification log.
In Windows systems, all the specified size is uesd for Db2 diagnostic log (db2diag.log) file. Because administration notification log will be recorded in Windows event log.
When DIAGSIZE was set as greater than zero (default), up to 10 log files can be created and rotated. Maximum size of each log file is 1/10 of specified size. So the total size of all Db2 diagnostic log files and administration notification log will not exceed DIAGSIZE value.
 
Note:
There is a know defect in V10.5 Fix Pack 7. Instance may hang when DIAGSIZE was set other than zero.
IT14995: DB2 MAY HANG WHEN USING ROTATING DB2DIAG LOGS
b) Archive the file by db2diag command

Execute db2diag command with -A option. It archives db2diag.log file.

db2diag -A [target directory / file name]
Note: -readfile option is also required if db2diag command was run in a script.

If you do not specify target directory, archived file will be created on the directory where current db2diag.log resides. If you do not specify file name, default file name is db2diag.log-YYYY-MM-DD-hh.mm.ss (where YYYY-MM-DD-hh.mm.ss is the timestamp when db2diag.log -A command was run).
Archiving db2diag.log does not affect any Db2 processing. You can do it while Db2 instance is up and running.

Example:
$ ls -l /home/db2inst1/sqllib/db2dump
total 1918432
-rw-rw-rw-    1 db2inst1 db2group       2084 Oct 18 15:04 db2diag.log

$ db2diag -A
db2diag: Moving "/home/db2dinst1/sqllib/db2dump/db2diag.log"
         to     "/home/db2dinst1/sqllib/db2dump/db2diag.log_2019-10-18-15.07.04"

$ ls -l /home/db2dinst1/sqllib/db2dump
total 1918440
-rw-rw-rw-    1 db2inst1 db2group       2084 Oct 18 15:07 db2diag.log
-rw-rw-rw-    1 db2inst1 db2group       2084 Oct 18 15:04 db2diag.log_2019-10-18-15.07.04

[{"Business Unit":{"code":"BU058","label":"IBM Infrastructure w\/TPS"},"Product":{"code":"SSEPGG","label":"Db2 for Linux, UNIX and Windows"},"Component":"Not Applicable","Platform":[{"code":"PF002","label":"AIX"},{"code":"PF010","label":"HP-UX"},{"code":"PF016","label":"Linux"},{"code":"PF027","label":"Solaris"},{"code":"PF033","label":"Windows"}],"Version":"9.7;9.5;10.1;10.5;11.1;11.5","Edition":"","Line of Business":{"code":"LOB10","label":"Data and AI"}}]

Historical Number

3806B3EFEAC01FD249257690001F524C

Document Information

Modified date:
04 December 2019

UID

ibm11088926