DB2 installation

From OpenVZ Linux Containers Wiki

Jump to: navigation, search

DB2 has been certified by IBM for use inside Virtuozzo. It works in OpenVZ too!

IBM provides a free download of DB2 Express-C which is what I installed.

Here is a rough guide to installing DB2 into a freshly-created VE.

Contents

[edit] Create a new VE

I created a new VE for the Debian distribution using debootstrap, as described in Debian template creation.

[edit] Set VE resource limits appropriately

These are tested resource limits for x86-64 system running Debian/GNU Linux 5.0.6:

And according to DB2 9 documentation, the following minimal guest kernel options must be set in /etc/sysctl.conf:

kernel.shmmax = 1073741824
kernel.sem = 250 256000  32 1024
kernel.msgmax = 65535
kernel.msgmnb = 65535

[edit] Install additional packages

[edit] Download the DB2 Express-C package

DB2 Express-C version 9 is available from this page: [[1]]

You will need to register with IBM before you can download.

[edit] Post-install actions

This is where it gets yukky. DB2 wants to run a browser inside the VE. It wants to run Java applets inside the browser. I installed Iceweasel, but the post-install script does not recognise it. I was eventually able to hack the script to recognise and use the browser but it crashed on one of the Java applets. I think you can get by without running the post-install.

Here's what to do instead:

First, su to the instance owner:

Try starting and stopping the database:

If these don't work it means your environment variables are not set properly. IBM set these for me:

CLASSPATH=/home/db2inst1/sqllib/java/db2java.zip:/home/db2inst1/sqllib/java/db2jcc.jar:/home/db2inst1/sqllib/java/sqlj.zip:/home/db2inst1/sqllib/function:/home/db2inst1/sqllib/java/db2jcc_license_cu.jar:.
DB2INSTANCE=db2inst1
PATH=/usr/local/bin:/usr/bin:/bin:/usr/games:/home/db2inst1/sqllib/bin:/home/db2inst1/sqllib/adm:/home/db2inst1/sqllib/misc

Try creating IBM's sample database:

[edit] Setup a development environment

I develop in perl so I was most interested in access to the database though the DBI library. I did this:

If you don't use CPAN you can also do this (as root):

[edit] Setup DB2 for autostart

It seems that DB2 can be auto-started at VE boot time, but not auto-stopped. I used this script:

#!/bin/sh
#
# Script to start DB2 instances on bootup.
#

set -e

. /lib/lsb/init-functions

case "$1" in
start)
        echo Starting DB2
        /opt/ibm/db2/V9.1/instance/db2istrt
        ;;
stop)
        ;;
restart|reload)
        ;;
esac

exit 0

And I used this command to create the symlink to make it start at VE "boot" time:

update-rc.d db2 start 95 2 .

[edit] Testing your installation

From the db2inst1 user, do:

Inside the db2 client, try:

connect to sample
grant dbadm on database to user fred
connect reset

[edit] Enjoy!

Please provide feedback in the discussion (Talk) page about improvements to this HOWTO.

Personal tools
Namespaces
Variants
Actions
Navigation
Sites
Toolbox