Return to LinuxDig.Com HowTo's

DB2 Version 7.1 for Linux HOWTO

Dan Scott

Revision History
Revision 1.2.72003-12-05Revised by: dbs
Add pointers to DB2 Version 8 information as a stop-gap measure until a real HOWTO is available.
Revision 1.2.62002-09-21Revised by: dbs
Add Mandrake 8.1, SuSE 7.3 install instructions from contributor Mykola Buryak.
Revision 1.2.52002-07-16Revised by: dbs
Fixed or removed some broken links, added a few new resources.
Revision 1.2.42001-06-02Revised by: dbs
Running JDK 1.1.8 on Red Hat 7.1
Revision 1.2.32001-04-25Revised by: dbs
Red Hat 7.1 install instructions, more DB2 on Debian info, connecting to AS/400 databases, buffer pool memory limits, converted to DocBook XML.
Revision 1.2.12000-10-25Revised by: dbs
Basic Red Hat 7.0 info, additional Debian instructions.
Revision 1.22000-09-25Revised by: dbs
IBM JDK 1.3 works! More troubleshooting.
Revision 1.12000-07-28Revised by: dbs
Documented _SHM_ID_BITS kernel parameter tuning for increasing number of available connections. Added basic indexing.
Revision 1.02000-07-06Revised by: dbs
Added basic Debian instructions. Corrected some factual, stylistic, and grammatical mistakes. Licensed document under GNU GPL. Submitted document to LDP.
Revision 0.72000-04-26Revised by: dbs
Based on DB2 V7.1 beta release, wrote install instructions for Caldera 2.4, Red Hat 6.2, SuSE 6.2, SuSE 6.3, and TurboLinux 6.0.

This HOWTO gives you explicit instructions on installing DB2 Universal Database Version 7.1 for Linux on the following Intel x86-based distributions: Caldera OpenLinux 2.4, Debian, Mandrake Linux 7.2 and 8.1, Red Hat Linux 6.2 and 7.1, SuSE Linux 6.2, 6.3, 7.0, and 7.3, and TurboLinux 6.0. After installing DB2, you can work with a sample database, connect to your DB2 server from a remote machine, and administer DB2 using the DB2 Control Center.


1. Introduction

1.1. Why a DB2 installation HOWTO?

Ever since DB2 Version 5.2 was ported to Linux in 1998 and made available as a beta download, there has been a lot of interest in DB2 on Linux. The beta represented one of IBM's first dips into the waters of Linux, and it generated a lot of feedback. And, not surprisingly, they ran into problems. It was a beta product, after all.

DB2 on Linux has come a long way since Version 5.2. The first supported release of DB2 on Linux was Version 6.1 in 1999, which removed many of the installation hurdles faced by the Version 5.2 beta testers.

DB2 Version 7.1 was the second major release that supports Linux. I wrote this HOWTO to share my experiences and help smooth the installation path of those new to DB2, Linux, or both. The standardization on the IBM Developer Kit for Java improved the stability of the DB2 Control Center and enabled application developers to write stored procedures and UDFs in Java. DB2 Version 7.1 also introduced the ability to write stored procedures in SQL.

DB2 Version 8 is the most recent release. Support was added for Linux distributions on architectures beyond Intel 32-bit processors, including AMD 64-bit processors, Intel 64-bit processors, POWER PC processors, and Linux on zSeries. If you're just starting out with Linux or DB2, I strongly urge you to consider going directly to DB2 Version 8 to take advantage of all of the additional features, stability, and performance it offers. For information on installing DB2 Version 8 on Linux, please refer to the Web sites section of Appendix A.


1.2. Who should read this HOWTO?

If you plan to install DB2 Version 7.1 on one of the Linux distributions supported by IBM, this document is for you. The distributions that IBM officially supports are:

  • Caldera OpenLinux 2.4

  • Red Hat Linux 6.2

  • SuSE Linux 6.2 and 6.3

  • TurboLinux 6.0

For Debian and Slackware, I have included very basic installation instructions or links to other resources in Section 5. If you have any other installation success stories, please forward me the details and I'll try to expand the section. As time permits, I plan to try to duplicate and confirm these installation instructions.

