IBM's Universal Database

Getting DB2 up and running on Linux.
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


White Paper
Linux Management with Red Hat Satellite: Measuring Business Impact and ROI

Linux has become a key foundation for supporting today's rapidly growing IT environments. Linux is being used to deploy business applications and databases, trading on its reputation as a low-cost operating environment. For many IT organizations, Linux is a mainstay for deploying Web servers and has evolved from handling basic file, print, and utility workloads to running mission-critical applications and databases, physically, virtually, and in the cloud. As Linux grows in importance in terms of value to the business, managing Linux environments to high standards of service quality — availability, security, and performance — becomes an essential requirement for business success.

Learn More

Sponsored by Red Hat

White Paper
Private PaaS for the Agile Enterprise

If you already use virtualized infrastructure, you are well on your way to leveraging the power of the cloud. Virtualization offers the promise of limitless resources, but how do you manage that scalability when your DevOps team doesn’t scale? In today’s hypercompetitive markets, fast results can make a difference between leading the pack vs. obsolescence. Organizations need more benefits from cloud computing than just raw resources. They need agility, flexibility, convenience, ROI, and control.

Stackato private Platform-as-a-Service technology from ActiveState extends your private cloud infrastructure by creating a private PaaS to provide on-demand availability, flexibility, control, and ultimately, faster time-to-market for your enterprise.

Learn More

Sponsored by ActiveState