Checking archive log files with the db2cklog tool
Checking your archive log files ensures that known good log files are available in case a rollforward recovery becomes necessary and that the recovery operation does not fail because of a problem with a log file. The information in this topic tells you how to check log files with the db2cklog tool, and what to do if a log file does fail validation.
Before you begin
About this task
- Immediately before a rollforward operation is started: If it becomes necessary to perform a rollforward recovery operation, you can first run the db2cklog tool against all the archive log files that are required to perform the rollforward operation to ensure that the log files are valid. Running the db2cklog tool against the log files beforehand helps avoid a situation where a recovery operation fails partway through because of a problem with a log file, necessitating a follow-on recovery operation.
- Every time a log file is closed and copied to the log archive directory: As part of your day-to-day operations, archive log files can be checked as an added precaution to make sure that known good log files are always available. With this preventive measure, you know right away whether you need to locate a copy of a log file or if a full database backup to establish a new recovery point is needed. This helps to reduce any delay in the event that a rollforward recovery becomes necessary.
Procedure
To check your archive log files, you issue the db2cklog command
from the command line and include the log file or files you want checked.
Note that you do not specify full log file names with the db2cklog command
but only the numeric identifiers that are part of the log file names.
The numeric identifier of the S0000001.LOG log
file is 1, for example; to check that log
file, you specify db2cklog 1
. If the archive log
files are not in the current directory, include the relative or absolute
path to the log files with the optional ARCHLOGPATH parameter.
- If you want to check the validity of a single archive log
file, you specify the numeric identifier of that log file as log-file-number1 with
the command. For example, to check the validity of the S0000000.LOG log
file in the /home/amytang/tests directory, you
issue the command
db2cklog 0 ARCHLOGPATH /home/amytang/tests
. - If you want to check the validity of a range of archive
log files, you include the first and last numeric identifier of that
range with the command (from log-file-number1 to log-file-number2).
All log files in the range are checked, unless the upper end of the
range specified with log-file-number2 is numerically
lower than the beginning of the range (specified with log-file-number1).
In that case, only log-file-number1 is checked.
For example, to check the validity of the log files ranging from S0000000.LOG to S0000005.LOG in
the /home/nrichers/tests directory, you issue
the command
db2cklog 0 TO 5 ARCHLOGPATH /home/nrichers/tests
Results
Examples
The following example shows the typical output of the db2cklog command as it parses a log file, in this case S0000002.LOG. This file passes validation with a return code of zero.$ db2cklog 2
____________________________________________________________________
_____ D B 2 C K L O G _____
Db2 Check Log File tool
I B M
The db2cklog tool is a utility can be used to test the integrity
of an archive log file and to determine whether or not the log file
can be used in the rollforward database command.
____________________________________________________________________
________________________________________________________________________________
========================================================
"db2cklog": Processing log file header of "S0000002.LOG"
"db2cklog": Processing log pages of "S0000002.LOG" (total log pages: "316840")
==> page "1" ...
==> page "25001" ...
==> page "50001" ...
==> page "75001" ...
==> page "100001" ...
==> page "125001" ...
==> page "150001" ...
==> page "175001" ...
==> page "200001" ...
==> page "225001" ...
==> page "250001" ...
==> page "275001" ...
==> page "300001" ...
"db2cklog": Finished processing log file "S0000002.LOG". Return code: "0".
========================================================
What to do next
If an archive log file fails validation, your response depends on whether or not you have a copy of the log file that can pass validation by the db2cklog tool. If you are not sure whether you have a copy of the log file, check the setting for the logarchmeth2 configuration parameter, which determines whether your database server archives a secondary copy of each log file. If you are validating logs as they are being archive and log mirroring is also configured on your data server, you might still be able to locate a copy of the log file in the log mirror path, as your data server does not recycle log files immediately after archiving.
- If you have a copy of the archive log file, use the db2cklog command against that copy. If the copy of the log file passes validation, replace the log file that cannot be read with the valid copy of the log file.
- If you have only one copy of the archive log file and that copy cannot be validated, the log file is beyond repair and cannot be used for rollforward recovery purposes. In this case, you must make a full database backup as soon as possible to establish a new, more recent recovery point that does not depend on the unusable log file for rollforward recovery.