====== DB2 Installation (LINUX) ======
===== DB2 Engine installation : =====
**Install linux pre-requisites :**
yum -y update
yum -y install zip unzip ksh pam.i686 libstdc++-4.4.7-11.el6.i686
**Batch for 3 Instances :**
# 1 VG
pvcreate /dev/sdb
vgcreate db2vg /dev/sdb
# DB2-WORKALL
mkdir -p /db2/db2workall
lvcreate -L 1G -n lvWORKALL db2vg
mkfs.ext4 /dev/db2vg/lvWORKALL
#DB2-DB2INST1 V9.7
lvcreate -L 2G -n lvDB2INST1home db2vg
lvcreate -L 2G -n lvDB2INST1data01 db2vg
lvcreate -L 2G -n lvDB2INST1data02 db2vg
lvcreate -L 2G -n lvDB2INST1tmp db2vg
lvcreate -L 2G -n lvDB2INST1logs db2vg
lvcreate -L 2G -n lvDB2INST1audit db2vg
mkfs.ext4 /dev/db2vg/lvDB2INST1home
mkfs.ext4 /dev/db2vg/lvDB2INST1data01
mkfs.ext4 /dev/db2vg/lvDB2INST1data02
mkfs.ext4 /dev/db2vg/lvDB2INST1tmp
mkfs.ext4 /dev/db2vg/lvDB2INST1logs
mkfs.ext4 /dev/db2vg/lvDB2INST1audit
mkdir -p /db2/db2inst1/home
mkdir -p /db2/db2inst1/data01
mkdir -p /db2/db2inst1/data02
mkdir -p /db2/db2inst1/tmp
mkdir -p /db2/db2inst1/logs
mkdir -p /db2/db2inst1/audit
#DB2-DB2INST2 V10.1
lvcreate -L 2G -n lvDB2INST2home db2vg
lvcreate -L 2G -n lvDB2INST2data01 db2vg
lvcreate -L 2G -n lvDB2INST2data02 db2vg
lvcreate -L 2G -n lvDB2INST2tmp db2vg
lvcreate -L 2G -n lvDB2INST2logs db2vg
lvcreate -L 2G -n lvDB2INST2audit db2vg
mkfs.ext4 /dev/db2vg/lvDB2INST2home
mkfs.ext4 /dev/db2vg/lvDB2INST2data01
mkfs.ext4 /dev/db2vg/lvDB2INST2data02
mkfs.ext4 /dev/db2vg/lvDB2INST2tmp
mkfs.ext4 /dev/db2vg/lvDB2INST2logs
mkfs.ext4 /dev/db2vg/lvDB2INST2audit
mkdir -p /db2/db2inst2/home
mkdir -p /db2/db2inst2/data01
mkdir -p /db2/db2inst2/data02
mkdir -p /db2/db2inst2/tmp
mkdir -p /db2/db2inst2/logs
mkdir -p /db2/db2inst2/audit
#DB2-DB2INST3 V10.5
lvcreate -L 2G -n lvDB2INST3home db2vg
lvcreate -L 2G -n lvDB2INST3data01 db2vg
lvcreate -L 2G -n lvDB2INST3data02 db2vg
lvcreate -L 2G -n lvDB2INST3tmp db2vg
lvcreate -L 2G -n lvDB2INST3logs db2vg
lvcreate -L 2G -n lvDB2INST3audit db2vg
mkfs.ext4 /dev/db2vg/lvDB2INST3home
mkfs.ext4 /dev/db2vg/lvDB2INST3data01
mkfs.ext4 /dev/db2vg/lvDB2INST3data02
mkfs.ext4 /dev/db2vg/lvDB2INST3tmp
mkfs.ext4 /dev/db2vg/lvDB2INST3logs
mkfs.ext4 /dev/db2vg/lvDB2INST3audit
mkdir -p /db2/db2inst3/home
mkdir -p /db2/db2inst3/data01
mkdir -p /db2/db2inst3/data02
mkdir -p /db2/db2inst3/tmp
mkdir -p /db2/db2inst3/logs
mkdir -p /db2/db2inst3/audit
# FILESYSTEMS
cat >> /etc/fstab << EOF
#DB2-WORKALL
/dev/db2vg/lvWORKALL /db2/db2workall ext4 defaults 0 0
#DB2-DB2INST1 V9.7
/dev/db2vg/lvDB2INST1home /db2/db2inst1/home ext4 defaults 0 0
/dev/db2vg/lvDB2INST1data01 /db2/db2inst1/data01 ext4 defaults 0 0
/dev/db2vg/lvDB2INST1data02 /db2/db2inst1/data02 ext4 defaults 0 0
/dev/db2vg/lvDB2INST1tmp /db2/db2inst1/tmp ext4 defaults 0 0
/dev/db2vg/lvDB2INST1logs /db2/db2inst1/logs ext4 defaults 0 0
/dev/db2vg/lvDB2INST1audit /db2/db2inst1/audit ext4 defaults 0 0
#DB2-DB2INST2 V10.1
/dev/db2vg/lvDB2INST2home /db2/db2inst2/home ext4 defaults 0 0
/dev/db2vg/lvDB2INST2data01 /db2/db2inst2/data01 ext4 defaults 0 0
/dev/db2vg/lvDB2INST2data02 /db2/db2inst2/data02 ext4 defaults 0 0
/dev/db2vg/lvDB2INST2tmp /db2/db2inst2/tmp ext4 defaults 0 0
/dev/db2vg/lvDB2INST2logs /db2/db2inst2/logs ext4 defaults 0 0
/dev/db2vg/lvDB2INST2audit /db2/db2inst2/audit ext4 defaults 0 0
#DB2-DB2INST3 V10.5
/dev/db2vg/lvDB2INST3home /db2/db2inst3/home ext4 defaults 0 0
/dev/db2vg/lvDB2INST3data01 /db2/db2inst3/data01 ext4 defaults 0 0
/dev/db2vg/lvDB2INST3data02 /db2/db2inst3/data02 ext4 defaults 0 0
/dev/db2vg/lvDB2INST3tmp /db2/db2inst3/tmp ext4 defaults 0 0
/dev/db2vg/lvDB2INST3logs /db2/db2inst3/logs ext4 defaults 0 0
/dev/db2vg/lvDB2INST3audit /db2/db2inst3/audit ext4 defaults 0 0
EOF
#MOUNT THEM
mount -a
#ADD USERS & GROUP
groupadd db2grp1
useradd -g db2grp1 -m -d /db2/db2inst1/home db2inst1
useradd -g db2grp1 -m -d /db2/db2inst2/home db2inst2
useradd -g db2grp1 -m -d /db2/db2inst3/home db2inst3
# CHANGE PASSWORD
echo "db2inst1:broodi" | chpasswd
echo "db2inst2:broodi" | chpasswd
echo "db2inst3:broodi" | chpasswd
# CHOWN & CHMOD
chown -R db2inst1:db2grp1 /db2/db2inst1
chown -R db2inst2:db2grp1 /db2/db2inst2
chown -R db2inst3:db2grp1 /db2/db2inst3
chown -R db2inst1:db2grp1 /db2/db2workall
chmod 1777 /db2/db2workall
chmod -R 750 /db2/db2inst1
chmod -R 750 /db2/db2inst2
chmod -R 750 /db2/db2inst3
# SETUP USER PROFILES
su - db2inst1
cp /etc/skel/.* .
echo "set -o vi" >> .bashrc
mkdir -p /db2/db2workall/db2inst1
mkdir -p /db2/db2workall/db2inst1/log
mkdir -p /db2/db2workall/db2inst1/script
exit
su - db2inst2
cp /etc/skel/.* .
echo "set -o vi" >> .bashrc
mkdir -p /db2/db2workall/db2inst2
mkdir -p /db2/db2workall/db2inst2/log
mkdir -p /db2/db2workall/db2inst2/script
exit
su - db2inst3
cp /etc/skel/.* .
echo "set -o vi" >> .bashrc
mkdir -p /db2/db2workall/db2inst3
mkdir -p /db2/db2workall/db2inst3/log
mkdir -p /db2/db2workall/db2inst3/script
exit
#DONE !
echo "FINISHED"
===== DB2 Installation ====
The software has firstly to be installed before the below command be executed.
[root@localhost server_t]# ./db2_install
Read the license agreement file in the db2/license directory on the CD.
***********************************************************
To accept those terms, enter "yes". Otherwise, enter "no" to cancel the install process. [yes/no]
yes
Default directory for installation of products - /opt/ibm/db2/V11.1
***********************************************************
Install into default directory (/opt/ibm/db2/V11.1) ? [yes/no]
Install into default directory (/opt/ibm/db2/V11.1) ? [yes/no]
yes
Specify one of the following keywords to install DB2 products.
SERVER
CONSV
CLIENT
RTCL
Enter "help" to redisplay product names.
Enter "quit" to exit.
***********************************************************
SERVER
***********************************************************
Do you want to install the DB2 pureScale Feature? [yes/no]
no
DB2 installation is being initialized.
===== Instance configuration =====
**Create new instance :**
/instance/db2icrt -a server -s wse -u db2inst1 db2inst1
auth server fencedID instanceID
**Configure port & communication method :**
su -
db2 update dbm cfg using SVCENAME `grep -w DB2_${DB2INSTANCE} /etc/services | awk '{print $1}'`
db2set DB2COMM=tcpip4
db2 terminate
**Restart DB2 :**
db2stop force
db2start
**Configure TSM db2adutl : **
su - db2inst1
cat >> ~/.bashrc < EOF
export DSMI_CONFIG=/opt/tivoli/tsm/client/api/bin64/dsm_db2inst1.opt
export DSMI_LOG=/db2/db2workall/db2inst1/log
export DSMI_DIR=/opt/tivoli/tsm/client/api/bin64
EOF
. ~/.bashrc