IBM®
Skip to main content
    Country/region [select]      Terms of use
 
 
      
     Home      Products      Services & solutions      Support & downloads      My account     

developerWorks > Linux >
developerWorks
Speed-start your Linux app: Installing DB2 Version 7.2 and the JRE
Discusse-mail it!
Contents:
Before you begin
Prerequisites
Installing DB2 for Linux
Configuring kernel parameters
Downloading and installing the JRE
Summary
Resources
About the authors
Rate this article
Related content:
Using DB2 and the DB2 Control Center
Speed-start your Linux app -- Overview, training, tech support
Installing prerequisite Linux packages
Installing Red Hat Linux 7.1
Installing Red Hat Linux 7.2
Installing SuSE Linux 7.3
Basic tasks for new Linux developers
vi intro -- the cheat sheet method
Living in Emacs
Subscriptions:
dW newsletters
dW Subscription
(CDs and downloads)
How to install and configure DB2 for Linux and the Java Runtime Environment

Level: Introductory

Kevin Czap (kczap@us.ibm.com), e-business architect, IBM
Ian Shields (ishields@us.ibm.com), Senior programmer, IBM

01 Jul 2002
Updated 18 May 2004

This article guides you through the steps to install DB2 and the IBM Java Runtime Environment (JRE) with minimal fuss and frustration. The article targets developers who are new to Linux or UNIX-based operating systems. Share your questions and views on this article with the author and other readers in the discussion forum by clicking Discuss at the top or bottom of the article.

In this article, we'll cover the following tasks:

  • Querying Linux for installed packages, such as pdksh
  • Using the su command to switch users
  • Using the db2setup command to customize the DB2 installation
  • Configuring the kernel parameters to improve the performance of DB2 for Linux
  • Using the rpm command to install the JRE
  • Using symbolic links in Linux

Before you begin
Note: The instructions in this article are for DB2 Version 7.2. You will find the instructions for Version 8 in our article Installing DB2 Version 8.1

Install Red Hat Linux 7.1, Red Hat Linux 7.2, or SuSE Linux 7.3.

If you're new to Linux and need help with mounting a CD or opening a terminal window, see the Basic tasks for new Linux developers, which covers these tasks and more.

Prerequisites
Open a terminal window. See our Basic tasks for new Linux developers if you need help doing this. Use the which command to check that you have ksh (the Korn shell) and Netscape installed. If you know the package names, you may use the rpm command instead.

Listing 1. Checking for the Korn shell and Netscape

      
[root@echidna root]# which ksh
/bin/ksh
[root@echidna root]# which netscape
/usr/bin/netscape
[root@echidna root]# rpm -q pdksh
pdksh-5.2.14-13
[root@echidna root]# rpm -q netscape-communicator
netscape-communicator-4.78-2

If you do not have the pdksh package installed, please see the article "Installing prerequisite Linux packages" before you install the IBM DB2 trial software.

For a typical installation, use the df command to verify that you have at least 200 MB of free space in the file system containing the /usr directory, and 40 MB in the /home directory. To get a report in MB instead of KB, add the -m option to the df command. If, as in this example, /home and /usr are both mounted on /, then you need to ensure that / contains the total of 240 MB.

Listing 2. Checking for sufficient free space

      
[root@echidna root]# df -m /usr
Filesystem           1M-blocks      Used Available Use% Mounted on
/dev/hda6                 4918      2280      2388  49% /
[root@echidna root]# df -m /opt
Filesystem           1M-blocks      Used Available Use% Mounted on
/dev/hda6                 4918      2280      2388  49% /
[root@echidna root]# df /home
Filesystem           1k-blocks      Used Available Use% Mounted on
/dev/hda6              5036284   2334356   2446096  49% /
[root@echidna root]#

If you plan to download the DB2 code from the "Speed-start your Linux app" downloads page (instead of from the CD), you will need approximately 360 MB of space for the archive (tar) file and a similar amount for the extracted contents.

Installing DB2 for Linux
The examples in these steps refer to a Red Hat Linux 7.2 system with a GNOME desktop. (If you are using a SuSE Linux system, your CD is likely to be mounted at /cdrom instead of /mnt/cdrom.)

