Archive for the Databases Category

DB2 Linux Installation Notes

DB2 Linux Installation Notes
These notes are for the manual installation and configuration of IBM DB2 Enterprise Edition v.8.1.1 on Linux, particularly with the 2.4.20 kernel and Red Hat 9.0.

Part 1: Program Installation
Run everything as root.

If you get errors, see the /tmp log files created by db2, and you can also write the output errors to a file like in: # command 2> command.err


  • Unzip the installation file if you don't have the CD-ROM. (in our case in /opt)

  • Run the installation program:



  • cd (intallation_path)

  • # ./db2install

  • Choose installation option, for example DB2.EXE DB2.ADMCL


  • Create users and groups:


    • # groupadd -g 999 db2iadm1

    • # groupadd -g 998 db2fadm1

    • # groupadd -g 997 db2asgrp

    • # useradd -g db2iadm1 -m db2inst1 -p password

    • # useradd -g db2fadm1 -m db2fenc1 -p password

    • # useradd -g db2asgrp -m db2as -p password


  • Create an Administration Server (DAS)


    • /opt/IBM/db2/V8.1/instance/dascrt -u db2as


  • Create an Instance


    • /opt/IBM/db2/V8.1/instance/db2icrt -u db2fenc1 db2inst

    • 1

  • Create links


    • /opt/IBM/db2/V8.1/cfg/db2ln


  • Install license key


    • (NOTE: the trial version lasts for 90 days)

    • /opt/IBM/db2/V8.1/adm/db2licm -a /opt/009ESE_LNX_32_NLV/db2/license/db2license.lic


    Part 2: Test

    • Login as db2inst1 (for example from root: # su db2inst1 -)

    • Start the database: $ db2start

    • Create the "sample" database: $ db2sample

    • List existing database(s): $ db2 list database directory

    • Check the sample database



    • $ db2 connect to sample

    • $ db2 list tables

    • $ db2 "select * from employee"

    • $ db2 connect reset


    Part 3: Create Users and Database Instances

    • Add to the /etc/profile file the db2 profile environment with: (note: you are "sourcing", there's a dot at the beginning of the line)
      . /home/db2inst1/sqllib/db2profile

    • To create the users we use a script genesis.sh, to run as root:

      (NOTE: afterwards each password must be set manually with # passwd password# genesis.sh : Script that creates users with www directory
      # usage: ./genesis.sh username
      # then 2) password must be set manually
      # and 3) run /home/db2inst1/createdb.sh as db2inst1
      #
      # The opposite script to delete user and database is: nuke username
      #
      # Fernando Duran , Oct 2003
      #

      #!/bin/bash
      useradd $1
      mkdir /home/$1/www
      chown $1 /home/$1/www
      chgrp $1 /home/$1/www
      chmod 711 /home/$1
      chmod 755 /home/$1/www


    • To create the database instances for the users we use a script createdb.sh, to run as dbinst1:

      (NOTE: the name of the database is the same that the Linux login name for that user.
      /home/db2data is an arbitray directory)# createdb.sh : Script that creates users' databases
      # usage: ./genesis.sh username
      #
      # The opposite script to delete user and database is: /root/nuke.sh username
      #
      # Fernando Duran , Oct 2003
      #

      #!/bin/bash

      db2 "create database $1 on /home/db2data"
      db2 "connect to $1"
      db2 "grant dbadm on database to user $1"
      db2 "revoke connect on database from public"
      db2 "connect reset"


    • To delete a user and the associated database we run a script nuke.sh as root:# nuke.sh: script to delete user and his/her /home directory and database
      # usage: ./nuke.sh username
      #
      # Fernando Duran , Oct 2003
      #

      #!/bin/bash
      #
      userdel -r $1
      SQL="drop database $1"
      su -l -c "db2 $SQL" db2inst1



    Part 4: Optional Configurations

    • To restart the db2 server automatically when Linux starts, add:
      su db2inst1 -lc /home/db2inst1/sqllib/adm/db2start
      to the end of the /etc/rc.local file