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.
About this task
The db2cklog tool reads either single log files or a range
of numbered log files and performs checks on the internal validity
of the files. Log files that pass validation without any error messages
or warnings are known good files and you can use them during a rollforward
recovery operation. If an archive log file fails validation with an
error message or if a warning is returned, then you must not use that
log file during rollforward recovery. An archive log file that fails
validation cannot be repaired and you should follow the response outlined
in this task for what to do next.
Checking your archive log files
is useful in the following scenarios:
- 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.
Before you begin
You need to have read permission on the archive log files,
so that the db2cklog tool can read the log files and perform its checks.
Only log files that are closed, such as archive log files, can be
validated successfully. If you run the tool on a log file that is
still active, the tool cannot check that file accurately and you will
receive a warning to let you know that the file is still active.
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 numerical identifiers that are part
of the log file names. The numerical 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 numerical 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 numerical 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
The db2cklog tool will return a return code of zero for any
file that passes validation. If a range of numbered archive log files
is specified, the db2cklog tool will read each file in sequence, perform
its checks and issue a return code for each file. The tool stops at
the first error it encounters, even if a range of log files was specified
and there are additional files the tool has not yet checked. The DBT
message that is returned when an error is found can provide you with
some more information about why an archive log file failed validation,
but you cannot fix an invalid log file. If you receive a DBT warning
message that a log file might still be active but know for certain
that the file is an archive log file, then you should treat the archive
log file as invalid and follow the response for what to do next outlined
in this task.
Example
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.