?Query to evaluate your log usage:
db2 "select total_log_available,tot_log_used_top,sec_log_used_top from sysibmadm.snapdb"
?If the Total Log Used Top is nowhere near the Total Log Available you can reduce the size of the logs (logfilsiz) or the number of primary logs (logprimary).
If the Sec_Log_Used_Top is low, you should consider reducing the logfilsiz or logprimary because you are holding on to space you never use.
?It’s perfectly normal to use many secondary logs in peak periods. They are only allocated as needed and go away when you don’t!
?Two of the configuration parameters for Log Archiving are:
–LOGRETAIN
–LOGARCHMETH1
?When LOGRETAIN is ON, closed logs are retained as 'Archived Logs' These logs are necessary for recovery in the event of a crash recovery or point-in-time restore.
–Archived Logs are also necessary for an HADR pair to stay in sync.
–Updating this parameter requires that all connections to be cleared and the database is backed up (offline).
?LOGARCHMETH1 turns on log archiving and can tell db2 to archive logs to a new location. This is useful for archiving logs to TSM or simply to a separate directory.
–Updating this parameter requires that all connections to be cleared and the database is backed up (offline).
?For example:
–>db2 update db cfg for testdb using LOGARCHMETH disk:/db2logs/archive_logs
–>db2 backup db testdb to /dev/null
Managing Archived Logs
?GOOD
–Use the PRUNE and DELETE command to prune the history file and delete recovery objects associated with it. This will also delete backups associated with the history file.
?>db2 prune history 20120630 and delete………..this will delete all entries in the history file, the backups and also the archive logs prior to June 30, 2012
?If auto_del_rec_obj is set to ON in the database config file, the PRUNE command will automatically delete asscociated objects.
–Archive logs to a different directory and script the cleanup
?Use LOGARCHMETH1 to archive logs to separate filesystem in order to easily manage them. Remove logs from this filesystem on a scheduled basis. I usually recommend keeping 5-7 days of archived logs on disk.
?Unix/Linux
–/usr/bin/find /db2logs/archive_logs/DB2/dbname/NODE0000/C0000047-mtime +5-exec /usr/bin/rm -f {} \;
?Windows
–forfiles /P "D:\archive_logs\DB2\dbname\NODE0000\C0000047" /M *.LOG /D -5 /C "CMD /C del @file"
?BAD
–Set LOGRETAIN on and script the removal of archived logs.
–Be sure you are checking the FIRST ACTIVE LOG FILE in the database config file and only deleting logs older.
?UGLY
–Set LOGRETAIN ON, let the archive logs and active log reside in the same directory and wait for a system administrator to start deleting files when the filesystem fills. It will FILL.