If you are new to Linux, please refer to the Basic tasks for new Linux developers for tasks such as mounting a CD-ROM and opening a terminal window.

  1. Do you have CD 1 from the "Speed-start your Linux app (2Q 2002)" CD set in your CD drive and mounted? If yes, skip to step 3. (If you are using another CD set, such as the developerWorks Toolbox Sample CD, browse the index.html file to locate the correct directory for the DB2 code, and proceed with step 3.)

  2. Alternatively, if you don't have the CDs and prefer to download the code from IBM, you can download and extract the code. You will need approximately 360 MB to download the file and another 360 MB to extract it. The file you download will be 040_EE_LNX_NLV.tar. This is a tar, or tape archive, file, which is a common form of packaging sets of files in UNIX and Linux. I keep a directory called /download for my downloaded files, but you can use any free space that you wish. Change into the directory where you downloaded and use the tar command with the -xvf options to extract it. You will see the files being extracted: Listing 3. Extracting the DB2 files
    
              
    [root@echidna root]# cd /download
    [root@echidna download]# ls 040*     
    040_EE_LNX_NLV.tar
    [root@echidna download]# tar -xvf 040_EE_LNX_NLV.tar
    040_EE_LNX_NLV/
    040_EE_LNX_NLV/db2_install
    040_EE_LNX_NLV/db2_deinstall
    040_EE_LNX_NLV/db2setup
    
  3. Open a terminal window. If you are not running as root, use the su command to switch to the root user. Many prompts show a trailing $ sign for non-root users and a trailing # for the root user, and some show the user name as part of the prompt. You can check the current user if you aren't sure by running the whoami command. Listing 4. Using su to switch to the root user
    
              
    [ian@echidna ian]$ whoami
    ian
    [ian@echidna ian]$ su
    Password: 
    [root@echidna ian]#
    
  4. Use the cd command to change to the db72pf5u directory on your CD or to the 040_EE_LNX_NLV that you extracted from the downloaded file. For example: Listing 5. Changing to the db72pf5u directory
    
              
    cd /download/040_EE_LNX_NLV
      or (on a Red Hat Linux system):
    cd /mnt/cdrom/db72pf5u
      or (on a SuSE Linux system):
    cd /cdrom/db72pf5u
    
  5. Start the DB2 setup by entering ./db2setup . Note the leading ./, which you need if you do not have root automatically running programs from the current directory. You should see a screen like this:

    Figure 1. Starting db2setup
    Starting db2setup

    On the db2setup screens, you select or deselect entries by pressing the space bar. Selected entries are shown by an asterisk (*), and your current position is highlighted in reverse video. You navigate around the screen by pressing the Tab key or the up, down, left, or right arrow keys. You select actions such as OK, Cancel, or Help by moving or tabbing to the field and then pressing the Enter key.

  6. We will start by selecting and customizing the DB2 Administration Client. Press the space bar and you should see an asterisk indicating that the DB2 Administration Client is selected. Then press that Tab key once, and the customize... field should be highlighted. Press Enter and you should see a screen like this:

    Figure 2. Customizing the DB2 Administration Client
    Customizing the DB2 Administration Client

  7. Move down and select the Control Center so it has an asterisk (*) beside it. Tab till the OK selection is highlighted, and press Enter. You should return to the screen you left in step 4.

  8. Select DB2 UDB Enterprise Edition and DB2 Application Development Client. You may explore the other customization options, for example, if you would like messages in languages other than English. When you are ready, tab down to the OK selection so your screen looks like this:

    Figure 3. Additional selections for DB2
    Additional selections for DB2

  9. Press Enter. Now select the options to create a DB2 instance. Tab or use the cursor movement keys until Create a DB2 Instance is highlighted, and then press the space bar. This will take you to the first customization screen for the instance. The default instance name is db2inst1, and a system user of the same name will be created. If you do not choose a password, then ibmdb2 will be used as a password. We recommend that you choose your own password. Databases for this instance will be created in the home directory of this user unless you specify another location when you are creating the database. Enter your desired password twice, or accept the default, and then tab to the Properties selection so your screen looks like this:

    Figure 4. Creating a DB2 instance
    Creating a DB2 instance

  10. Press Enter. On the next screen, move down to Create a sample database for DB2 Instance, and press the space bar to select it. This will create a sample database that we can use to explore DB2. Next, tab to the OK selection, and press Enter.

  11. When you return to the DB2 instance creation screen, tab to the OK selection and press Enter. You will now choose a userid and password for the fenced user, where user-defined functions (UDFs) and stored procedures are executed. Again, we recommend you select the default userid and choose your own password. As before, the default password is ibmdb2.

  12. Tab to the OK selection, and press Enter. Accept the default to Set up DB2 Warehouse Control Database. Continue tabbing to OK and pressing Enter until you return to the Create DB2 Services screen, which should now look like this:

    Figure 5. Return to Create DB2 Services
    Return to Create DB2 Services

  13. We recommend that you tab down to Create the Administration Server, and press the space bar to select it. Choose your own password, or accept the default. Continue selecting OK until you return to the Create DB2 Services screen. Select OK and press Enter. You should see a summary screen that will look something like this:

    Figure 6. DB2 setup confirmation
    DB2 setup confirmation

    You will have one more chance to quit before the install begins, and then your install will start. When the install completes, you may press Enter until you leave the db2setup utility.

