SQL Relay - Getting Started With IBM DB2 - Installing DB2 Version 7.2

Installing IBM DB2 Version 7.2
Install pdksh

DB2 7.2 requires pdksh (Public Domain Korn Shell). If it did not come with your distribution, you'll need to download and install it.

For RPM based distributions, look for pdksh at rpmfind and install it using rpm -i.

For Debian Linux, run apt-get install pdksh.

Install libncurses.so.4

DB2 7.2 requires libncurses.so.4. Many older distributions come with libncurses.so.4. Many newer distributions come with libncurses.so.5 (or newer). Some distributions come with both. If your distribution does NOT have libncurses.so.4, create a symbolic link to the newer library as follows.

(These instructions assume that your system has ncurses version 5.2 and that libncurses.so.5.2 resides in /usr/lib. If your system has a different version of ncurses or if it resides somewhere else (for example, in /lib) then modify the instructions accordingly)

> cd /usr/lib
> ln -s libncurses.so.5.2 libncurses.so.4

Install Compatibility Packages

DB2 V7.2 for Linux requires glibc 2.1. On distributions that come with newer versions of glibc it is necessary to install some compatibility packages.

RedHat provides compatability RPM's for RedHat 7 that can actually be used on any Linux distribution. These RPM's can be downloaded from rpmfind. You'll need the following RPM's.

- compat-glibc-6.2-2.1.3.2.i386.rpm for RedHat Linux 7.3
- compat-egcs-6.2-1.1.2.16.i386.rpm for RedHat Linux 7.3
- compat-libstdc++-6.2-2.9.0.16.i386.rpm for RedHat Linux 7.3

You can install the compatibility RPM's using rpm -i.

DB2 Installation

IBM DB2 V7.2 is available from the IBM website as a tarball. Extracting the tarball using tar xf creates a directory called 018_EEE_LNX_NLV. Change directories into that directory.

On Debian Linux edit the db2_install script and comment out the line:

> rpm -qa | grep rpm 1>/dev/null 2>/dev/null

If you're installing on a computer that gets moved around a lot (such as a laptop) and gets assigned more than 1 hostname, you should set the hostname to localhost now using the following command:

> hostname localhost

The installer will name the database after whatever hostname your computer currently has. This will cause the database to be inaccessible when that hostname doesn't resolve or resolves to a computer other than yours.

Run the db2_install script.

When prompted to specify a keyword, type DB2.EENT and press return.

When the script completes, run rpm -qa and verify that the following RPM's were installed:

> db2cnvc71-7.1.0-40
> db2gs71-7.1.0-40
> db2cucs71-7.1.0-40
> db2engn71-7.1.0-40
> db2cdrd71-7.1.0-40
> db2dj71-7.1.0-40
> db2pext71-7.1.0-40
> db2cliv71-7.1.0-40
> db2rte71-7.1.0-40
> db2wcc71-7.1.0-40
> db2hten71-7.1.0-40
> db2cnvk71-7.1.0-40
> db2cj71-7.1.0-40
> db2conn71-7.1.0-40
> db2smpl71-7.1.0-40
> db2xlic71-7.1.0-40
> db2cnvj71-7.1.0-40
> db2crte71-7.1.0-40
> db2cdb71-7.1.0-40
> db2das71-7.1.0-40
> db2cnvt71-7.1.0-40
> db2repl71-7.1.0-40
> db2adts71-7.1.0-40
> db2jdbc71-7.1.0-40
> db2adt71-7.1.0-40

Ignore the Misinformation

There are many, many instances where the DB2 Version 7.2 distribution identifies itself as version 7.1 instead of 7.2. For example, the RPM's have a 7.1.0 version number. These clues might lead one to think that he or she has accidentally installed version 7.1 instead of version 7.2, but this is not the case.

Install the Documentation

For version 7.2, once the RPM's are installed, you can install the documentation by running /usr/IBMdb2/V7.1/doc/db2insthtml en_US. To view the documentation, point your browser at /usr/IBMdb2/V7.1/doc/en_US/html.

Restore unixODBC if Necessary

The DB2 installation creates symbolic links from include files in its base directory to /usr/include. If you had a unixODBC-devel RPM installed prior to installing DB2, the include files provided by the unixODBC-devel RPM will have been overwritten by these symbolic links. You should probably reinstall the unixODBC-devel RPM. SQL Relay looks in the DB2 installation directory for DB2 includes, so not having them in /usr/include won't hurt, but not having the proper unixODBC includes in /usr/include will cause the ODBC database connection build to fail.