If you install DB2 Version 6.1 for Linux and DB2 hangs on the db2start command, see db2start hangs on Linux distributions built with glibc 2.1. I don't include any other DB2 Version 6.1 information in this document. If you plan to install DB2 Version 5.2 on Linux, don't! (Have I emphasized that point enough? All right, I'll stop now.) The Personal Developer's Edition of DB2 Version 7.1 is available as a free (beer) download from IBM, at the DB2 Universal Database download site. Registration is required, and, of course, your copy of DB2 is only free as long as you don't use it in a production environment.

This document is really meant to help you install DB2 Version 7.1 on the previously listed Linux distributions. I've installed DB2 on all of the distributions supported by IBM and noted the prerequisites and quirks for each of them. I don't go into detail about the various features of DB2, or what each installation option means, but I do cover the basics that you need to know to get it installed.


1.3. New versions of this document

I like my friends at the Linux Documentation Project, so you'll always be able to find the most up-to-date version of this document at the LDP web site.


1.4. Copyright and License

Copyright (c) 2000, 2003 International Business Machines Incorporated.

This document is free documentation; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This document is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this document; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.


1.5. Credits

Dan Scott is the originator and current maintainer of this HOWTO. Please send all suggestions for improvement, criticisms, or more-or-less related questions to me at (remove REM in my email address before sending). Please send all spam or hate mail to /dev/null.

Feedback and suggestions for improvement have been provided by Susan Williams, Serge Boivin, Darin McBride, and Xiaoyan Zhao. Ronnie Seagren did an awesome job of editing the original version for style and consistency.

Additional thanks to:

  • Andika Triwidada for contributing instructions to install DB2 V7.1 on Debian using the rpm utility.

  • Michael Naughton for braving Red Hat 7 and figuring out the libncurses.so.4 prerequisite.

  • Christoph Shmitz for resolving license problems with DB2 installed via alien.

  • Claus Fischer for solving a DB2 on Debian problem with updating instances and contributing cataloging instructions for DB2 on AS/400.

  • Mykola Buryak for contributing the sections on Mandrake Linux 8.1 and SuSE 7.3.


1.6. About the author

Dan Scott has been employed by IBM Canada as an Information Developer since 1998—approximately when DB2 was first ported to Linux. It's probably just coincidence. He has documented and tested DB2 application development for the bulk of that time. In his spare time he can occasionally be found mourning for his motorcycle (in storage for the winter), abusing his body on his mountain bike, or contemplating how to upgrade his Linux distribution at home (which started life as Mandrake 5.3 and has mutated wildly ever since) without suffering the wrath of his girlfriend (er, make that wife now).


2. Prerequisites

2.1. What are prerequisites?

Prerequisites are what you, your machine, and your distribution require before you will be able to successfully install or use DB2. The required prerequisites come straight from IBM DB2 Universal Database for UNIX Quick Beginnings. The suggested prerequisites come from experience. For your convenience, I've divided them into hardware and software requirements.

Hardware prerequisites

Processor

x86 compatible (for example, Intel, AMD, or Cyrix). I've successfully installed DB2 Version 7.1 on a Pentium Pro 200 and a Pentium II 350. Your experiences with other x86 processors would be appreciated.

Memory

For application development, I've found 96 MB of RAM is enough to run a small database and test out your applications. Even the Control Center responds acceptably if your processor speed is fast enough. In my case, I was working with a Thinkpad 600 equipped with a Pentium 233 MMX processor and 96 MB of RAM. However, more memory is recommended if you're putting your database into production or running multiple services.

Free disk space

Of course, this depends on the components you install, but for a typical installation of the DB2 Version 7.1 server, the Administration Client, the Application Development Client, the documentation, and the creation of a sample database, you will need about 350 MB of free disk space.

Software prerequisites

glibc

2.1.2 or greater. This can be a tough part of Linux to upgrade on its own, so if your current distribution doesn't meet this requirement, I would strongly suggest upgrading your entire distribution. For example, I tried upgrading only the glibc portion of TurboLinux 4.0 from 2.1.1 to 2.1.3 and ran into a whole world of trouble.

DB2 Version 7.1 should work with glibc 2.1.1. IBM sets prerequisites based on the systems with which they tested.

kernel

2.2.12 or greater. I've upgraded to both 2.2.19 and 2.4.3 and recompiled the kernel for my own purposes, and DB2 seems to work as well as before.

DB2 Version 7.1 should work with a minimum of kernel 2.2.10. IBM sets prerequisites based on the systems with which they tested.

libncurses

4.x. For db2setup to work correctly, this version of the library must be available on your system with the following pathname: /usr/lib/libncurses.so.4.

libstdc++-libc6.1-1.so.2

A file or symbolic link by this exact name is mandatory. On most distributions, this is a symbolic link to libstdc++-2.9.0.so, but on several recent distributions this is a symbolic link to libstdc++-2.10.0.so.

Note

In previous versions of this HOWTO, I stated that the exact version of libstdc++-2.9.0.so was mandatory. I was wrong.

pdksh

5.2 or greater. This is a public domain version of the Korn shell that both the DB2 installer and the DB2 commands require. You cannot do anything with DB2 without installing pdksh.

rpm

3.0 or greater. DB2 for Linux is distributed as a number of RPM packages, so you won't get far without this piece of software. For information on installing DB2 on distributions without using RPM, see Section 5.

Java

The IBM Developer Kit for Java, 1.1.8 or 1.3, is an optional component, but is required to:

  • use the DB2 Control Center to administer your databases using a graphical user interface

  • create or run Java applications, including stored procedures and user-defined functions

As of this writing, the minimum required level of the IBM Developer Kit for Java 1.1.8 is the March 22, 2000 release. You can get the IBM Developer Kit and Runtime Environment for Linux, Java Technology Edition, from the IBM Java Developer Kit downloads web site as follows:

Please note: Other versions of Java, such as the Blackdown or Sun JDKs, have not been tested with DB2 and are not supported by IBM. And no, none of the distributions I have seen so far package the IBM JDK. But do yourself a favour, and get the IBM Developer Kit for Java.

Web browser

DB2 calls the netscape command when you:

  • display the online help for the DB2 Control Center

  • display information using the DB2 Information Center

The easiest approach is to install Netscape Navigator or Communicator on your system. Netscape version 4.72 or above is required to display the Business Intelligence Quick Tour, because of its extreme use of JavaScript.

To use a browser other than Netscape to display online help or information, create a link called netscape to your preferred browser executable. The link must appear in your PATH. For example, to display online help with mozilla, you could create a link in /usr/local/bin with the following command:
bash# ln -s /usr/bin/mozilla-bin /usr/local/bin/netscape

In the following table:

  • unknown indicates that I don't know what the default level is, and I haven't installed DB2 on this distribution (your feedback is welcome!)

  • okay indicates that I don't know what the default level is, but it worked when I installed DB2

  • ** as a prefix indicates that the default level is not acceptable and must be replaced or supplemented with a compatible library

Table 1. Prerequisite levels, by distribution

DistributionglibcLinux kernellibncurseslibstdc++-libc6.1-1.sopdkshrpm
Caldera OpenLinux 2.42.1.22.2.14okay2.9.05.2.14okay
Debian 2.22.1.32.2.17okay2.10.05.2.143.0.3
Mandrake Linux 7.22.1.32.2.17okay (4, 4.2, 5, & 5.1)2.95.2.143.0.5
Mandrake Linux 8.12.2.42.4.85.22.105.2.144.0.3
Red Hat 6.22.1.22.2.14okay2.9.05.2.14okay
Red Hat 72.1.922.2.16**5.1**2.9.65.2.144.0
Red Hat 7.12.2.22.4.2**5.2**2.9.65.2.144.0.2
SuSE 6.22.1.12.2.10unknown2.9.05.2.14okay
SuSE 6.32.1.22.2.13okay2.9.05.2.14okay
SuSE 7.0unknown2.2.17okayunknown5.2.14okay
SuSE 7.32.2.42.4.104.2, 5.22.7.2, 2.8, 2.95.2.143.0.6
TurboLinux 6.02.1.22.2.13okay2.9.05.2.14okay

3. Preparing your distribution for DB2

3.1. Caldera OpenLinux 2.4

3.1.1. Before installing DB2 on Caldera OpenLinux

This section contains instructions that you must follow before installing DB2.

Preparing for the installation of DB2

  1. Install the pdksh-5.2.14-1.i386.rpm package from the Caldera OpenLinux CD-ROM in the /Packages/RPMS/ directory. For example, log in as root, mount the CD-ROM, and enter the following command to install the pdksh package:
    bash# rpm -ivh /mnt/cdrom/Packages/RPMS/pdksh-5.2.14-1.i386.rpm

  2. Remove the jdk package, (JDK 1.2.2 from Sun), since it will conflict with the IBM Developer Kit for Java that you will install in the next step. To remove Sun's JDK, issue the following command as root:
    bash# rpm -e jdk

  3. Install the IBM Developer Kit for Java. A brief set of installation directions is included in Section 11.

  4. Edit the JAVA_HOME and PATH entries in /etc/config.d/shells/bashrc to remove the references to the JDK from Sun and update them to reflect the IBM Developer Kit for Java. The section that I changed started as:
    
    [ -z "$JAVA_HOME" ]&& [ -d /usr/java ] && (
                export JAVA_HOME=/usr/java
                [ -r $JAVA_HOME/lib/classes.zip ] &&
                  export CLASSPATH=$JAVA_HOME/lib/classes.zip
    )
    

    Replace it with the following section to reflect the default locations for the IBM Developer Kit for Java:
    
    [ -z "$JAVA_HOME" ]&& [ -d /usr/jdk118 ] && (
                export JAVA_HOME=/usr/jdk118
                export PATH=$PATH:$JAVA_HOME/bin
                [ -r $JAVA_HOME/lib/classes.zip ] &&
                  export CLASSPATH=$JAVA_HOME/lib/classes.zip
    )
    


3.1.2. Installing DB2 and creating instances on Caldera

Follow the instructions in Section 4 the generic section on installing DB2, and go ahead and create the instances. It's probably a good idea at this point to read through Section 3.1.3 to keep in mind the steps that you need to take after installing DB2.

3.1.2.1. What does /etc/login.defs not accessible, using defaults mean?
3.1.2.2. Okay, DB2 is installed and I created the instances. Now what do I do?

3.1.2.1. What does /etc/login.defs not accessible, using defaults mean?

It means something went slightly wrong, but it's okay. You may get this message splashed across your installation screen one or more times during the DB2 installation process, but other than not looking pretty, DB2 still installs correctly. Caldera apparently doesn't include a /etc/login.defs configuration file. The file controls the default options for the useradd command for adding new users, including policies like how many days before the new user's password expires and whether a home directory should be created for a new user. For more information on the /etc/login.defs file, refer to the man page for useradd.

3.1.2.2. Okay, DB2 is installed and I created the instances. Now what do I do?

Now that you've installed DB2, you have to perform some steps to configure your instances correctly. Keep reading.


3.1.3. After installing DB2 on Caldera

This section contains instructions that you must follow after installing DB2.


3.1.3.1. Adding instance user IDs to their groups

The most important step is to manually add the instance user ID to the corresponding instance group you defined during the instance creation step. DB2 and Caldera OpenLinux don't get this part of the DB2 instance creation process right, so you have to do it yourself. You can add an instance user ID to an instance group in two ways:

  • Edit /etc/group to add the appropriate instance user ID to the last field for each group.

  • Use the COAS utility to manage your groups by selecting KDE menu, Settings, COAS, System, Accounts, then selecting the Groups submenu and the Manage Groups menu item.


3.1.3.2. Changing the default home page in Netscape

The DB2 Control Center and the DB2 Information Center use the Netscape browser to display help and documentation. This works for the first document you display in the browser, but if you try to switch to a different DB2 document (for example, from one book to another), you may instead be redirected to the default home page set by the Caldera OpenLinux installation process. I found that this problem went away as soon as I changed the default home page in the Edit menu, Preferences menu item.


3.1.3.3. Removing the Caldera login greeting

Add a file called .hushlogin to the home directory of each of your instance user IDs. This should prevent the Welcome to your OpenLinux system! messages while running DB2 commands.

DB2 generates these messages on Caldera because the DB2 commands run under the root user ID, which in turn becomes the instance owner to invoke commands. Part of this su process calls one or both of /etc/config.d/shells/csh.login and /etc/config.d/shells/profile, which in turn call the /etc/config.d/shells/OL-greeting script that contains the offensive string.

Instead of adding .hushlogin to every user's home directory, you could probably edit /etc/config.d/shells/OL-greeting to remove the message (or change it to something else, if you want). I haven't tried it myself, so let me know what works best.


3.2. Mandrake Linux 7.2

The DB2 server and command line DB2 client works on Mandrake Linux 7.2, and I was able to successfully start and use the DB2 Control Center with IBM JDK 1.1.8 (build 20000713).


3.2.1. Before installing DB2 on Mandrake Linux

Preparing for the installation of DB2

  1. Install the pdksh-5.2.14-8mdk.i586.rpm package from the Mandrake Linux CD-ROM in the /Mandrake/RPMS/ directory. For example, log in as root, mount the CD-ROM, and enter the following command to install the pdksh package:
    bash# rpm -ivh /mnt/cdrom/Mandrake/RPMS/pdksh-5.2.14-8mdk.i586.rpm


3.2.2. Installing DB2 and creating instances on Mandrake Linux

When you run db2setup, you may receive the following error: ksh: /etc/profile.d/tmdir.sh[9]: source: not found This is only a warning message and you can continue installing DB2. If the message interferes with the db2setup menu, press CTRL-L to clear the screen.

Otherwise, follow the instructions in Section 4, the generic section on installing DB2 and creating instances.


3.2.3. After installing DB2 on Mandrake Linux

With Mandrake Linux 7.2, there are no special steps to take after installing DB2 Version 7.1. The DB2 server and command line client work out of the box, and the DB2 Control Center worked with IBM JDK 1.1.8 (build 20000713).


3.3. Mandrake Linux 8.1

3.3.1. Before installing DB2 on Mandrake Linux

Preparing for the installation of DB2

  1. Install the pdksh-5.2.14-12mdk.i586.rpm package from the Mandrake Linux CD-ROM #2 in the /Mandrake/RPMS2/ directory. For example, log in as root, mount the CD-ROM, and enter the following command to install the pdksh package:
    bash# rpm ivh /mnt/cdrom/Mandrake/RPMS2/pdksh-5.2.14-12mdk.i586.rpm

  2. The Linux 2.4 kernel changes the default values of some ipc limits. However, the default value for the msgmni is 16, which causes difficulties running DB2 with the default 2.4 kernel ipc parameters. Fortunately, the 2.4 kernel also enables you to change a number of these parameters through the /proc filesystem. With the 2.4 kernel, you do not have to recompile your kernel to experiment with different parameter values. To set the msgmni kernel parameter at boot time, append the following lines to /etc/sysctl.conf:
    
# Sets maximum number of message queues to 128
    # Set this to 1024 or higher on production systems
    kernel.msgmni = 128
    

  3. Uninstall the default Mandrake Linux 8.1 Kaffe Virtual Machine with Package Manager or Software Manager. Install the IBM Developer Kit for Java by issuing the following command as root:
    bash# rpm -ivh IBMJava118-SDK-1.1.8-5.0-i386.rpm

  4. To set up the Java environment for all or specific users in Mandrake Linux 8.1, copy the content of /usr/jdk118/bin to /usr/bin and /usr/jdk118/lib to /usr/lib. After that you can successfully issue the
    java -fullversion
    command.

  5. To install DB2 Warehouse Control Database, you must change the permissions for the /home directory to read, write and execute (for users, groups, others) as a user with root authority:
    
bash# chmod ugo=rwx /home
    
    If you do not change the permissions for the /home directory, you may recieve the following error: SQL0970N The system attempted to write to a read-only file. SQLSTATE=55009.


3.3.2. Installing DB2 and creating instances on Mandrake Linux

When you run db2setup, the DB2 Product Messages and DB2 Product Library menus can interfere with the db2setup main menu. If this happens, press CTRL-L to clear the screen.


3.3.3. Removing DB2 on Mandrake Linux

You must perform the following steps as a user with root authority.

Removing DB2 on Mandrake Linux 8.1

  1. List all DB2 instances:
    
bash# /usr/IBMdb2/V7.1/instance/db2ilist
    

  2. Drop each instance listed in the previous step with the following command:
    
bash# /usr/IBMdb2/V7.1/instance/db2idrop <instanse-name>
    

  3. Drop the DB2 administration server:
    
bash# /usr/IBMdb2/V7.1/instance/dasidrop `/usr/IBMdb2/V7.1/instance/dasilist`
    

  4. Uninstall all of the DB2 packages on your system using the db2deinstall command on your DB2 CD-ROM:
    
bash# /mnt/cdrom/db72pf5u/db2_deinstall -n
    

  5. To remove all users (db2inst1..db2instN, db2fenc, db2as) created by DB2 issue the following commands:
    
bash# userdel -r db2inst1
    bash# ..
    bash# userdel -r db2instN
    bash# userdel -r db2fenc1
    bash# ..
    bash# userdel -r db2fenc2
    bash# userdel -r db2as
    


3.4. Red Hat Linux 6.2

3.4.1. Before installing DB2 on Red Hat

Preparing for the installation of DB2

  1. Install the pdksh-5.2.14-2.i386.rpm package from the Red Hat CD-ROM in the /RedHat/RPMS/ directory. For example, log in as root, mount the CD-ROM, and enter the following command to install the pdksh package:
    bash# rpm -ivh /mnt/cdrom/RedHat/RPMS/pdksh-5.2.14-2.i386.rpm


3.4.2. Installing DB2 and creating instances on Red Hat

Follow the instructions in Section 4, the generic section on installing DB2 and creating instances.


3.4.3. After installing DB2 on Red Hat

With Red Hat 6.2, you don't need to take any special steps after installing DB2 Version 7.1. It works.


3.5. Red Hat Linux 7.1

3.5.1. Before installing DB2 on Red Hat

Preparing for the installation of DB2

  1. Install the pdksh-5.2.14-12.i386.rpm package from Red Hat CD-ROM (2) in the /RedHat/RPMS/ directory. For example, log in as root, mount the CD-ROM, and enter the following command to install the pdksh package:
    bash# rpm -ivh /mnt/cdrom/RedHat/RPMS/pdksh-5.2.14-12.i386.rpm

  2. For a compatible version of the libstdc++ library, install the compat-egcs-c++-6.2-1.1.2.14.i386.rpm package from Red Hat CD-ROM (2) in the /RedHat/RPMS/ directory. For example, log in as root, mount the CD-ROM, and enter the following command to install the compat-egcs-c++ package:
    bash# rpm -ivh /mnt/cdrom/RedHat/RPMS/compat-egcs-c++-6.2-1.1.2.14.i386.rpm

  3. Install the compat-libs-6.2-3.i386.rpm package from Red Hat CD-ROM (2) in the /RedHat/RPMS/ directory. For example, log in as root, mount the CD-ROM, and enter the following command to install the compat-libs package:
    bash# rpm -ivh /mnt/cdrom/RedHat/RPMS/compat-libs-6.2-3.i386.rpm

  4. The db2setup command looks for a file called /usr/lib/libncurses.so.4 and will not proceed unless it exists, so create a symbolic link from the ncurses4.0 library in /usr/i386-glibc21-linux/lib/ to your /usr/lib/ directory.
    
bash# ln -sf /usr/i386-glibc21-linux/lib/libncurses.so.4.0 /usr/lib/libncurses.so.4
    

  5. The default setting for the msgmni kernel parameter only allows a couple of simultaneous connections to DB2. To set this value at at boot time, append the following lines to /etc/sysctl.conf:
    
# Sets maximum number of message queues to 128
    # Set this to 1024 or higher on production systems
    kernel.msgmni = 128
    


3.5.2. Installing DB2 and creating instances on Red Hat

Follow the instructions in Section 4, the generic section on installing DB2 and creating instances.


3.5.3. After installing DB2 on Red Hat

Red Hat 7.1 enabled the floating stack feature of the glibc library. Unfortunately, this causes Java programs using IBM JDK 1.1.8, including the DB2 Control Center, to fail miserably. Fortunately, you can disable the floating stack by setting the LD_ASSUME_KERNEL environment variable to 2.2.5 before running the DB2 Control Center as follows:

bash$ export LD_ASSUME_KERNEL=2.2.5
bash$ db2set DB2ENVLIST=LD_ASSUME_KERNEL
bash$ db2jstrt 6790
bash$ db2cc 6790

With IBM JDK 1.3 (IBMJava2-SDK-1.3-7.0-i386.rpm), the DB2 Control Center started successfully without any workarounds. For instructions on installing the IBM JDK, see Section 11.


3.6. SuSE Linux

3.6.1. Before installing DB2 on SuSE

At some point in its past, SuSE included an old beta version of DB2 in their distribution. When you install SuSE Linux, up to and including version 7.0, the SuSE installer still creates the default DB2 user IDs and sets their home directories in /usr/lib. This can cause some difficulties when you set up the DB2 instances. Before installing DB2, remove the default DB2 user IDs by issuing the following commands as root:

bash# userdel -r db2as
bash# userdel -r db2fenc1
bash# userdel -r db2inst1


3.6.2. Installing DB2 and creating instances on SuSE

Follow the instructions in Section 4, the generic section on installing DB2.


3.6.3. After installing DB2 on SuSE

With SuSE 6.2 or above, I have not needed to take any special steps after installing DB2 Version 7.1. It just works—and that's nice.


3.7. TurboLinux 6.0

3.7.1. Before installing DB2 on TurboLinux

TurboLinux 6.0 includes all of the required packages at or above the minimum required levels for DB2 Version 7.1.


3.7.2. Installing DB2 on TurboLinux

Follow the instructions in Section 4, the generic section on installing DB2.


3.7.3. After installing DB2 on TurboLinux

When you run the DB2 Control Center with TurboLinux 6.0, the console window may display a number of map failed messages. These messages do not indicate a serious problem, so do not worry about them.


4. Installing DB2 using db2setup

The purpose of this section is to walk you through a typical install of DB2 Version 7.1 on Linux. The following section, Section 6, tells you how to create both a DB2 Administration Server and a DB2 instance. For in-depth information on the components offered by DB2 Version 7.1, consult the following documents:

For the purposes of this document, I'll assume that you have a copy of DB2 Version 7.1 on CD-ROM. If you download a copy from IBM, just adjust the path /mnt/cdrom in the following instructions to reflect the directory created by the tar command.

Tip

Some distributions disable execute privileges on CD-ROM devices by default. To mount a CD-ROM with execute permissions at mount point /mnt/cdrom, issue the following command as root:

bash# mount -o exec /mnt/cdrom


4.1. Using the db2setup utility

You'll find the following executables on the root directory of the DB2 Version 7.1 installation CD-ROM:

  • db2setup: Use the db2setup command to install DB2 Version 7.1, to create or modify DB2 instances, and to create a DB2 Administration Server. Once you install DB2, db2setup is copied to the /usr/IBMdb2/V7.1/install directory to enable you to create or modify instances without the CD-ROM.

  • db2_install: The db2_install command provides an alternate means of installing DB2 RPMs. Unlike db2setup, it does not enable you to create a DB2 instance or Administration Server, or install a license key. I highly recommend db2setup.

  • db2_deinstall: Use the db2_deinstall command to uninstall the DB2 Version 7.1 packages on your system. For more information, see Section 7.

Note

The db2setup command provides a terminal-based text menu for your installation and instance creation options. Unfortunately, db2setup on Linux sometimes encounters a few formatting bugs in terminal emulators. Running db2setup from the TTY console works well. Within an X session, the rxvt or xterm terminals work quite well, but gnome-terminal is rather frustrating to use. If the text menu formats incorrectly, press CTRL-L to refresh the menu.


4.2. Installing DB2 components

The following instructions assume that you are using db2setup to install DB2.

To select or deselect a component, highlight the component using the cursor keys and press ENTER.

To change the options for a component, highlight [ Customize... ] and press ENTER.

To install your selected components, highlight [ OK ] on the Install DB2 V7 menu and press ENTER.

The common DB2 files are installed in the /usr/IBMdb2/V7.1/ directory. When you create an instance, a directory called sqllib is created in the corresponding user's home directory. The sqllib directory contains symbolic links to the executables and other files in /usr/IBMdb2/V7.1/.

The following list describes some of the common DB2 components that you can install, including estimates of the size required for each component.

Description of DB2 components

Administration Client

The Administration Client enables database administrators to administer local or remote DB2 servers from the command line. This component, without Java support or the Control Center, requires about 20 MB of disk space.

Control Center

The Control Center (db2cc) is an optional part of many DB2 components. It gives database administrators a graphical interface for administering local or remote DB2 servers. The Control Center includes the DB2 Information Center (db2ic), which gives you a graphical interface that provides a tree view of the DB2 documentation installed on your workstation organized by task or by title.

Note that both the Control Center and Information Center are Java applications, so their performance depends on your system's processor speed and available memory. This component requires about 90 MB of disk space.

Tip

You probably want to install the Control Center.

DB2 UDB Enterprise Edition, DB2 UDB Workgroup Edition, DB2 Personal Edition

These components determine the state of your DB2 installation as a database server. The core capabilities of the components are the same. The difference between Enterprise Edition and Workgroup Edition primarily has to do with how they are licensed--Enterprise Edition is licensed on a per-processor basis with unlimited users, while Workgroup Edition is licensed on a per-user basis. Enterprise Edition also gives you the capability to enable DB2 clients to connect to mainframe databases, like DB2 for OS/390 or DB2 for OS/400. In contrast, Personal Edition is a single user database server that is useful only for developing DB2 applications. You cannot use Personal Edition as a server because Personal Edition does not accept incoming remote connections.

Adding one of these components requires about 40 MB of disk space.

Options for DB2 servers

Replication

This option enables your DB2 server to replicate data to other DB2 servers, and, with additional software, across non-DB2 servers as well. This option requires about 5 MB of disk space.

Distributed Join for DB2 Data Sources

This option enables your DB2 server to participate in a join with data from other database servers. This option requires about 2 MB of disk space.

Application Development Client

The Application Development Client component installs the headers and libraries that you need to create applications using embedded SQL for C and C++, Call Level Interface (CLI), Java Database Connectivity (JDBC), or embedded SQL for Java (SQLJ). You also have the option of installing the source code for sample applications that demonstrate much of the functionality of DB2.

Tip

If you plan on developing applications for DB2, install the sample applications. The sample directories in /usr/IBMdb2/V7.1/samples/ contain build scripts (bld***) that include the compile and link options suitable for your own applications.

Tip

If you are trying to develop applications and you get an error like "That command is not supported in this environment" while trying to precompile a file, it's because you either did not install the Application Development Client, or you installed it after you created an instance and you have not used the db2iupdt command to update the instance. See Section 9.1 for more information on db2iupdt.

Including the sample applications, this component requires about 10 MB of disk space.

DB2 Product Library (HTML documentation)

Documentation is installed into the /usr/IBMdb2/V7.1/doc/ directory. For each language that you install, the DB2 installer creates a subdirectory with a five-character name corresponding to the language locale. Issue the db2help command to fire up your Web browser with a page that links to the documentation installed with DB2.

The English HTML (En_US) documentation requires about 90 MB of disk space.


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.

Christoph Shmitz reports that, while he was able to install DB2 Version 7.1 Personal Developer's Edition on Debian 2.2 using alien as described above, DB2 starts in a time-limited trial mode (90 days). While the use of DB2 Version 7.1 Personal Developer's Edition should be unlimited, alien does not automatically install the DB2 license file.

To remove the time limit on DB2 Version 7.1 Personal Developer's Edition, you need to manually install the license file (s000510.personal/db2/license/db2udbpe.lic in the tar archive) using the following command as root:

bash# db2licm -a db2udbpe.lic

Using alien 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.

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:

bash$ 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
    
bash$ 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
    

After installing DB2 with alien, Claus Reiner reported that:

While all components of DB/2 were installed, the instance apparently didn't know them and thus couldn't use them. After a lot of sweat going through the configurations, IBM support told me that I should make an instance update which solved it. (The instance could locally and between Unixen do everything, only when trying to connect to AS/400 using DCS it told us 'authentication not supported').

Claus recommends running the following commands as root after installing DB2 with either alien or RPM,

bash# . $INSTANCEHOME/sqllib/db2profile
bash# /usr/IBMdb2/V7.1/instance/db2iupdt -e


6. Creating DB2 instances

This section gives you a brief overview of DB2 instances and the DB2 Administration Server, and tells you how to create them.

Some IBM documentation uses the term "instance" to refer to both DB2 instances and a DB2 Administration Server. The basic similarity between a DB2 Administration Server and a DB2 instance, or "database manager", is that each is associated with a unique user ID. When you create either a DB2 instance or a DB2 Administration Server, DB2:

  • creates one or more new user IDs and corresponding home directories

  • creates a subdirectory in the instance home directory called sqllib

  • alters the .bashrc file to call the ~/sqllib/db2profile shell script to set up the environment for the instance


6.1. Overview of DB2 Administration Server

Like a queen bee in a hive, only one DB2 Administration Server can exist on any given DB2 server. By locally or remotely logging as the user ID that corresponds to the DB2 Administration Server, a database administrator uses the DB2 Administration Server to create, drop, or change the properties of DB2 instances.


6.2. Overview of DB2 instance

To quote the IBM DB2 Universal Database Version 7.1 Administration Guide definition of an instance:

An instance (sometimes called a database manager) is DB2 code that manages data. It controls what can be done to the data, and manages system resources assigned to it. Each instance is a complete environment. ... An instance has its own databases (which other instances cannot access), and all its database partitions share the same system directories. It also has separate security from other instances on the same machine (system).

What this boils down to is that for every DB2 instance, DB2 requires a unique user ID on your Linux workstation. Security for an instance is provided by the normal password authentication process for any Linux user ID. Each instance can contain one or more databases, each of which inherits settings from their instance.

Creating the Administration Server using db2setup

The DB2 Administration Server requires about 3 MB of disk space. The following steps guide you through the process of creating a DB2 Administration Server.

  1. Issue the db2setup command as described in Section 4.2.

  2. Select [ Create... ].

  3. Select the check box for Create the Administration Server. The Administration Server window is displayed.

  4. Enter a unique user name in the User Name field. You can use an existing user name that is not already in use by a DB2 instance, but it is probably simpler to create a new user for each instance.

  5. Select the Use default UID check box. As far as I can tell, this setting is always right.

  6. Enter a unique group name in the Group Name field. You can use an existing group name if you wish, but creating a new group ensures that you do not inadvertently give permissions to other users on your system.

  7. Select the Use default GID check box. Again, as far as I can tell, this setting is always right.

  8. Ensure that the value of the Home Directory field reflects the home directory of the user ID.

    Warning

    SuSE users: The prefix for the home directory may default to /usr/lib/db2/. This is almost certainly wrong; the value for a standard SuSE system should be /home/.

  9. Enter a unique password in the Password and Verify Password fields.

    Warning

    Enter a new password! If you do not enter a new password in these fields, DB2 assigns the default password ibmdb2, giving crackers a wide-open front door to your system.

Creating a DB2 instance using db2setup

A DB2 instance requires about 2 MB of disk space. A sample database for a DB2 instance requires about 16 MB of disk space. The following steps guide you through the process of creating a DB2 instance.

  1. Issue the db2setup command as described in Section 4.2.

  2. Select [ Create... ].

  3. Select the Create a DB2 Instance check box. The DB2 Instance window is displayed.

  4. Enter a unique user name in the User Name field. You can use an existing user name that is not already in use by a DB2 instance, but it is probably simpler to create a new user for each instance.

  5. Select the Use default UID check box. As far as I can tell, this setting is always right.

  6. Enter a unique group name in the Group Name field. You can use an existing group name if you wish, but creating a new group ensures that you do not inadvertently give permissions to other users on your system.

  7. Select the Use default GID check box. Again, as far as I can tell, this setting is always right.

  8. Ensure that the value of the Home Directory field reflects the home directory of the user ID.

    Warning

    SuSE users: The prefix for the home directory may default to /usr/lib/db2/. This is almost certainly wrong; the value for a standard SuSE system should be /home/.

  9. Enter a unique password in the Password and Verify Password fields.

    Warning

    Enter a new password! If you do not enter a new password in these fields, DB2 assigns the default password ibmdb2, giving crackers a wide-open front door to your system.

  10. Select [ Properties... ] to change the properties for the instance.

    1. Under the Authentication Type heading, select the Server Encrypt check box. This greatly improves the security of your system, by telling DB2 to accept encrypted passwords, rather than plain text passwords.

    2. Select the Auto start DB2 Instance at system boot check box if you want to start this DB2 instance every time you reboot your system.

    3. Select the Create a sample database for DB2 Instance check box if you plan to work with the sample applications available with the Application Development Client. To run correctly, most of the sample applications require the specific tables and data of the sample database. If you do not create the sample database now, you can create it later using the db2sampl command.

  11. Select [ OK ] to create the DB2 instance. The Fenced User text window is displayed. Repeat the previous steps for creating a new user and group. Server-side DB2 executables, such as stored procedures and user-defined functions, execute under the permissions of the fenced user ID. By controlling the permissions of the fenced user ID, you control the permissions of the server-side DB2 executables.

  12. Select [ OK ] to create the fenced user.


7. Removing DB2

To remove DB2 from your workstation cleanly, perform the following steps:

  1. Log in as root.

  2. List all DB2 instances:
    bash# /usr/IBMdb2/V7.1/instance/db2ilist

  3. Drop each instance listed in the previous step with the following command:
    bash# /usr/ibmdb2/v7.1/instance/db2idrop instance-name

  4. Drop the DB2 administration server:
    bash# /usr/IBMdb2/V7.1/instance/dasidrop `/usr/IBMdb2/V7.1/instance/dasilist`

  5. Uninstall all of the DB2 packages on your system using the db2deinstall command on your DB2 CD-ROM:
    bash# /mnt/cdrom/db2/db2_deinstall -n


8. Using DB2

This section gives you the basic information you need to start working with DB2 on Linux. It includes instructions on issuing DB2 commands and SQL statements from the command line, as well as the commands you need to start the DB2 Control Center and the DB2 Information Center.

Note

This section assumes that you have followed the instructions in Section 11.


8.1. DB2 Control Center

The left side of the DB2 Control Center provides an object-oriented view of the database objects that you have catalogued, including DB2 instances and databases on other DB2 servers. One way to add, edit, or drop database objects is to right-click on an object to bring up a menu.

To start the DB2 Control Center

  1. Ensure you are logged on to your Linux workstation using either the DB2 Administration Server user ID or the DB2 instance user ID. If you use the su command to become the user, ensure you include the -l parameter to initialize the environment for the user.

  2. Start the X server, if it is not already started.

  3. Issue the db2cc command to start the DB2 Control Center. Depending on the speed of your system, it may take a few seconds for the splash screen to appear, and longer before the full DB2 Control Center appears.


8.2. DB2 Information Center

The DB2 Information Center provides tree views of the information about DB2 that is installed on your system, as well as a number of links to web sites with further information. If you did not install the DB2 documentation, the tree views contain fewer links.

To start the DB2 Information Center

  1. Ensure you are logged on to your Linux workstation using either the DB2 Administration Server user ID or the DB2 instance user ID. If you use the su command to become the user, ensure you include the -l parameter to initialize the environment for the user.

  2. Ensure that the X server is started.

  3. Issue the db2ic command to start the DB2 Information Center. Depending on the speed of your system, it may take a few seconds for the splash screen to appear, and longer before the full DB2 Information Center appears.


8.3. The DB2 command line

If you are logged on to your Linux workstation using either the DB2 Administration Server user ID or the DB2 instance user ID, you can issue DB2 commands and SQL statements from the command line.

If this is your first time using DB2, I would suggest creating the sample database that ships with DB2. The sample database is used throughout the DB2 documentation and is required by most of the sample applications. To create the sample database, you can either select the Create the sample database option when you create a DB2 instance, or issue the db2sampl command from the DB2 command line.

Before you can issue an SQL statement, you have to connect to a database. To connect to a database:

  • db2 CONNECT TO database USER userID USING password

To connect to a database, and have DB2 prompt you for the password:

  • db2 CONNECT TO database USER userID

To connect to a database using the default user ID:

  • db2 CONNECT TO database

Once you have connected to a database, you can then issue SQL statements or DB2 commands against that database. For example, to select all of the columns from the EMPLOYEE table in the SAMPLE database, issue the following command:
bash$ db2 "SELECT * FROM employee"

Note

You can avoid typing db2 as the prefix for every SQL statement and DB2 command by issuing commands using the Command Line Processor (CLP). To start the CLP, issue the db2 command by itself. DB2 provides the following prompt:

You can issue database manager commands and SQL statements from the command
prompt. For example:
    db2 => connect to sample
    db2 => bind sample.bnd

For general help, type: ?.
For command help, type: ? command, where command can be
the first few keywords of a database manager command. For example:
 ? CATALOG DATABASE for help on the CATALOG DATABASE command
 ? CATALOG          for help on all of the CATALOG commands.

To exit db2 interactive mode, type QUIT at the command prompt. Outside
interactive mode, all commands must be prefixed with 'db2'.
To list the current command option settings, type LIST COMMAND OPTIONS.

For more detailed help, refer to the Online Reference Manual.

db2 =>

I don't use the CLP because it prevents me from using the command line history feature of my shell. I find myself using the command line history a lot when I'm issuing SQL statements.

Some users claim that running the CLP within an Emacs shell gives them the best of both worlds: they get command line history, and they don't have to escape commands that contain lots of quotation marks and brackets.


9. Troubleshooting

The following section covers some of the common problems you may encounter while installing DB2, creating an instance, or using a DB2 database.


9.1. Problems with DB2 installation

The following section covers some of the common problems you may encounter when you install DB2.

9.1.1. When I try to run db2setup, I get the following error: DBI1503E An error was encountered when opening or writing to file, "/tmp/.dbinst.swp".
9.1.2. When I try to run db2setup, I get the following error: ./db2inst: error while loading shared libraries: libncurses.so.4: cannot open shared object file: No such file or directory
9.1.3. Creating a DB2 instance on SuSE Linux: Default user name already exists
9.1.4. Creating a DB2 instance on SuSE Linux: Default group name already exists
9.1.5. Creating a DB2 instance on SuSE Linux: Default home directory points to /usr/lib/db2/
9.1.6. After creating a DB2 instance, I installed the Application Development Client, but I can't use that instance to create DB2 applications.
9.1.7. I installed DB2, but none of the permissions in /usr/IBMdb2/V7.1/bin are executable!

9.1.1. When I try to run db2setup, I get the following error: DBI1503E An error was encountered when opening or writing to file, "/tmp/.dbinst.swp".

DB2 issues this error when it can't find the pdksh or ksh shells. This has probably occurred because you did not install the pdksh package for your distribution. See Section 3 for more details on installing the pdksh package for your Linux distribution.

9.1.2. When I try to run db2setup, I get the following error: ./db2inst: error while loading shared libraries: libncurses.so.4: cannot open shared object file: No such file or directory

DB2 issues this error when it can't find the libncurses.so.4 library. Red Hat 7 does not include this level of the library in their standard ncurses-5.1-2 package, requiring that you install the ncurses4-5.0-2 library for backwards compatibility.

9.1.3. Creating a DB2 instance on SuSE Linux: Default user name already exists

If you did not remove the default DB2 user IDs created by SuSE Linux before installing DB2 (see Section 3.6), the DB2 Create Instance panel places the corresponding user ID in the "User ID" field. This can cause a problem when you change the value of the User Name field to reflect the name of the new instance, because the value of the "User ID" still reflects the original user name.

Ensure that you select the "Use default UID" check box to automatically associate the new user name with its corresponding user ID.

9.1.4. Creating a DB2 instance on SuSE Linux: Default group name already exists

If you did not remove the default DB2 user IDs created by SuSE Linux before installing DB2 (see Section 3.6), the DB2 Create Instance panel places the corresponding group ID in the Group ID field. This can cause a problem when you change the value of the Group Name field to reflect the name of the new instance, because the value of the Group ID still reflects the original group name.

Ensure that you select the "Use default GID" check box to automatically associate the new group name with its corresponding group ID.

9.1.5. Creating a DB2 instance on SuSE Linux: Default home directory points to /usr/lib/db2/

If you did not remove the default DB2 user IDs created by SuSE Linux before installing DB2 (see Section 3.6), the default user name already exists and was created in the /usr/lib/db2/ directory. To change the home directory of your new DB2 instance, you must manually specify the location of the new instance. The default home directory is /home/.

9.1.6. After creating a DB2 instance, I installed the Application Development Client, but I can't use that instance to create DB2 applications.

When you add the Application Development Client after you initially install DB2 and create a DB2 instance, your existing DB2 instance won't recognize the db2 prep command. Instead, DB2 returns the following error: DB21051E The command is not supported for this environment.

The problem is that when you install a new DB2 component, DB2 does not automatically update existing DB2 instances to include links to the new libraries and executables. To update an existing DB2 instance, use the db2iupdt command as root:
bash# /usr/IBMdb2/V7.1/instance/db2iupdt instance-name
To update all existing DB2 instances, issue the following command as root:
bash# /usr/IBMdb2/V7.1/instance/db2iupdt -e

9.1.7. I installed DB2, but none of the permissions in /usr/IBMdb2/V7.1/bin are executable!

When you create an instance, as described in Section 6, DB2 copies selected files from /usr/IBMdb2/V7.1/bin into the $HOME/sqllib/bin directory of the instance. DB2 sets the appropriate permissions on the copies of the files in the instance directory.


9.2. Problems creating a DB2 instance

The following section covers some of the common problems you may encounter when you create a DB2 instance.

9.2.1. Creating a DB2 instance or a DB2 Administration Server fails.
9.2.2. db2setup indicated that it successfully created an instance, but I checked /tmp/db2install.log and it contains the message DBI1766W Cannot change the secondary group list of "" (Caldera OpenLinux 2.4).

9.2.1. Creating a DB2 instance or a DB2 Administration Server fails.

DB2 often fails to create an instance because you became root by issuing the command bash$ su root rather than bash$ su -l root, which uses the environment settings for the root account. Check the contents of the DB2 install log in /tmp/db2setup.log. If the installer has issued the following error message:

  DBI1517E An attempt to execute a command in a subprocess failed.

  Explanation: An error was detected when attempting to execute a command in a subprocess. One of the
  following problems occurred:

      o The command does not exist.
      o Incomplete command search path.
      o Incorrect access permissions on the command.
      o System resource problem.
then most likely your root account did not have the /usr/sbin directory in the PATH environment variable for root.

PATH is normally set correctly for you if you log in as root, or issue the command bash$ su -l root to become root. You can add /usr/sbin to the PATH environment variable by issuing the following command at the terminal prompt, or including it in /root/.bashrc:

  export PATH=$PATH:/usr/sbin

9.2.2. db2setup indicated that it successfully created an instance, but I checked /tmp/db2install.log and it contains the message DBI1766W Cannot change the secondary group list of "" (Caldera OpenLinux 2.4).

This is one area where DB2 and Caldera OpenLinux don't work well together. Fix this by manually adding each instance user ID to the group you defined during instance creation. Here's the full help from the IBM DB2 Message Reference:

      DBI1766W Cannot change the secondary group list of
                "".

      Explanation:  A code, "", is returned when attempting to
      change the secondary group list of the given user ID. One of the
      following situations has occurred:

      o  NIS is running.

      o  One or more processes are currently being executed under the
          given user ID.

      User Response:  You must add the group ID, "", to the
      secondary group list of the user ID, "", so that the
      Adminstration Server can function properly.

      o  If there happens to be any process run under the given user
          ID, terminate all of these processes and follow the
          instructions above to setup the secondary group list of this
          user ID.

      o  If you are running this command on an NIS client, try the
          above instructions to setup the secondary group list of this
          user ID on your NIS server.
For instructions on how to add user IDs to groups, see Section 3.1.3.1.


9.3. Problems using DB2

The following section covers some of the common problems you may encounter when you use a DB2 database.

9.3.1. DB2 is running out of available connections.
9.3.2. I installed DB2 Version 6.1 and db2start just hangs.
9.3.3. I'm using DB2 PE 7.1 on linux (RH 6.0), and I'm having problems when trying to connect with my username and password. I can connect successfully to the database with the default user ID:

bash$ db2 connect to sample

Database Connection Information

Database server        = DB2/LINUX 7.1.0
SQL authorization ID   = userID
Local database alias   = SAMPLE
But when I try to connect to the database using the explicit user ID, it fails:

bash$ db2 CONNECT TO sample USER userID
Enter current password for userID:
SQL1403N  The username and/or password supplied is incorrect.
SQLSTATE=08004
Why can't I connect with an explicit user ID?
9.3.4. When I run any db2 commands, part of the output is Welcome to your OpenLinux system!. How do I change this? (Caldera OpenLinux 2.4)
9.3.5. How do I connect from a DB2 Connect for Linux client to a DB2 for AS/400 server?

9.3.1. DB2 is running out of available connections.

You probably need to adjust some kernel parameters. For more information, see Section 10.

9.3.2. I installed DB2 Version 6.1 and db2start just hangs.

Hey! I said I wasn't going to include any DB2 Version 6.1 information! Oh well, this is one of the most frequently asked questions about 6.1, so here's a short answer: you need to install a recent DB2 FixPack. The initial release of DB2 Version 6.1 ran into incompatibilities with distributions built on glibc 2.1. For a full description of the problem, and the correct install procedure, refer to IBM Support document 1000814: db2start hangs on Linux distributions built with glibc 2.1.

9.3.3. I'm using DB2 PE 7.1 on linux (RH 6.0), and I'm having problems when trying to connect with my username and password. I can connect successfully to the database with the default user ID:

bash$ db2 connect to sample

Database Connection Information

Database server        = DB2/LINUX 7.1.0
SQL authorization ID   = userID
Local database alias   = SAMPLE
But when I try to connect to the database using the explicit user ID, it fails:

bash$ db2 CONNECT TO sample USER userID
Enter current password for userID:
SQL1403N  The username and/or password supplied is incorrect.
SQLSTATE=08004
Why can't I connect with an explicit user ID?

Check the ownership and permissions on the db2ckpw program. They should look like this:

bash$ ls -al ~/sqllib/security/db2ckpw
-rwsr-s--x    1 root     build       15989 Oct 17 07:22 sqllib/security/db2ckpw*
If this program is not owned by root, then do the following as root:

bash# chown root db2ckpw
bash# chmod ug+s db2ckpw

9.3.4. When I run any db2 commands, part of the output is Welcome to your OpenLinux system!. How do I change this? (Caldera OpenLinux 2.4)

Caldera OpenLinux includes this annoying message as part of their default login. For instructions on how to remove or modify this output, see Section 3.1.3.3.

9.3.5. How do I connect from a DB2 Connect for Linux client to a DB2 for AS/400 server?

Claus Reiner contributed the following procedure:

Preparing DB2 for AS/400 to accept connections

AS/400 has a special service that must be run and other things that need to be prepared:

  1. Name the database and make a *LOCAL entry Command WRKRDBDIRE. There should be an entry with a remote location name of *LOCAL. The relational database name specified with that entry is the external name of the AS/400 database. Typically this is the same name as the system name.

  2. Set the code page to 37. For the user that connects, change the CCSID parameter from *SYSVAL to 37, or change it system-wide:
    
  CHGUSRPRF USRPRF(user) CCSID(37)
    
    or
    
 CHGSYSVAL SYSVAL(QCCSID) VALUE(37)
    

  3. Start a service to listen on port 446. To start the service once:
    
  STRTCPSVR SERVER(*DDM)
    
    To automatically start the service:
    
  CHGDDMTCPA AUTOSTART(*YES)
    

  4. Create a NULLID collection by issuing the following SQL statement:
    
  CREATE COLLECTION NULLID
    

  5. Possibly create a collection for the user ID to connect with:
    
  CREATE COLLECTION userid
    

Preparing DB2 Connect for Linux to connect to an AS/400 database

On the Linux side, you need to perform the following steps:

  1. Catalog the remote node (the AS/400) with OSTYPE OS400:
    
bash$ db2 CATALOG TCPIP NODE as400 REMOTE as400 \
              SERVER 446 REMOTE_DATABASE as400_dbname \
              OSTYPE os400
    

  2. Catalog the remote database in DCS:
    
bash$ db2 CATALOG DCS DATABASE as400_dbname AS as400_dbname
    

  3. Catalog the remote database:
    
bash$ db2 CATALOG DATABASE as400_dbname AS as400_dbname \
              AT NODE as400 AUTHENTICATION DCS
    


9.4. Problems starting the DB2 Control Center

The following section covers some of the common problems you may encounter trying to start the DB2 Control Center.

9.4.1. When I start the DB2 Control Center with db2cc, nothing happens.
9.4.2. When I start the DB2 Control Center, I get a message box with the error SQL1042C An unexpected system error occurred.
9.4.3. I followed the instructions for installing IBM JDK 1.1.8 but Java applications, including the DB2 Control Center, don't work.
9.4.4. The DB2 Control Center starts normally, but the "Systems" folder is empty.
9.4.5. When I try to start the DB2 Control Center, I get the following message at the console: Xlib: connection to "localhost:0.0" refused by server
9.4.6. When I start the DB2 Control Center, I get a message box with the error SQL1042C An unexpected system error occurred.
9.4.7. When I try to start the DB2 Control Center with the db2cc command, the splash screen comes up, then disappears.

9.4.1. When I start the DB2 Control Center with db2cc, nothing happens.

On some systems, for unknown reasons, issuing the db2cc command will not start the Control Center. You can often get the DB2 Control Center to start by explicitly starting a DB2 JDBC server on a specified port, then issuing the db2cc command with the port number. The following example starts the DB2 JDBC server and DB2 Control Center on port 6799:

bash$ db2jstrt 6799
bash$ db2cc 6799

9.4.2. When I start the DB2 Control Center, I get a message box with the error SQL1042C An unexpected system error occurred.

On most systems, this error occurs only the first time you start the Control Center. Note that the message box may be mostly covered up by the pretty DB2 splash screen; if this is the case, you have to move the error message window down and press the "Close" button. The Control Center then starts correctly, and you should not get the error message again.

9.4.3. I followed the instructions for installing IBM JDK 1.1.8 but Java applications, including the DB2 Control Center, don't work.

Red Hat 7.1 enabled a floating stack feature in the glibc library that breaks the IBM JDK 1.1.8. Other distributions might follow their lead.

Set the LD_ASSUME_KERNEL environment variable to 2.2.5 before running the DB2 Control Center or your Java application:

bash$ export LD_ASSUME_KERNEL=2.2.5
bash$ db2set DB2ENVLIST=LD_ASSUME_KERNEL
It would probably be wise to include these commands in the sqllib/db2profile script of your instance user so that you always inherit these settings.

9.4.4. The DB2 Control Center starts normally, but the "Systems" folder is empty.

If the Control Center displays an empty "Systems" folder, you might need to catalog the DB2 Administration Server manually for the local instance from which you are trying to run the Control Center. This assumes that you have created the DB2 Administration Server instance before starting the Control Center.

To catalog the DB2 Administration Server, issue the following command:
bash$ db2 catalog admin local node machine-name instance Administration-Server-name system machine-name ostype linux
Now restart the Control Center. Your local system is now displayed under the "Systems" folder. Do not try this from a client-only install of DB2, because no local DB2 Administration Server can be available.

9.4.5. When I try to start the DB2 Control Center, I get the following message at the console: Xlib: connection to "localhost:0.0" refused by server

This normally indicates an X permissions problem that occurs when you log on as one user, then su to the DB2 instance owner so that you can start the DB2 Control Center. By default, most X servers do not recognize 'localhost' as a client that is allowed to initiate an X app on your display; it will only recognize your real hostname. If xauth is set up, then it will complain if a user ID other than the one that started X tries to invoke an X application.There are a few things you can try:

  • Before su'ing to the DB2 instance owner, issue the command bash$ xhost +localhost: this tells your X server that 'localhost' is allowed to start X apps on your display. Then su to the DB2 instance owner and start the Control Center.

  • Log out completely, then log on directly as the DB2 instance owner and start the Control Center. You may still have to issue the command bash$ xhost +localhost before the Control Center will start--recent distributions have added this extra level of security.

  • Look into the xauth command and add your primary user ID's ~/.Xauthority file to your DB2 instance owner's xauth authority database. I believe it's the xauth merge command that you want.

9.4.6. When I start the DB2 Control Center, I get a message box with the error SQL1042C An unexpected system error occurred.

On most systems, this error occurs only the first time you start the Control Center. Note that the message box may be mostly covered up by the pretty DB2 splash screen; if this is the case, you have to move the error message window down and press the "Close" button. The Control Center then starts correctly, and you should not get the error message again.

9.4.7. When I try to start the DB2 Control Center with the db2cc command, the splash screen comes up, then disappears.

On Caldera, the Control Center didn't work for me until I added the instance user IDs to the appropriate groups. For more information, see Section 3.1.3.1.

Ensure that you have installed the IBM Developer Kit for Java, and that the directory containing the jre or java executable is in your path. If you issue the command
bash$ java -fullversion
, you should get a response like this: java full version "JDK 1.1.8 IBM build l118-20000325 (JIT enabled: jitc)" or, for the IBM JDK 1.3: java full version "J2RE 1.3.0 IBM build cx130-20000623" Java virtual machines from other sources may not work. For a quick guide to installing the IBM Developer Kit for Java, see Section 11.


10. Improving DB2 Version 7.1 performance on Linux

Database administrators running DB2 on Linux often run into problems attempting to perform the following tasks:

  • increasing the maximum number of simultaneous connections to the DB2 server

  • configuring buffer pools

The following sections attempt to address those problems.


10.1. Increasing maximum connections

One of the most frequently reported problems with running DB2 on Linux is that DB2 seems to quickly start refusing connections to the server. You can alleviate this problem by examining an altering several kernel parameters that control inter-process communication (ipc) limits.

The number of connections that DB2 can support depends on kernel parameters that, in the 2.2 kernel, are #define variables included in the kernel source header files. In the 2.4 kernel, some of these parameters can be set through the /proc filesystem. Following the description of these variables is a table listing the default values by distribution. The table includes the values of these variables in the updated kernel packages for each distribution.

_SHM_ID_BITS

This variable, defined in /usr/src/linux/include/asm/shmparam.h, determines the number of shared memory segment identifiers available to Linux. The default value for _SHM_ID_BITS in the kernel source is 7, which allows for a total of 2^7, or 128, shared memory segment identifiers.

On a single-processor machine, DB2 itself uses a set number (~15) of shared memory segment identifiers. On a machine with multiple processors, DB2 also requires one shared memory segment identifier per agent to take advantage of the Fast Communication Manager (FCM) feature of DB2. Because each DB2 connection requires one agent per processor, on a quad-processor machine the default value of _SHM_ID_BITS allows less than 32 simultaneous connections to a DB2 instance.

If you recompile the kernel yourself, you should be able to safely increase this value to 9.

MSGMNI

This variable determines the maximum number of message queue identifiers. For DB2 Version 7.1 to function correctly, the minimum value is 128, but for heavier use consider setting this value to 1024 or higher.

In the 2.2 kernel source, this variable is defined in /usr/src/linux/include/linux/msg.h. The default value of 128 is acceptable for small-scale use of DB2 Version 7.1.

In the 2.4 kernel source, this variable is defined in /proc/sys/kernel/msgmni. The default value of 16 must be increased to enable DB2 Version 7.1 to function correctly. The good news is that you can change this value without recompiling the kernel or rebooting your machine. For more information, see Section 12.

NR_TASKS

This variable, defined in /usr/src/linux/include/linux/tasks.h, determines the number of simultaneous processes that Linux supports. A second variable, MAX_TASKS_PER_USER, is defined as NR_TASKS/2. Since DB2 instances are treated as users by Linux, and each connection uses a single process, the maximum number of connections per instance is capped at the value of NR_TASKS/2.

The default value for NR_TASKS in the kernel source is 512, allowing a maximum of 256 simultaneous connections to a single DB2 instance. DB2 itself requires a few connections for overhead processes. If you recompile the kernel yourself, you should increase this value to something like 2048. The stock kernels shipped with the Red Hat, SuSE, and TurboLinux distributions increase the value of NR_TASKS to 2560 or above. However, Caldera OpenLinux eDesktop 2.4 ships with a kern