The db2flsn command returns the name of the file in a log stream that contains the log record identified by a specified log sequence number (LSN) or log record identifier (LRI).
Instance owner
>>-db2flsn--+-----+--+- -db--dbname---+--+---------------+------> '- -q-' '- -path--dbpath-' '-| Log paths |-' >--+-+-input_LSN-+--+------------------------+-+----------------> | '-input_LRI-' '-| Range of log files |-' | +-input_LSO---------------------------------+ '- -lsnrange--+-log_number-------------+----' '-| Range of log files |-' >--+-------------------------------------+--------------------->< +- -kspassword--password--------------+ +- -kspassarg--+-fd:file_descriptor-+-+ | '-filename:file_name-' | '- -ksprompt--------------------------' Log paths |--+----------------------------+-------------------------------> '- -logpath--primary_logpath-' >--+-------------------------------+----------------------------| '- -logpath2--secondary_logpath-' Range of log files |--+------------------------+--+----------------------+---------| '- -startlog--log_number-' '- -endlog--log_number-'
db2flsn 000000BF0030
Given LSN is contained in log file S0000002.LOG
db2flsn -q 000000BF0030
S0000002.LOG
db2flsn -db flsntest 0000000000FA0000
Given LSN is contained in log file S0000002.LOG
db2flsn -q -db flsntest 0000000000FA0000
S0000002.LOG
db2flsn -path /db2/NODE0000/SQL00001 0000000000FA4368
Given LSN is contained in log file S0000002.LOG
Using -lsnrange option:
db2flsn -lsnrange -startlog 20 -endlog 27
S0000020.LOG: has LSN range 0000000000023B3D to 0000000000023E0A
S0000021.LOG: has LSN range 0000000000023E0B to 00000000000240D8
S0000022.LOG: is not empty, but has no log records starting within its boundaries.
S0000023.LOG: has LSN range 00000000000240D9 to 00000000000243B9
S0000024.LOG: is unused/blank.
S0000025.LOG: is unused/blank.
S0000026.LOG: could not be opened or was invalid. Check file permissions.
S0000027.LOG: could not be opened or was invalid. Check file permissions.
Warning messages when an LSN could not be found, but it cannot be in
an earlier log file:
db2flsn 00000000000243D7
Input LSN 00000000000243D7 is within or after log file S0000023.LOG:
S0000023.LOG: Log file starts with LSN 00000000000243BA.
S0000024.LOG: Log file could not be opened or was invalid/unused.
Log paths used:
(./LOGSTREAM0000) and
().
If this is not the end of the log stream, retrieve more log files into a
temporary directory (to avoid overwriting active log files) and re-run
db2flsn tool with -logpath2 option to use the log files from that temporary
directory as well. Check access permissions on log files to make sure db2flsn
can open necessary log files.
To see the first LSN of a log file, use the -lsnrange option:
db2flsn -lsnrange <log file number> -logpath2 <temp log dir>
To see the first LSN of a set of log files, use:
db2flsn -lsnrange -logpath2 <temp log dir> \
-startlog <first log> -endlog <end log>
db2flsn -q 00000000000243D7
S0000023.LOG
=> Return code is: 100 (Warning, the LSN could be in a later log file,
returning the last file that db2flsn could open).
db2flsn 00000000000243D7 -endlog 23
Input LSN 00000000000243D7 is after log file S0000023.LOG.
This log file has LSN range 00000000000243BA - 00000000000243D6.
To find the exact log file, try a larger value for the -endlog parameter.
Log paths used:
(./LOGSTREAM0000) and
().
To see the first LSN of a log file, use the -lsnrange option:
db2flsn -lsnrange <log file number> -logpath2 <temp log dir>
To see the first LSN of a set of log files, use:
db2flsn -lsnrange -logpath2 <temp log dir> \
-startlog <first log> -endlog <end log>
db2flsn -q 00000000000243D7 -endlog 23
S0000023.LOG
=> Return code is: 101 (Warning, LSN could be in a later log file, returning
the file specified by -endlog parameter. To find the exact file, use a larger
value for the -endlog parameter.)
db2flsn -lsnrange 23
S0000023.LOG: has LSN range 00000000000243BA to 00000000000243D6
=> This shows that LSN 00000000000243D7 has not been produced yet on this log
stream. However, when it is generated, this LSN is guaranteed that it cannot be
in a log file before S0000023.LOG.
Error messages, when an LSN could not be found. In this example, S0000000.LOG
has already been archived and not found in history file either:
db2flsn 000000000000001
Input LSN 0000000000000001 could not be found. Input LSN is before the earliest
LSN found 0000000000021E6B:
S0000001.LOG: Log file starts with LSN 0000000000021E6B.
S0000000.LOG: Log file could not be opened or was invalid/unused.
Log paths used:
(./LOGSTREAM0000) and
().
Retrieve log files before S0000001.LOG into a temporary directory (to avoid
overwriting active log files) and re-run db2flsn tool with -logpath2 option to
include the log files from that temporary directory:
db2flsn <LSN> -db <db> -logpath2 <temp log dir> -startlog <first log>
-endlog <last log>
To see the first LSN of a log file, use the -lsnrange option:
db2flsn -lsnrange <log file number> -logpath2 <temp log dir>
To see the first LSN of a set of log files, use:
db2flsn -lsnrange -logpath2 <temp log dir> \
-startlog <first log> -endlog <eng log>
db2flsn -q 000000000000001
=> with "-q" option, no output is produced as the log file could not be found.
Error code returned is -108 (The LSN is before the earliest log file db2flsn
could open).
db2flsn 000000000000001 -startlog 1
Input LSN(0000000000000001) is before log file S0000001.LOG. This log file starts
with LSN 0000000000021E6B.
Log paths used:
(./LOGSTREAM0000) and
().
To see the first LSN of a log file, use the -lsnrange option:
db2flsn -lsnrange <log file number> -logpath2 <temp log dir>
To see the first LSN of a set of log files, use:
db2flsn -lsnrange -logpath2 <temp log dir> \
-startlog <first log> -endlog <end log>
db2flsn -q 000000000000001 -startlog 1
=> with "-q" option, no output is produced as the log file could not be found.
Error code returned is -109 (The LSN is before the log specified by -startlog
parameter.)