This should be enough you get you started. To set up more complex configurations, consult the documentation that came with your DB2 distribution.

Creating an Instance

IBM DB2 is installed under either /opt/IBMdb2/V7.1, /usr/IBMdb2/V7.1 That directory will be referred to as BASE_DIR in this document.

A DB2 installation consists of an administration server and one or more instances. Each instance contains one or more databases. The administration server coordinates the instances. The administration server is owned by an OS-level user. Each instance is owned by a seperate OS-level user as well.

To create an instance and an administration server, run BASE_DIR/install/db2setup, a text-based installation program.

> Select [ Create... ]
> Select Create a DB2 Instance
> Accept the default user name (db2inst1).
> Accept the default UID.
> Accept the default group name (db2iadm1).
> Accept the default GID.
> Pick a password.
> Select [ OK ]
> A screen for creating the Fenced User (the user that will run user defined functions and stored procedures) will now appear.
> Accept the default user name (db2fenc1).
> Accept the default UID.
> Accept the default group name (db2fadm1).
> Accept the default GID.
> Pick a password.
> Select [ OK ] This will return you to Create DB2 Services screen.
> Select Create the Administration Server
> Accept the default user name (db2as).
> Accept the default UID.
> Accept the default group name (db2asgrp).
> Accept the default GID.
> Pick a password.
> Select [ OK ]
> If you get a DB2SYSTEM will be set to ... dialog, select [ OK ].
> On the Create DB2 Services screen, select [ OK ]
> Select [ Continue ]
> Select [ OK ] in the This is your last chance to stop dialog.
> Now the instance and administration server will be created.
> If all went well, you'll get a Completed Sucessfully. notice.
> To exit,
> Select [ OK ]
> Select [ OK ]
> Select [ Close ]
> Select [ OK ]

Should you need to create additional DB2 instances, follow this procedure again using a different user name and skipping the steps pertaining to the Administration Server. The BASE_DIR/instance/db2ilist command lists all of the DB2 instances on the local computer.

If you need to drop an instance, run BASE_DIR/instance/db2idrop instancename, substituting the name of the instance you want to drop for instancename.

The BASE_DIR/instance/dasilist command lists all of the DB2 administration servers on the local computer.

If you need to drop an administration server, run BASE_DIR/instance/dasidrop servername, substituting the name of the administration server you want to drop for servername.

Enable Remote Access

By default, a DB2 instance only accept connections from clients running on the local machine. To enable connections from clients running on a remote machine over TCP, execute commands like the following. These commands set up the db2inst1 instance on port 50000.

> log in as root
> view /etc/services and look for a line like:

> > db2cdb2inst1 50000/tcp # Connection port for DB2 instance db2inst1

> if no such line exists, add it
> log in as db2as
> run the following commands:

> > . /home/db2inst1/sqllib/db2profile
> > db2 "update database manager configuration using svcename db2cdb2inst1"
> > db2stop
> > db2start

Now the db2inst1 instance should be accessible to remote clients on port 50000.

Creating a Sample Database

To create a sample database, run the command /usr/IDMdb2/V7.1/bin/db2sampl.

Starting the Database at Boot Time

During the DB2 installation process, /etc/inittab is modified such that the database will be started at boot time. However, if you would like to start and stop the database at will, you can use the following script.

>     #!/bin/sh

>     case "$1" in
>             start)
>                     /usr/IBMdb2/V7.1/instance/db2istrt
>             ;;
>             stop)
>                     /usr/IBMdb2/V7.1/instance/db2ishut
>             ;;
>             *)
>             echo $"Usage: $0 {start|stop}"
>             exit 1
>     esac

>     exit 0

Install this script and run it with the "start" option to start up the database. Running it with the "stop" option shuts the database down. To access a database, it must be running.

You can control which instances start at boot time using the following commands. To get each instance to start at boot time, you need to run the following command as root for each instance:

> /usr/IBMdb2/V7.1/bin/db2iauto -on INSTANCE_USER

Where INSTANCE_USER is replaced by the username of the user associated with the instance you want to start at boot time.

If you want to disable an instance from starting at boot time, you need to run the following command as root for each instance:

> /usr/IBMdb2/V7.1/bin/db2iauto -off INSTANCE_USER