Adsense

Thursday, May 14, 2015

db2diag log file path location and how to change location, size and reset db2diag.log file

db2diag.log file is useful for DBA for trouble shooting the database.  All errors, warnings, event messages, and administration notification messages  starting from installation are captured in the db2diag.log file. Also any failure in the db2 server / database are captured in db2diag.log file. DBA  can use this log file and trace. 

We can use db2diag tool with various options for reading and displaying db2diag.log file.

db2diag.log grows indefinitely. db2diag.log can either be a single file or a rotating file with fixed size  depending upon the database configuration made.

Now let us see where the db2diag.log file is stored in Windows and Linux by default.

In Windows (Vista or any Latest OS)

C:\ProgramData\IBM\DB2\<DB2 COPY NAME>\DB2\DIAG0000

eg. C:\ProgramData\IBM\DB2\DB2COPY1\DB2\DIAG0000

where ProgramData is hidden folder.

In Windows (XP or any Old OS)

C:\Documents and Settings\All Users\Application Data\IBM\DB2\<DB2 copy name>\DB2\DIAG0000


You can retrieve the DIAGPATH  from dbm configuration using the command

db2 get dbm cfg | find/I "diagpath"   in windows.



In Linux :

/home/db2inst1/sqllib/db2dump


Get the current diagpath using command in Linux.


db2 get dbm cfg | grep -i "diagpath"   


1. How to change the default path location of db2diag.log?

Command to change db2diag.log location:

db2 update dbm cfg using DIAGPATH local_path

For Eg in Windows, I issued the following command.

C:\Program Files\IBM\SQLLIB_01\BIN>db2 update dbm cfg using DIAGPATH c:/db2log
DB20000I  The UPDATE DATABASE MANAGER CONFIGURATION command completed
successfully.

Now restart the db2 server.

db2 get dbm cfg | find/I "diagpath"
 Diagnostic data directory path               (DIAGPATH) = c:\db2log\
 Current member resolved DIAGPATH                        = c:\db2log\


2. How to reset the db2diag.log file?


If db2diag.log file is single file, it grows indefinitely. You can reset at point of time so that the content of the file is moved to db2diag.log_current_timestamp and  new db2diag.log file is created.

To reset, use the db2diag tool with the option A

db2diag -A

For Example :

c:\ProgramData\IBM\DB2\DB2COPY2\DB2\DIAG0000>db2diag -A db2diag.log
db2diag: Moving "c:\ProgramData\IBM\DB2\DB2COPY2\DB2\DIAG0000\db2diag.log"
         to     "c:\ProgramData\IBM\DB2\DB2COPY2\DB2\DIAG0000\db2diag.log_2015-05-12-08.20.34"



3. How to make db2diag.log  a rotating file with fixed size?


Simply set the size of the db2diag.log file using the below command.

db2 update dbm cfg using DIAGSIZE 10

Now the size of the log file size is fixed to 10 MB. The rotating file starts with db2diag0.log

C:\db2log>db2 get dbm cfg | find/I "diagsize"
 Size of rotating db2diag & notify logs (MB)  (DIAGSIZE) = 10

0 comments:

Post a Comment