 | Level: Introductory Ian Shields (ishields@us.ibm.com), Senior programmer, IBM
04 Jan 2003 This article guides you through the steps to install DB2 8.1 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 for this 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
See DB2 for Linux for information on supported Linux distributions. Kernel levels of 2.4.18 or better are recommended. A Red Hat 7.3 installation with the GNOME desktop was used for the examples shown here.
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. First, use the uname command with the -r option to verify the kernel level. Then, use the which command to check whether ksh (the Korn shell) and Netscape are installed. If you know the package names, you may use the rpm command instead.
Listing 1. Checking for the Korn shell and Netscape
[root@attic root]# uname -r
2.4.18-3
[root@attic root]# which ksh
/bin/ksh
[root@attic root]# which netscape
/usr/bin/netscape
[root@attic root]# rpm -q pdksh
pdksh-5.2.14-16
[root@attic root]# rpm -q netscape-communicator
netscape-communicator-4.79-1
[root@attic root]#
|
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.
Unpack files
Disk sizes are usually measured in megabytes using powers of 1,000, rather than 1,024 as used for many other computer measurements. All sizes here refer to powers of 1,000, so a megabyte is 1,000,000 bytes not 1,048,576 bytes. You will need approximately 520 MB of temporary for the unpacked files from the CD. If you download the DB2 Enterprise Sever Edition for Linux (32 Bit): version tar file ( DB2_V81_ESE_LNX_32_NLV.tar) you will need a further 508MB for the download. The downloaded file can be deleted as soon as yuou have unpacked it, and the unpacked files can be deleted when you have installed everything you want.
Our example will create a temporary directory called db281 in the home directory of the root user. You may use another location if you wish.
Log in as root and open a terminal window.
Use the df command to verify that you have at least 520 MB of free
space in the file system containing the /root directory. If you are downloading to the same location make sure that you have at least 1030MB free.
Note that ~ (tilde) refers to the home directory of the current user, so you can use either ~ or /root as an argument for the df command.
To get a report in human readable form using multiples of 1,000 rather than number of disk blocks using multiples of 1024, add the -H option.
Listing 2. Checking for sufficient free space
[root@attic ss3db2]# df -H ~
Filesystem Size Used Avail Use% Mounted on
/dev/hdb5 4.6G 2.6G 1.8G 59% /
[root@attic ss3db2]# df -H /root
Filesystem Size Used Avail Use% Mounted on
/dev/hdb5 4.6G 2.6G 1.8G 59% /
[root@attic ss3db2]#
|
For a typical installation, you will need at least 500 MB of free space in the /opt file system and at least 50 MB of space in the /home file system. In addition you will need space for your databases.
Log in as root and open a terminal window. Use the cd command with no arguments to change to root's home directory. Then create a temporary directory called db281 and change into this directory.
Listing 3. Creating a temporary directory
[root@attic root]# cd
[root@attic root]# mkdir db281
[root@attic root]# cd db281
[root@attic db281]#
|
Mount disk 2 from the Speed Start your Linux app 1Q 2003 CD set.
The examples in these steps refer to a Red Hat Linux 7.3 system with a GNOME desktop.
(If you are using a SuSE Linux system, your CD is likely to be mounted at /media/cdrom or /cdrom instead of /mnt/cdrom.).
Use your browser to open the index.html file on the root of the CD (/mnt/cdrom/index.html in our example) and review the license terms. If your system has automount enabled this may be opened for you. Next, locate the d81eeuxe.tar.gz in the d81eeuxe and use the tar command with the -zxvf options to uncompress and unpack it. If you donwloaded the DB2_V81_ESE_LNX_32_NLV.tar you only need the -xvf options as this file is not compressed.
Listing 4. Unpacking the installation code
root@attic db281]# ls /mnt/cdrom
autopp.ini autorun.exe d81eeuxe ids51uxi template.css
autorun autorun.inf devcon index.html
[root@attic db281]# ls /mnt/cdrom/d81eeuxe
d81eeuxe.tar.gz
[root@attic db281]# tar -zxvf /mnt/cdrom/d81eeuxe/d81eeuxe.tar.gz
./
./db2_deinstall
./db2_install
./db2setup
.
.
.
./doc.cmn/db2qt/images/statubgd.jpg
./doc.cmn/db2qt/images/tab_separator.gif
[root@attic db281]#
|
Installing DB2 for Linux
Log in as root. You will need a graphical environment, so if you use the su command to switch to the root user make usre your display is set up properly.
If you are new to Linux, please refer to the Basic tasks for new Linux developers for tasks such as switching users, setting up your display, mounting a CD-ROM and opening a terminal window.
- Open a terminal window. 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 5. Using su to switch to the root user
[ian@echidna ian]$ whoami
ian
[ian@echidna ian]$ su
Password:
[root@echidna ian]#
|
- If you just unpacked the DB2 installation code you should still be in the temporary directory (/root/db281) that we created for unpacking. If not, use the
cd command to change to it now.
- If you are using a multiprocessor system and your kernel is greater than 2.4.10 you will need to comment out two lines in an installation script. Using the
vi editor or another editor of your choice, edit the file ./db2/linux/install/db2setup and comment out the two lines that set the LD_ASSUME_KERNEL environment variable so they look like this:
Listing 6. Update for multiprocessor systems
# LD_assume_kernel=2.2.5
# export LD_ASSUME_KERNEL
|
Note that this is not required if you have a single processor system.
- Start the DB2 setup by entering
./db2setup. For security reasons, you should not have root automatically running programs from the current directory so you should need the leading ./. You should see a screen like this:
Figure 1. Starting db2setup
You may browse the installation notes or take a quick tour if you wish. Note that if you run Netscape 4.79, the quick tour launcher may pop up a window indicating that the quick tour cannot run. If you click the link to run it anyway, you can cut and paste the resulting URL from Netscape 4.79 into a supported browser such as mozilla. When you are ready, click on Install products. to start the installation.
- We will start by selecting the DB2 Enterprise Server. Make sure this item is selected and click Next.
Figure 2. Choosing DB2 Enterprise Server installation
- You will see an installation wizard introductory screen. Click Next. Review and accept the license. Click Next again. Select the installation type. We will choose Typical. You may add Data warehousing if you wish. You may click the View features button to view the features that will be installed but if you need to change them you should do a Custom installation. When you are ready, click Next.
Figure 3. Select the installation type
-
For this exercise we will not set up a partitioned database, so there is no need to save the responses in a response file. Click Next on the installation action screen and move on to the DAS user screen. If you have had previous versions of DB2 installed this may appear somewhat differently.
Figure 4. Setting up the DB2 Administrative server userid
- 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 5. Creating a DB2 instance
- Click Next. Accept the choice for a single partition instance on the next screen and then specify the passwords for the instance owner and fenced user for this instance. User defined functions will run under the id of the fenced user and, for security reasons, this id should not be the same as that of the instance owner.
- If this is your first DB2 database, we suggest that you do create a tools catalog.
Figure 6. Creating a DB2 tools catalog
Click Next and accept the defaults to have the tools catalog created in your new instance.
- Next you will get a chance to specify a userid for notification. If you do not currently have an SMTP server running, you may still set up the contact list, but disable the checkbox for Enable notification.
Figure 7. Specifying a contact list
- Next you can accept or change the defaults for an id to receive health notifications in the event of database health thresholds being breached. After you finish with the helth monitor selection you shoudl see a summary of your choices. Review these and click Finish to start copying files and setting up your system.
Figure 8. Start copying files
- When the installation has ocmpleted you should see a post install summary.
Figure 9. Post install summary
At this point you have installed DB2 and its Administration Server and created an instance of DB2. 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. Note that if you previously updated these parameters for DB2 V7.2, the new values are different.
- To check shared memory segment, semaphore array, and message queue limits, issue the
ipcs -l command. Your output will look something like this:
Listing 7. Displaying kernel parameters
[root@attic root]# ipcs -l
------ Shared Memory Limits --------
max number of segments = 4096
max seg size (kbytes) = 262144
max total shared memory (kbytes) = 8388608
min seg size (bytes) = 1
------ Semaphore Limits --------
max number of arrays = 1024
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 = 1024
max size of message (bytes) = 8192
default max size of queue (bytes) = 16384
|
- To change the kernel parameters, add the following entries in the default system control configuration file /etc/sysctl.conf:
Listing 8. Editing /etc/sysctl.conf
kernel.msgmni = 512
kernel.sem=250 128000 32 1024
|
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 10 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.
- Run
sysctl with the -p parameter to load
in the system control settings from the default /etc/sysctl.conf.
Listing 9. Activating the kernel parameters
[root@attic root]# sysctl -p
net.ipv4.ip_forward = 0
net.ipv4.conf.default.rp_filter = 1
kernel.sysrq = 0
kernel.core_uses_pid = 1
kernel.msgmni = 512
kernel.sem = 250 128000 32 1024
[root@attic root]#
|
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.
 |
