IBM's Universal Database

by Paul Zikopoulos

Have you been trying to install DB2 Universal Database on a Linux-based workstation? Did you run into some troubles? As I scan around the DB2 and Linux newsgroups, I hear from many of users who are getting frustrated when trying to get DB2 running on Linux. How did this problem get so big? Well, the Linux phenomenon is relatively new and ever-changing. Recently, all sorts of vendors are flocking to market their distributions, with slight differences between them all. Combine that with what seems to be quarterly releases and you can see how communication channels between the Linux vendors and the people who build applications to run on them get clogged. While efforts are being made between application developers and Linux vendors to define this communication pipe, you can use the information in this article to get yourself up and running in no time at all.

DB2 for Linux is officially supported on the following Linux distributions: Caldera OpenLinux, Red Hat Linux, TurboLinux and SuSE Linux. This article will take you through the steps involved in installing DB2 on each of the supported Linux distributions. In the article, I assume you have not previously installed a version of DB2 and you are not maintaining any of the default users created by a default DB2 Installation. The three user IDs that will be created during a DB2 installation are: db2inst1, db2fenc1 and db2as. If you have any of these users on your system, be sure to remove them and their associated directories before installing DB2. This article also assumes you are familiar with the rpm command, used to install packages. If you are not familiar with this command, refer to your Linux documentation.

In order to run DB2 on Linux, the following are required:

  • Linux kernel 2.0.35 or higher

  • RPM (package manager)

  • pdksh package (public domain Korn shell)

  • glibc version 2.0.7 or higher

  • libstdc++ version 2.8.0

Preparing Your Linux Workstation for a DB2 Installation

The following sections will highlight any actions you need to perform on your Linux workstation to enable it for a DB2 installation. If a requirement exists by default on your system, I will not make note of it in the sections that follow. Keep in mind that the lag time between when this article was written and when you are going to read it may be a couple of months. In that time, some of the levels or links I have referred to here may have changed.

DB2 and Caldera OpenLinux

The information I am providing in this section is based on a Caldera OpenLinux version 2.3, or simply Caldera, Standard Installation type. If you installed a different installation type on your Linux workstation, you may have to add some of the required packages to your workstation.

The pdksh package is missing from the default Standard Installation. This package is available on the Caldera CD-ROM; however, it is not compatible with DB2. IBM and Caldera are working to solve this problem, but in the meantime, I recommend you download a pdksh package from a Red Hat mirror site—it will work just fine. I am sure Caldera Systems will post a fix sometime on their FTP site at ftp://ftp.calderasystems.com/pub/.

For now, go to the mirror site at http://www.metalab.unc.edu/pub/Linux/distributions/redhat/redhat-6.1/i386/RedHat/RPMS/. Download the pdksh-5.2.14-1.i386.rpm package and install it with the rpm command using the -nodeps option. If you try to install this package without the -nodeps option, you will receive an error stating that this package has a requirement on the glibc package. This error is only a result of the different naming conventions used by Caldera Systems and Red Hat. A glibc package is installed by default.

For DB2 version 6, you require libstdc++ 2.80, DB2 v6 will not run with libstdc++ 2.9.0. Caldera version 2.3 by default installs with libstdc++ 2.9.0. The required libstdc++ 2.8.0 is located on the CD-ROM in the /col/contrib/RPMS directory as a package called libstdc++-compat-2.8.0-1.i386.rpm.

If you are running Caldera version 2.2, I recommend that you upgrade to version 2.3; it will make your DB2 installation much easier. In the event you do not want to do this, there are some things you will need to note on top of the issues I mentioned for Caldera version 2.3.

First, the libstdc++-compat-2.8.0-1.i386.rpm package, is not on the CD-ROM. You can get it from Caldera at ftp://ftp.calderasystems.com/pub/openlinux/2.3/contrib/RPMS/.

Finally, DB2 requires a file called libcrypt.so.1 to work. This file is usually shipped with every Linux distribution. Some problems with federal export laws caused Caldera version 2.2 to ship without this file. To add this file to your workstation, download the package glibc-crypt-2.1-3i.i386.rpm from ftp://ftp.linuxland.de/pub/OpenLinux/crypto/2.2/RPMS/. I could not find this fix on Caldera's FTP site.

Once you have completed these tasks, your Caldera version 2.2 workstation is ready for a DB2 installation.

DB2 and TurboLinux

The information I provide in this section is based on a TurboLinux version 3.6 Base Workstation installation. If you installed a different installation type on your Linux workstation, you may have to add some of the required packages to your workstation.

There are some problems trying to get DB2 to run on a workstation running TurboLinux. Download a fix from the Web at: ftp://ftp.software.ibm.com/ps/products/db2/tools/. The fix is called tl36_instfix.tar.Z, note that the l is the letter “l” not the number “1” All the information you require to implement this fix is mentioned in the README file called tl36_instfix.readme.txt.

After you have downloaded the fix, you need to add the pdksh package, which is not part of the Base Workstation installation. This file is available on the TurboLinux CD-ROM, in the /TurboLinux/RPMS directory.