At this point you have installed DB2 and its Administration Server and created an instance of DB2 along with a sample database. If you need to add things later, you can always rerun db2setup.

Configuring kernel parameters
Systems using a 2.4.x series Linux kernel have a default value for the msgmni (message queue) parameter of 16, which allows only a couple of simultaneous connections to DB2. Furthermore, semaphore array parameters must be changed for DB2 to run successfully.

  1. To check shared memory segment, semaphore array, and message queue limits, issue the ipcs -l command. Your output will look something like this: Listing 6. Displaying kernel parameters
    
            
    [root@dhcppc4 etc]# ipcs -l
    
    ------ Shared Memory Limits --------
    max number of segments = 4096
    max seg size (kbytes) = 32768
    max total shared memory (kbytes) = 8388608
    min seg size (bytes) = 1
    
    ------ Semaphore Limits --------
    max number of arrays = 128
    max semaphores per array = 250
    max semaphores system wide = 32000
    max ops per semop call = 32
    semaphore max value = 32767
    
    ------ Messages: Limits --------
    max queues system wide = 16
    max size of message (bytes) = 8192
    default max size of queue (bytes) = 16384
    
  2. To change the kernel parameters, add the following entries in the default system control configuration file /etc/sysctl.conf: Listing 7. Editing /etc/sysctl.conf
    
              
    kernel.msgmni = 512
    kernel.sem=250  128000  32 512
    

    We'll use the vi command to edit the file with the vi editor. If you already know another editor that you would prefer to use, such as gedit or Emacs, feel free to use that editor instead. We use vi in this task simply to illustrate this editor, which is found on all UNIX and Linux systems. The vi editor is not a graphical editor, although a graphical version (vim) does exist. You use commands to move around and delete or change characters, words, or lines. If you would like to know more about either vi or Emacs, see the tutorials listed in Resources later in this article.

    To edit /etc/sysctl.conf with the vi editor, enter vi /etc/sysctl.conf. Hold the shift key and press g to move to the end of the file. Type o to open a new line for input at the end of the file. Either type the two lines from Listing 7 above into the end of the file in the vi window or copy them.

    Hint: If you have a three-button mouse (or if you have set up your mouse to emulate three buttons by chording both buttons -- that is, holding down both together), you can hold down your left button and drag over text in one window and then use the middle button (or chord both buttons on a 2-button mouse) to paste the highlighted text into the rest of the command. You can use this handy trick within a window or between windows.

    Press the Esc key to leave insert mode. If you make a mistake, type :q! to quit without saving. Otherwise, press and hold Shift while you type zz to save the file.

  3. Run sysctl with the -p parameter to load in the system control settings from the default /etc/sysctl.conf. Listing 8. Activating the kernel parameters
    
              
    [root@dhcppc4 etc]# sysctl -p
    net.ipv4.ip_forward = 0
    net.ipv4.conf.default.rp_filter = 1
    kernel.sysrq = 0
    kernel.msgmni = 512
    kernel.sem = 250  128000  32 512
    [root@dhcppc4 etc]# 
    

    In the future, these entries from the sysctl.conf file will be read during startup by the network initialization script. You only need to run sysctl manually now to have the parameters updated without rebooting. If you wish, you can run the ipcs command with the -l option again to see the changed values.

