Keeping archived logs for the agent¶
A Db2 for LUW Capture Agent reads the archived log files, so they must stay until it has read them.
Archived log files accumulate until something deletes them, and both too few and too many cause trouble: if a file the
agent still needs is deleted, all its subscriptions need a new baseline; if years of files pile up, Db2 gets slow at
retrieving the ones the agent needs (see Capture slows down when the database is
busy). Delete archived logs regularly, and only those the agent has
read. Stelo Support can also supply a log exit program that keeps archived logs until the agent has read them
(properties managedLogs and archivedLogPath).
Which files the agent has read. db2flsn lists the log sequence number (LSN) range of each log file, for example:
db2flsn -db MYDB -lsnrange -startlog 0 -endlog 128
S0000000.LOG: has LSN range 0000000027FBC8BA to 0000000027FC775E
S0000001.LOG: has LSN range 0000000027FC775F to 0000000027FD25BE
Compare them with the agent's log position on its Summary tab: its last 16 digits are the LSN the agent is at. Files whose whole range is lower can go.
Delete them after a backup. db2 prune history with and delete deletes the archived logs older than a
timestamp that recovery no longer needs, so run it after a backup, for example for those older than March 1, 2026:
db2 connect to MYDB
db2 prune history 20260301000000 and delete
A scheduled job that runs shortly before midnight can delete the logs older than that day, assuming the agent runs and has read them. On a Windows database server, a batch file for the Task Scheduler (it doesn't need a Db2 command window):
set DB2DIR=C:\Program Files\IBM\SQLLIB
set DB2=%DB2DIR%\bin\db2
set DB2CLP=DB20FADE
set DB2INSTANCE=DB2
set DB=MYDB
for /f "tokens=1-5 delims=/ " %%d in ("%date%") do set CURRENTDATE=%%g%%e%%f
"%DB2%" connect to %DB%
"%DB2%" prune history %CURRENTDATE% with force option and delete
"%DB2%" disconnect %DB%
The for line builds the date as YYYYMMDD from a %date% like Wed 11/11/2026; adjust it to your system's date
format. On a Linux or UNIX database server, the same as a shell script run by the instance owner's cron (for
example 45 23 * * *):
DB=MYDB
CURRENTDATE=$(date +%Y%m%d)
. /home/db2inst1/sqllib/db2profile
db2 connect to $DB
db2 prune history $CURRENTDATE with force option and delete
db2 disconnect $DB
Overflow log path (recommended)¶
When the agent needs a log file that Db2 has already archived, Db2 first retrieves it from the archive. On a busy
database this slows capture down, and db2diag.log often shows "ADM1843I Started retrieve for log file". If the
database archives its logs to disk, point OVERFLOWLOGPATH at the archive directory, so that Db2 reads the archived
files where they are. This works only when the archived files aren't compressed (LOGARCHCOMPR1 is OFF).
-
Check
LOGARCHMETH1andLOGARCHCOMPR1:db2 get db cfg for MYDB -
Db2 keeps the archived files in subdirectories of the
LOGARCHMETH1path, by instance and database. ForLOGARCHMETH1DISK:/db2archlogs, instancedb2inst1and databaseMYDB:db2 update db cfg for MYDB using OVERFLOWLOGPATH /db2archlogs/db2inst1/MYDBAfterwards
OVERFLOWLOGPATHshows the full path, for example/db2archlogs/db2inst1/MYDB/NODE0000/LOGSTREAM0000/.
See Using an overflow log path in the Db2 documentation.