db2fmtlog – Format and display log file information command
Use the db2fmtlog
tool to extract and display information from
transaction log files.
Various types of information can be displayed or inferred, including, but not limited to, the
following information:
- Whether a log file is encrypted or compressed.
- The log chain that a log file is associated to.
- The range of log records in a log file.
- The log records in a log file that would trigger a replay-only window if replayed on an HADR Standby database that is enabled with Reads On Standby (ROS).
Authorization
Anyone can run the command, but you require read permission on the archive log files.Required connection
NoneCommand syntax
Command parameters
- log_file_number_start
- Specifies the numeric identifier of the log file to format. For example, the numeric identifier
of the log file S0000017.LOG log file is 17. If the
log_file_number_end
parameter is also specified, thenlog_file_number_start
represents the first numeric identifier in a range of log files to format. - log_file_number_end
- Specifies the last numeric identifier in a range of log files to format. The value of
log_file_number_end
must be greater than or equal tolog_file_number_start
. - Format options
- If no options are specified, basic information from the log file or files is displayed.
Specification of keystore password information is required for encrypted log files only when the
keystore password is not stashed.
- -lsnrange
- Displays a list of the range of LFS, LSN, and LSO values in the log file or files.
- -replayonlywindow
- Displays each log record that can trigger a replay-only window when replayed on an HADR Standby
database that is enabled with with Reads On Standby.
If the log file or files are encrypted, then this tool must be run in an environment where decryption is possible. This requirement includes access to the native encryption library, and either a stashed keystore password file must be available or a valid keystore password option must be specified.
- -kspassword keystore_password
- Specifies the password to use to open the keystore.
- -kspassarg fd:file_descriptor | filename:filepath
- Specifies the keystore password arguments. The file_descriptor parameter specifies a file descriptor that identifies an open and readable file or pipe that contains the password to use. The filepath parameter specifies the path of the file that contains the password to use.
Examples
- Example 1
- The following example shows the encrypted log file S0000003.LOG formatted
with no options.
$ db2fmtlog 3 Log File S0000003.LOG: Extent Number 3 Format Version 14 Architecture Level Version V:11 R:1 M:3 F:3 I:0 SB:0 Encrypted Yes Compression Mode OFF Number of Pages 4 Partition 0 Log Stream 0 Database Seed 3136515636 Log File Chain ID 0 Master Key Label DB2_SYSGEN_db2admin1_ENCDB_2018-02-06-17.37.48_35002821 Previous Extent ID 2018-02-06-22.39.38.000000 GMT Current Extent ID 2018-02-06-22.39.39.000000 GMT Database log ID 2018-02-06-22.37.49.000000 GMT Topology Life ID 2018-02-06-22.37.49.000000 GMT First LFS/LSN 4173/000000000003F5AF Last LFS/LSN 4185/000000000003F637 LSO range 44884913 to 44901216
- Example 2
- The following example shows the encrypted log files S0000003.LOG to
S0000009.LOG that are formatted with
-lsnrange
option.$ db2fmtlog -lsnrange 3-9 S0000003.LOG: First LFS/LSN 4173/000003F5AF Last LFS/LSN 4185/000003F637 LSO range 44884913 to 44901216 S0000004.LOG: First LFS/LSN 4185/000003F638 Last LFS/LSN 4200/000003F6E9 LSO range 44901217 to 44917520 S0000005.LOG: First LFS/LSN 4200/000003F6EA Last LFS/LSN 4218/000003F76F LSO range 44917521 to 44933824 S0000006.LOG: First LFS/LSN 4218/000003F770 Last LFS/LSN 4236/000003F795 LSO range 44933825 to 44946052 S0000007.LOG: First LFS/LSN 4237/000003F796 Last LFS/LSN 4237/000003F796 LSO range 44950129 to 44954204 S0000008.LOG: First LFS/LSN 4238/000003F797 Last LFS/LSN 4238/000003F797 LSO range 44966433 to 44970508 S0000009.LOG: First LFS/LSN 4239/000003F798 Last LFS/LSN 4247/000003F81A LSO range 44982737 to 44999040
- Example 3
- The following example shows the unencrypted log file S0000004.LOG is
formatted with
-replayonlywindow
option. To use the output of ls as input, '-' is required at the end of the command format "ls *.LOG | db2fmtlog -replayonlywindow - ".$ ls S0000004.LOG | db2fmtlog -replayonlywindow - |------|------------------------------------------------------------------------ | LREC | 4812 0003F9E6 000000000197 |------|------------------------------------------------------------------------ | LREC | Record LSO = 53456514 | | Record TID = 000000000197 | | Action = DDL |------|------------------------------------------------------------------------ | LREC | 4812 0003F9E7 000000000197 |------|------------------------------------------------------------------------ | LREC | Record LSO = 53456942 | | Record TID = 000000000197 | | DDL Statement = create table t5ba.t1 (a int, b long varchar) in t1 |------|------------------------------------------------------------------------ | LREC | 4828 0003FA6F 0000000001CF |------|------------------------------------------------------------------------ | LREC | Record LSO = 53467006 | | Record TID = 0000000001CF | | Action = LOAD |------|------------------------------------------------------------------------ | LREC | 4832 0003FA76 0000000001D0 |------|------------------------------------------------------------------------ | LREC | Record LSO = 53473142 | | Record TID = 0000000001D0 | | Action = LOAD |------|------------------------------------------------------------------------ | LREC | 4839 0003FAD5 0000000001E9 |------|------------------------------------------------------------------------ | LREC | Record LSO = 53489660 | | Record TID = 0000000001E9 | | Action = DDL
- Example 4
- The following example shows the formatting of an encrypted log file that uses
-replayonlywindow
option, but without a keystore password (and no stashed keystore password file is available). When an error is encountered, thedb2fmtlog
command will skip the current log file and resume processing in the next log file.$ db2fmtlog -replayonlywindow 4 Could not retrieve DEK for log file "S0000004.LOG". Reason code: -2141452066, sqlcode: -1728. Processing will resume in the next log file.
- Example 5
- The following example shows how to format an encrypted log file that uses
-replayonlywindow
option with a keystore password specified:$ db2fmtlog -replayonlywindow 4 -kspassword This8Is0Password |------|------------------------------------------------------------------------ | LREC | 4193 0003F6AB 000000000171 |------|------------------------------------------------------------------------ | LREC | Record LSO = 44911967 | | Record TID = 000000000171 | | Action = DDL