Once you have completed these tasks, your TurboLinux version 3.62 workstation is ready for a DB2 installation.

DB2 for SuSE Linux

The information that I am providing in this section is based on a SuSE version 6.3 Network Oriented System installation. These instructions also apply to a workstation running SuSE version 6.2. If you installed a different installation type on your Linux workstation, you may have to add some of the required packages to your workstation.

The biggest problem with installing DB2 on a workstation that is running SuSE Linux is the naming convention that SuSE uses for its packages. For example, SuSE calls the required glibc package shlibs. This will causes problems when you try to install DB2 because the DB2 installation utility will fail to recognize the existence of the required glibc package. To get around this problem, you have to install a dummy package, called glibc-2.0.7-0.i386.rpm. This package is located in the /db2/install/dummyrpm directory on your DB2 product CD-ROM.

Additional Steps for SuSE Version 6.1

SuSE Linux version 6.1 ships with a beta copy of the DB2 for Linux version 5.2 code. Consequently, when you go to install DB2, this causes problems with the default users. To make things ever stranger, I noticed that when I installed the Network Oriented System installation, which was not supposed to include DB2, the default DB2 users were created. To make matters worse, I could not find any information about the passwords for the DB2 users that SuSE creates (they are not the default DB2 passwords), and some of the settings that SuSE implements do not work for DB2. In the end, remove the users (db2inst1, db2as, db2fenc1) that the SuSE installation creates. For more information on SuSE user management, refer to your product's documentation.

Once you have completed these tasks, your SuSE version 6.1 workstation is ready for a DB2 installation.

DB2 and Red Hat Linux

The information I provide in this section is based on a Red Hat version 6.0 Server installation. These instructions also apply to a workstation that is running Red Hat version 5.2, though the names of the packages may be at a different level. If you installed a different installation type on your Linux workstation, you may have to add some of the required packages to your workstation.

Both the Red Hat version 5.2 and version 6.0 installation are easy to enable for a DB2 installation. They are both missing the required pdksh package that is required to run the DB2 Installer. This package is located in the /RedHat/RPMS directory on the Red Hat CD-ROM.

If you are trying to install DB2 on a workstation that is running Red Hat version 6.1, you aren't going to get very far due to a problem with this version of Red Hat v6.1 and DB2. You can download the Red Hat fix at ftp.software.ibm.com/ps/products/db2/tools. The fix you need depends on where you got your DB2 code. If you are installing the copy of DB2 bundled with Red Hat 6.1, download the file db2rh61fix.tgz. If you are installing any other DB2 code, you need to download the db2rh61gafix.tgz file.

After you download the appropriate fix, unpack them by entering the tar xvzf filename command, where filename is the name of the downloaded fix file. After unpacking this file, you will see three files in the directory. Once of them is a README file, called readme.txt. This file gives complete and detailed instructions on how to implement this fix.

Once you have completed these tasks, your Red Hat version 6.1 workstation is ready for a DB2 installation.

Installing DB2

Installing DB2 is made easy by an installation and setup utility called DB2 Installer. This utility will install all required packages for DB2, create instances for DB2 databases and administration support, and configure your DB2 server for communications. The instructions in this section assume you do not change any of the defaults presented by DB2 Installer, unless noted in the steps below.

You will usually run into display problems if you start DB2 Installer from a command window in your Linux distribution's graphical interface. You can refresh the view of DB2 Installer at any time by pressing CTRL-L. To avoid most potential display problems, I recommend running the DB2 Installer in a virtual console session outside of your operating system's graphical interface. You can shift between the virtual console session and the graphical interface session on most Linux distributions by pressing CTRL-ALT-F1 and CTRL-ALT-F7. Refer to your Linux documentation for more details.

To quickly install DB2, perform the following steps:

  • Log on to the system as a user with root authority

  • Mount the DB2 product CD-ROM by entering the following command:

        mount -t iso9660 -o ro /dev/cdrom /mnt/cdrom
  • where /mnt/cdrom is the mount point of the CD-ROM. Note that even if you are installing DB2 on a workstation that is running TurboLinux version 3.6 or Red Hat Linux version 6.1, you still need to mount the CD-ROM. The image created by the install fix links to the DB2 CD-ROM. For more information, refer to your fix's readme.txt file.

  • Change focus to the mount point of the CD-ROM. Note that if you were installing DB2 on a workstation that is running TurboLinux version 3.6 or Red Hat Linux version 6.1, you would change to the directory where you created the image on your workstation. For more information, refer to your fix's readme.txt file.

  • Enter the ./db2setup command to start the DB2 Installer program. The Install DB2 V6.1 window will open. The contents of this window vary with respect to the DB2 product you are installing. Figure 1 is the window displayed when you are installing DB2 Workgroup Edition for Linux.

  • tab key to move the selector bar, and the ENTER key to select or deselect an option. For more information or assistance during the installation of DB2, select Help. From the product list, select the DB2 product you want to install. For this example, select DB2 UDB Workgroup Edition, then OK. The Create DB2 Services window will open.

  • Select the “Customize” option beside the DB2 product you want to install. For our example, select the “Customize” option beside the DB2 UDB Workgroup Edition option.

  • Select the “Java Support” and the “Control Center” components.

  • Select the “Create a DB2 Instance” option. Enter a password for this user and verify it by retyping this password in the field provided.

  • Select the “Properties” option.

  • Select the “Create a Sample Database” for a DB2 instance then OK.

  • Select OK.

  • A window will open that asks you to create a user that will be used to execute user-defined functions (UDFs) and stored procedures. For this example, you do not need to know anything about, or use, this user. Simply enter a password for this user, verify it and select OK. You are returned to the DB2 Create Services window. For more information on UDFs or stored procedures, refer to the “Administration Guide”.

  • Select the “Create the Administration Server” option. Enter a password for this user as well and select OK.

  • A pop-up window will open telling you the DB2 system's name for this workstation. Select OK. You are again returned to the Create DB2 Services window.

  • Select OK, then Continue, and finally, OK to begin the installation. When the installation completes, respond to the DB2 Installer's prompts to close this utility.

