5. Installing DB2 on other Linux distributions

DB2 Version 7.1 is distributed as a set of RPM packages. If you want to install DB2 on a distribution that is not officially supported by IBM, and that distribution satisfies all of the prerequisites specified in Section 2, all that you theoretically need to do is find a way to install those packages on your distribution. The alien utility available from Kite converts RPM packages into formats supported by Debian (dpkg), Stampede (slp), and Slackware (slp).

Debian

Susan Williams reported success in installing DB2 Version 7.1 on Debian using the following script as root:

Example 1. Installation script for DB2 Version 7.1 on Debian

#!/bin/bash
cd /
for f in /mnt/cdrom1/db2/*rpm
do
alien -d -i -c $f
done

This script installs every DB2 package on the CD-ROM. In a future iteration of this document I plan to provide a description of all of the DB2 packages to help you develop a more selective approach for your installation.

Using this approach apparently prevents you from using the db2setup command to create instances. To create a DB2 Administration Server from the command line, issue the /usr/ibmdb2/v7.1/instance/dasicrt command as root. To create a DB2 instance, issue the /usr/ibmdb2/v7.1/instance/db2icrt command as root. To get the correct syntax for either command, use the -h flag.

Further information on installing DB2 on Debian is available from Tiago Antao's page, Agnostic DB2 V7.1 for GNU/Linux.

In the following section, Andika Triwidada describes how to install DB2 on Debian 2.2 using the rpm command. You can check the prerequisite package levels (described in Section 2) installed on your system with the following command:
$ dpkg -l|egrep -e '(libc6|libstdc++|pdksh|rpm|zip)'|awk '{print $1,$2,$3}'
The resulting list should contain:
  ii  libc6                 2.1.3-13         
  ii  libstdc++2.9-glibc2.1 2.91.66-4        
  ii  pdksh                 5.2.14-1
  ii  rpm                   3.0.3-1          
  ii  unzip                 5.40-1           

If you are missing any of these packages, you can install the package using apt-get:
bash# apt-get install package-name

Installation Steps

  1. Initialize the RPM database.
    bash# rpm --initdb

  2. Modifiy several files in /bin
    bash# mv /bin/sh /bin/sh.bash
    bash# ln -s /usr/bin/ksh /bin/sh
    bash# for f in awk basename ksh passwd sort touch; do ln -s /usr/bin/$f /bin/$f; done

  3. Copy the contents of the following script to create an RPM wrapper called /bin/rpm.
    #!/bin/sh
    # RPM wrapper, force RPM installation without checking any dependencies
    if [ "$1" = "-ivh" ]
    then
      shift
     /usr/bin/rpm -ivh --nodeps $*
    else
     /usr/bin/rpm $*
    fi

  4. Make the RPM wrapper executable:
    bash# chmod +x /bin/rpm

  5. Install DB2 using the db2setup command by following the instructions in Section 4.

  6. Create the DB2 administration server and at least one DB2 instance as described in Section 6. To simplify testing, ensure that you create the sample database when you create the DB2 instance.

Testing your DB2 installation

  1. Log on to your Linux server with the DB2 instance user ID. Remember, the default user ID is db2inst1.

  2. Prepare your DB2 environment by running the db2profile script:
    bash$ cd ~/sqllib
    bash$ . ./db2profile

  3. Run a query against the sample database to test your installation.
    bash$ db2
    bash$ db2 => connect to sample
    bash$ db2 => select * from employee
    There should be a printout of records from sample database here
    $ db2 => quit

After you install DB2

  1. Remove the RPM wrapper script by removing, renaming, or linking it directly to /usr/bin/rpm.
    bash# rm /bin/rpm

  2. Change /bin/sh back into a symlink to /usr/bin/bash.
    bash# ln -sf /usr/bin/bash /bin/sh

Slackware

Thorough information on installing DB2 on Slackware 7.1 using RPM is available from James Phillips' page, Installing DB2 on Slackware Linux.