10/03/2017

Script to Reduce the tablespace size and reduce the free pages

#!/bin/bash

# Establishing database connection
db2 "connect to itgdb"

# Gathering the tablespaces other than temporary and placing them in a file
db2 list tablespaces show detail | grep -i -A2 name | tac | sed '/Temporary/I,+2 d' | tac | grep -i name | awk '{print $3}' > /tmp/TablespaceList.out

# Using for loop to get the tablespace name one by one
for i in `cat /tmp/TablespaceList.out`
do

# Gathering free pages count for each tablespace
db2 list tablespaces show detail | grep -i -A9 $i | grep -i 'free pages' | awk '{print $4}' > /tmp/FreePages.out

FreePages=`cat /tmp/FreePages.out`

# Comparing whether the free pages are more than 1000 or not
if [ $FreePages -gt 1000 ]
then

# If the free pages are more than 1000 then reducing them
db2 "alter tablespace $i reduce max"
fi
done

10/02/2017

Monitoring database backup performance in db2

Monitoring backup performance:

Sometimes it is difficult to know why the backup process is slow down. So for that we need continuous monitoring on backup process. Here we present some scenarios and monitoring steps to monitor the backup process in db2.

Starting with DB2 V10.1 FixPack 2, every successful backup or restore operation logged into the db2diag.log file. This feature also exists in DB2 V9.7, but must be enabled by using the DB2_BAR_STATS registry variable.

The meanings of the various columns are as follows:

ads