DB2 Archivelog

Da Emigar.
Jump to navigation Jump to search

HOW TO clear inactive DB2 LUW transaction log files

21 September,2016 by Tom Collins

How to clear inactive DB2 LUW transaction log files is a solution to a common problem. Before we discuss how to prune the inactive transaction logs we’ll need to establish which log files are inactive.

It is important to identify which logs to delete. If you delete an active transaction log file, you will cause an outage on the database

Note: Log files located in the transaction log path cannot be removed with 'db2 prune history xxxxxxx and delet' if database configuration 'LOGARCHMETH1' is set to 'LOGRETAIN'.

Before you start any activity , speak to the owners and users of the database . It is safer to stop the applications. It is not always possible - as it may be a live online database. Also consider create a backup for recovery . Completing a DB2 online backup won't force any applications

Follow the steps below to clear the DB2 LUW transaction log files.

>>Connect to the database using the command

su - db2usr1
db2 connect to myDB

>>Connect to the database configuration details using either of these methods

db2 get db config
db2 get db config | grep "log"

>>Search for the First active log file database parameter. For example:

First active log file = S0130573.LOG

>>Once you define the active log file execute

db2 prune logfile prior to <activeLogFileName>

>>Applying this example to our command:

db2 prune logfile prior to S0130573.LOG

>>On execution of this command, DB2 would clear all inactive transaction logs prior to S0130573.LOG