Downloading and installing the JRE
The Java Runtime Environment (JRE) version 1.1.8, 1.3, or 1.3.1 is required for the DB2 Control Center. In these steps, we'll download and install the 1.3.1 version, and we'll point out differences for other versions as we go.

  1. Open the IBM Developer Kit for Linux: Overview page. We'll open it in a new window so you can refer back to these instructions. Select the Runtime Environment Package, and step through the registration process for the download until you reach the download page. Choose the IBMJava2-JRE-1.3.1-1.0.i386.rpm download. You will need approximately 20 MB of free space for the download. I keep a directory called /download for my downloaded files, but you can use any free space that you wish.

  2. Open a terminal window and change to the directory where you downloaded the RPM file. Use the rpmcommand with the -i option to install the JRE.

    Hint: For a long file name like this that may invite typing errors, use the ls command with a wildcard to list it. If you have a three-button mouse (or if you have set up your mouse to emulate three buttons by chording both buttons -- that is, holding down both together), you can key in the rpm -i part with a trailing space and then use the left button to double-click the name or drag over the name to highlight it and finally use the middle button (or chord both buttons) to paste the highlighted text into the rest of the command. You can use this handy trick within a window or between windows.

    Listing 9. Installing the JRE
    
            
    [root@echidna ian]# cd /download
    [root@echidna download]# ls IBMJ*
    IBMJava2-JRE-1.3.1-1.0.i386.rpm
    [root@echidna download]# rpm -i IBMJava2-JRE-1.3.1-1.0.i386.rpm
    [root@echidna download]#
    
  3. Once the install completes, you have just a few more tasks to do with the 1.3.1 JRE. These are not required for the older 1.1.8 JRE, so if you installed that JRE instead, you can skip down to the Summary. The 1.3.1 JRE does not include a separate jre command, but the DB2 Control Center expects one, so we will make a symbolic link to associate the name jre with the java command. If you are familiar with shortcuts in Windows you might think of this as a shortcut. First we need to change into the directory containing the java command, and then we use the ln command with the -s option to create a link so that the java command will be called whenever a program (or user) asks for the jre command. You can use the ls command with the -l (long) option to list the jre entry and see that it is indeed a link to the java command. The following screen shows these commands:

    Figure 7. Creating a symbolic link
    Symbolic link for jre to java

  4. The db2cc script calls the JRE with the -nojit option, which is not supported by the 1.3.1 JRE. You need to remove this option from the script. The script is installed read-only, so we will show you how to change it to read-write, edit it, and then return it to read-only status:
    1. First change into the /usr/IBMdb2/V7.1/bin directory.
    2. Use the ls command with the -l option to display the permissions of the db2cc command. You will see the read (r) and execute (x) bits set for the user, group, and all permissions.
    3. Use the chmod command with the u+w option to set the permission to allow the owner (root) to write the file.
    4. Use the ls command again to view the new permissions.
  5. Listing 10. Changing file permissions
    
            
    [root@dhcppc4 root]# cd /usr/IBMdb2/V7.1/bin
    [root@dhcppc4 bin]# ls -l db2cc
    -r-xr-xr-x    1 bin      bin          1528 Jan  9 12:19 db2cc
    [root@dhcppc4 bin]# chmod u+w db2cc
    [root@dhcppc4 bin]# ls -l db2cc
    -rwxr-xr-x    1 bin      bin          1528 Jan  9 12:19 db2cc
    [root@dhcppc4 bin]# vi db2cc
    
    Again, you can use vi or another editor. For this exercise, we want to find the -nojit option, which occurs on line 44, and we want to delete that option and save the file. Use the / command in the vi editor to locate -nojit by typing /-nojit and pressing Enter. You should see a block cursor over the - of -nojit as shown in Figure 8. If you now press ctrl-g to display your position, you will see the current line number (44) displayed at the bottom of the screen like this:

    Figure 8. Locating text with the vi editor
    vi locating -nojit

  6. To complete the editing, use the dw (delete word) command to delete the word at the cursor position. Note that only the - sign is deleted as vi considers punctuation when removing words. At this point you can use the dw command again, or use the . (dot or period) command, which repeats the last editing action. Type (Shift+z Shift+z) to save the file, or cancel your edit session by typing (:q!) and try again.

  7. Once you have saved the file, you can use the chmod command with the u-w option to make the file read-only again, and use the ls command as you did above to verify your actions. In fact, since you don't want anyone to be able to write the file, it suffices to use the -w option with chmod, which will turn off all write permissions.

Summary
Congratulations! You installed an instance of DB2 and the DB2 Administration Server. You installed the DB2 Control Center and the DB2 sample database. (To learn how to use DB2 and the Control Center, read the follow-on article, "Using DB2 and the DB2 Control Center".) You learned how to update the Linux kernel parameters to improve DB2 performance. You also installed the IBM Java Runtime Environment. Along the way you used the rpm command and the vi editor. If you have questions about these tasks, you can join the discussion forum by clicking Discuss at the top or bottom of the article. In the forum, you can share your questions and views on this article with the author and other readers.

Resources

About the authors
Kevin Czap is an IBM Certified Solutions Designer and Technologist in Austin, Texas. His areas of interest are Linux, DB2, and Harley-Davidsons (though not necessarily in that order). You can contact Kevin at kczap@us.ibm.com.


Ian Shields is currently researching Linux technology for the developerWorks Linux zone, and is a Senior Programmer at IBM at the Research Triangle Park, NC. He joined IBM in Canberra, Australia, as a systems engineer in 1973, and has since worked on communications systems and pervasive computing in Montreal, Canada, and RTP, NC. He has several patents. His undergraduate degree is in pure mathematics and philosophy from the Australian National University. He received an M.S. in computer science from North Carolina State University, where he is now pursuing a Ph.D. You can contact Ian at ishields@us.ibm.com.



Discusse-mail it!
Rate this article

This content was helpful to me:

Strongly disagree (1)Disagree (2)Neutral (3)Agree (4)Strongly agree (5)

Send us your comments or click Discuss to share your comments with others.



developerWorks > Linux >
developerWorks
  About IBM  |  Privacy  |  Terms of use  |  Contact