You are finished all the steps necessary to install DB2!

Verifying your DB2 Installation

Now that you have finished your installation, let's go through a quick sample query to prove to you that this powerful database is actually alive and running on your system.

To verify your installation, perform the following steps:

  • Log on to the system as the db2inst1 user. If you use the su command to do this, ensure that you enter this command with the - option; for example, su - db2inst1.

  • Enter the following command to connect to the sample database created by DB2 Installer:

        db2 connect to sample
  • You should receive output that is similar to the following:

        Database Connection Information
        Database server = DB2/LINUX 6.1.0
        SQL authorization ID = DB2INST1
        Local database alias = SAMPLE
  • Enter the following command to select a list of all employees who belong to department 20 in the staff table:

        db2 "select * from staff where dept = 20"
  • Note that you must enter this command using the quotation marks so that your operating system does not confuse the SQL statement with a command. You should receive output that is similar to that shown in Table 1.

  • End the database connection by entering the following command: db2 terminate.

Table 1

Enabling the DB2 Graphical Tools

You must have the prerequisite Java Runtime Environment (JRE) level to use the DB2 Administration Tools. For more information, refer to the Control Center README, which can be found in the INSTHOME/sqllib/cc/prime directory, where INSTHOME is the home directory of the user created for the instance during the installation (for example, /home/db2inst1/sqllib/cc/prime). Let me save you some time and take you through the quickest way I found to get the graphical tools running on your workstation. Perform the following steps:

  • Log on to your workstation as a user with root authority

  • In order to run the graphical tools, you need to be running at least Java 1.1.7 v3 or later. A JRE is available from the Blackdown web site at www.blackdown.org/java-linux/mirrors.html. For this example, I visited the mirror site at: ftp://metalab.unc.edu/pub/linux/devel/lang/java/blackdown.org/JDK-1.1.7/i386/glibc/v3/, downloaded the jre_1.1.7-v3-glibc-x86-native.tar.gz file and placed it in the /tmp directory. For all the latest information on supported JREs and browsers, go to http://www.software.ibm.com/data/db2/.

  • Note that you must download the native threads version of the JRE that you want to use. The DB2 Control Center does not support green threads.

  • Once you have downloaded an appropriate JRE, unpack the file by entering the following command:

  • tar xvfz jre_1.1.7-v3-glibc-x86-native.tar.gz

  • Log on to your workstation as the db2inst1 user.

  • Update your PATH so that your workstation knows the location of the JRE's binary files just installed. Assuming you are following along the example, for Bash or Bourne shells enter this command: export PATH=/tmp/jre117_v3/bin:$PATH; for C shell enter: setenv PATH /tmp/jre117_v7/bin:${PATH}, where /tmp/jre117_v7/bin is the path to the downloaded JRE binary files.

  • Start the JDBC Applet Server by entering the following command: db2jstrt 6790.

  • Start a graphical administration tool. For this example, let's start the Control Center using the command db2cc 6790.

  • The Control Center Sign On window opens. Enter a valid DB2 user that has SYSADM authority on the instance with which you intend to work. For our example, enter the db2inst user ID and the corresponding password. For more information, refer to the “Administration Guide”.

Now, you have completed all the steps necessary to configure your workstation for the DB2 graphical tools.

If you followed the steps and considerations that I have outlined in this article, you should have a running copy of DB2 on your Linux workstation, a sample database, a running Control Center and a smile on your face!

Paul Zikopoulos (paulz_ibm@yahoo.com) is a senior member of the DB2 information and development team, specializing in DB2 installation and configuration issues. He has more than five years experience with the DB2 Universal Database, and has written magazine articles and books about DB2. Paul is an IBM Certified Advanced Technical Expert (DRDA and Cluster/EEE) and an IBM Certified Solutions Expert with DB2 Universal Database.
Load Disqus comments