Installing the JRE
DB2 V8.1 requires a Jave runtime environment. If the installation wizard does not find one, it will install the 1.3.1 version in /opt/IBMJava2-131 for you. It is not necessary to separately install Java.
Summary
Congratulations! You have now installed DB2 and the administrative tools. To learn how to use DB2, create a sample database and use the graphical tools watch for our article in late January.
You learned how to update the Linux kernel parameters to improve DB2 performance.
Along the way you used 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
- Continue to the follow-on article, "Using DB2 and the DB2 Control Center".
- For help installing the pdksh package, refer to "Installing prerequisite Linux packages".
- For complete Linux installation instructions, choose the article that matches your system: "Tips for installing Red
Hat Linux 7.2", or "Tips for installing SuSE Linux 7.3", or "Installing and configuring SuSE Linux Enterprise Server (SLES) 8".
- For help in doing tasks in Linux, review the "Basic tasks for new Linux developers".
- To learn how to use the vi editor to edit in Linux, take the tutorial "vi intro -- the cheat sheet method" (developerWorks, December 2000).
- To develop your proficiency in using the Emacs editor to edit in Linux, take the "Living in Emacs" tutorial (developerWorks, July 2002).
- To learn more about DB2, visit the DB2 developer domain. You'll find technical documentation, how-to articles, education, downloads, product information, and more.
- Python is a great tool to use with DB2 Version 8. It combines the ability to quickly and simply access a DB2 database with the power to perform more complex tasks that require a general-purpose programming language. Learn about the Python DB2 module in the tutorial "Python and DB2 for Linux".
- Get help preparing for the DB2 Version 8 Family Fundamentals (Exam 700) certification exam. In the series of six tutorials, you'll get a solid base for each section of the exam. In addition, visit the certification Web site for more information about the exam.
- JDBC and SQLJ are used to access databases in your Java programs. The tutorial "Optimal DB2 performance with SQLJ and JDBC" introduces SQLJ and JDBC and covers some of the ways to take advantage of the features of SQLJ when accessing DB2 to achieve the best overall performance in your Java programs.
- Return to Speed-start your Linux app for additional training and tech support resources.
- Find more Linux articles in the developerWorks Linux zone.
About the author  | 
|  | 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. |
Rate this page
|  |