 | Level: Intermediate Venkata Nagalla (nagalla@us.ibm.com), e-business architect, IBM Kevin Czap (kczap@us.ibm.com), e-business architect, IBM
03 Nov 2003 This article shows how to install DB2 Version 8.1 for Linux on iSeries and pSeries. We'll also perform basic administration tasks for a functional DB2 environment, such as Control Center setup, preparation for database creation, and database creation. For questions, comments, or help, visit our tech support discussion forum.
Before you begin
This article shows how to install DB2 for Linux on both iSeries and pSeries machines. In fact, we will alternate between between the two platforms within this article. The DB2 installation is identical with a few exceptions. The first exception is that on iSeries, Linux must be run in a logical partition. So, for Linux on iSeries, you'll need to install and configure Linux by following the steps in "Install Linux on iSeries". When installing Linux on iSeries, you must use a remote connection via Virtual Network Computing (VNC).
Installing DB2 for Linux on pSeries offers two choices. If the pSeries machine does not contain a graphics adaptor capable of supporting 800 x 600 resolution, you can install via Virtual Network Computing (VNC). If the pSeries box does contain a graphics adaptor capable of supporting 800 x 600 resolution, you can install via a local install. To install and configure Linux on pSeries, follow the steps in "Install Linux on pSeries".
In this article, we'll access Linux via VNC. Keep in mind that, if doing a local install on pSeries, you will launch xWindows and bring up an xTerm window. To start the VNC client, vncviewer, from the client, provide the host address: display #. Here we use the IP address of 100.66.194.21 as the host address and 1 for display as shown in Figure 1. Next, log on as root by providing the password as shown in Figure 2.
Figure 1. VNC client vncviewer logon
Figure 2. VNC client vncviewer password
You should see a remote desktop as shown in Figure 3.
Figure 3. Root's X desktop
Install DB2 for Linux on iSeries and pSeries
To use the DB2 Setup, you can install a single partition database using the
DB2 Setup wizard or a response file. We'll install a single partition
database using the DB2 Setup wizard, which installs the
most common DB2 components except for Application Development and Business Intelligence
tools.
Unpack the files
Create a temporary directory called db281 and change into this directory. Download or copy the DB2 Enterprise Server Edition for Linux tar file (DB2_V81_ESE_LNX-32_NLV.tar) from the Linux on Power Architecture developer's corner into the db281 directory, and use the tar command with the -xvf option to unpack it.
Listing 1. Unpacking the DB2 for Linux tar file
SLES8BAS:/mkdir db281
SLES8BAS:/cd db281
SLES8BAS:/db281 # tar -xvf DB2_V81_ESE_LNX-32_NLV.tar
|
When the tar command is done, issue the ls command, and you should see a file structure similar to Figure 4:
Figure 4. File structure of unpacked files
Install DB2
- Start the DB2 Setup by entering
./db2setup. For security reasons, you should not have root automatically running programs from the current directory, so you
need the leading ./. You should see a screen like Figure 5.
Figure 5. Starting DB2 Setup
- When you are ready, click Install Products to start the installation.
Figure 6. Starting Install Products
- Select the DB2 Enterprise Server Edition. Click Next.
Figure 7. Choosing DB2 UDB Enterprise Server Edition
- You will see an installation wizard introductory screen. Click Next.
Figure 8. Data Management Software
Figure 9. Welcome to the DB2 Setup wizard
- Review and Accept the license. Click Next again.
Figure 10. Software Licence Agreement
- Select the installation type. Choose Typical. 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 11. Select the installation type
- For this exercise, you 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.
Figure 12. Response file option
- Set user information for the Database Administration Server (DAS). This
user administers the Database Administration Server. Type the password and click Next
on the DAS user screen.
Figure 13. DAS user
- Select Create a DB2 instance and click Next on the Instance setup
screen.
Figure 14. Instance setup
- Select Single-partition instance and click Next on the Instance use screen.
Figure 15. Instance use
- DB2 Setup creates a new user, db2inst1, in group db2grp1. You may change user
and group names, or configure an existing user to the new DB2 V8 instance
by selecting the Existing user option. Note that the default home directory is
/home. We recommend that you change the instance home directory to a
DB2-specific directory, such as /db2home.
Select New user, take the defaults, and type the password.
Click Next on the Instance owner screen.
Figure 16. Instance owner
- The Fenced user is responsible for executing fenced user-defined functions,
such as UDFs and stored procedures. Once again, please note the home directory location.
Select New user, take the defaults, and type the password.
Click Next on the Fenced user screen.
Figure 17. Fenced user
- The DB2 tools catalog lets you use the Task Center or scheduler. This creates
a database on your local machine that stores task metadata. The scheduler will not
work without this repository. You may also create a DB2 tools catalog after
installation, but it's much easier to let
DB2 Setup create it for you now.
Select Use a local database and click Next on the Tools catalog screen.
Figure 18. Tools catalog
- Specify the instance, database, and schema in which to store the tools
catalog. By default, a newly created tools catalog will be placed in the
instance owner's home directory.
Take the defaults and click Next.
Figure 19. Specify a local database to store the tools catalog
- The administration contact list stores administrator contact information and
is used for notifying administrators when a database requires attention. You may create a new
contact list that is stored locally, or use an existing global contact list that
resides on a remote DB2 server. If you check the Enable notification box,
your system will search for an available SMTP server and set it to be used for
e-mail notifications.
Take the default Local- Create a contact list on this system and click Next on
the Contact list screen.
Figure 20. Contact list
- By default, a health monitor runs on the DB2 instance. The DB2 health
monitor will send a notification e-mail to the person listed at the specified mail
address when a health indicator threshold is passed. If you check "Address is for a pager", the notification message will be sent to the contact's pager.
Take the default New contact and click Next.
Figure 21. Specify contact for health monitor notification
- Figure 22 summarizes your installation and configuration
settings. Scroll through this window to verify that settings
are correct, and then click Finish.
Figure 22. Installation summary window
- Figure 23 shows the overall progress of DB2 installation.
Figure 23. Copying files status
- Figure 24 shows the post-install steps of DB2 installation.
Figure 24. Post install steps
- Figure 25 shows the status report of DB2 installation. Click Finish.
Figure 25. Status report
Note: Install logs are located in /tmp/db2setup.log, /tmp/db2setup.his, and
/tmp/db2setup.err.
Check and configure the kernel parameters
Some Linux distributions using the 2.4.x series kernel have default value for the msgmni (message queue) parameter, which allows only a couple of simultaneous connections to DB2. You'll need to increase their values if they are too small. Check the message queue limits with the following command:
SLES8BAS:/db281 # ipcs -l
You should see the following:
Listing 2. Checking message queue limits
------ Shared Memory Limits --------
max number of segments = 4096
max seg size (kbytes) = 1048576
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 = 256000
max ops per semop call = 32
semaphore max value = 32767
------ Messages: Limits --------
max queues system wide = 128
max size of message (bytes) = 8192
default max size of queue (bytes) = 16384
|
Modifying 2.4x series kernel parameters
To change the kernel parameters, add the configuration entries to a new system control configuration file by creating a file called sysctl.conf in the /etc directory:
- Type
vi /etc/sysctl.conf
- Enter i for insert mode.
- Type
kernel.msgmni = 1024 and press Enter.
- Press the Esc key to return to the command mode.
- Enter
:wq to write changes to the current file and quit the edit session.
Run sysctl with the -p parameter to load in the sysctl settings from the default file /etc/sysctl.conf:
SLES8BAS:/db281 # sysctl -p
Xhost, switching users, and setting the display variable
The xhost + command allows another user on the localhost to create a new window on the display. We'll use this command for another user such as db2inst1 (the user created during the DB2 install).
- Open an Xterm window and type
xhost +.
- Issue the Substitute User command to switch to the user db2inst1, and use the
- option to invoke the users login shell script: su - db2inst1.
The display variable for db2inst1 now needs to be set. To set the X Window environmental variables to specify the display for the new db2inst1 user, enter:
DISPLAY=:1
export DISPLAY
Create a sample database
Now we'll create a DB2 sample database.
- Change to the sqllib/bin directory (under the db2inst1 home directory), and start the DB2 First Steps:
cd sqllib/bin
./db2fs
- On IBM DB2 First Steps, click Create Sample Database:
Figure 26. First Steps
- On First Steps - Create Sample Databases, select DB2 UDB sample, and click OK:
Figure 27. Create Sample Database
- When the sample database creation is completed, click OK:
Figure 28. Completed Sample Database
- On IBM DB2 First Steps, click Exit First Steps.
Verify the installation and work with a sample database
Now we'll verify the installation of DB2 and use the DB2 Command Line Processor to work with a sample database.
- At an Xterm window, switch to the db2inst1 user by issuing
su - db2inst1, and check the DB2 version level by issuing db2level:
SLES8BAS:/># su - db2inst1
db2inst1@SLES8BAS:/># db2level
You should see the following:
Figure 29. DB2 level
- Start the DB2 Command Line Processor by typing
db2.
- List the database directory to see what databases are present by typing
list database directory, and then connect to the sample database by typing connect to sample:
Figure 30. List databases
- List the database tables in the sample database by typing
list tables:
Figure 31. List tables
- Select (and display) all of the members of the employee table by typing
select * from employee:
Figure 32. Employee Table
- Display all of the members of the department table who are in dept E21 by typing
select * from department where deptno='E21':
Figure 33. Work Department E21
- Display all of the members of the employee table who are in workdept E21 by typing
select * from employee where workdept='E21', and then quit the DB2 Command Line Processor by typing quit.
Figure 34. Employees in Work Department E21
 |
Administering DB2 for Linux on iSeries and pSeries
The administration tasks for a functional DB2
environment include Control Center setup, preparation for database creation,
and database creation. The DB2 Control Center is a Java-based graphical tool that helps you
administer your DB2 instances and databases. We'll launch this tool, review Linux-specific settings for a single database partition, and create a database using the database wizard.
Setting up the Control Center
DB2 Universal Database has a rich set of graphical tools that help database
administrators manage the database system and help application developers
develop stored procedures and user-defined functions. The Control Center is a
general administration tool that you can use as you explore and administer
your databases.
If you want to administer your database server with the Control Center, you must
start the DB2 Administrator Server on each host of your database server
environment. To start the DB2 Administrator Server, log
on to every host as DAS user and issue db2admin start.
Before we start the Control Center, we need to switch to the DB2
instance owner ID and set up the display as follows:
Figure 35. Control Center setup
The ampersand sign after the command returns the shell prompt, which allows you to use
this shell for other commands.
Note: If you get a Java error, verify that you have installed and are using the
correct JDK Version, which is Java 2 Runtime Environment, Standard
Edition 1.3.1, and verify that the path setting is correct.
Figure 36. JDK Version
Preparing to create databases
In order to access DB2, each Linux user must set up the Linux
environment. During creation of an instance, DB2 creates a subdirectory named
sqllib in the instance home directory, $INSTHOME. In this directory, there are
important files such as db2nodes.cfg, db2profile, and userprofile. These files are
used to set up the DB2 environment. To set up a user environment to use DB2
every time the user logs on to the Linux system, add the following command to
the user profile under the user's home directory, $INSTHOME/.profile:
.$INSTHOME/sqllib/db2profile
Creating databases
Create a database using the Create Database Wizard. The DB2 instance was created during DB2 installation. Start the Create Database Wizard from the
Control Center, as shown in Figure 37.
Figure 37. Create Database Wizard in Control Center
- Expand the object tree until you find the Databases folder.
- Right-click the Databases folder and select Create Database Using
Wizard from the pop-up menu. See Figure 37.
- Figure 38 shows you the Create Database Wizard window where you name the database and database directory. All files related to the database will
be stored under this directory path; for example, for the first database in this
instance is:
/database/$DB2INSTANCE/NODE0000/SQL00001/
After a database is created, issue the following command to see which
directory the database is stored in:
db2 list database directory on /database
Figure 38. Start window of Create Database Wizard
- In the window shown in Figure 39, you decide where DB2 should store the default
tablespace, userpace1, and what type it should be. SMS (System Managed
Storage) means that the tablespace container is a directory in the given path and
that all data will be stored as files. DMS (Data Managed Storage) means that the
tablespace container is a pre-allocated file that is controlled by DB2.
Figure 39. Tablespace container definition
- In the next two windows (Figures 40 and 41), you decide where the catalog tablespace,
syscatspace, and the temporary tablespace, tempspace1, will be located. We
recommend that you allocate tempspace1 in a different file system.
Figure 40. Storage of system catalog tables management
Figure 41. Storage of system temporary tables management
- In Figure 42, you decide how DB2 should read and write data. We recommend
that you choose for Prefetch size a multiple of Extent size to allow DB2 to read
data from the disk before it is needed (prefetching). Every time DB2 needs data from
your table, it starts an I/O request. Such a request asks for an extent from disk. If
you allow DB2 to get more data at once, then you will reduce I/O wait time.
Figure 42. Tune the performance of this database
- After finishing all preview windows, select the Show Command, and the wizard
presents a window (Figure 43) with the created database command and all the
settings you specified.
Figure 43. Verify generated SQL
-
When you click Finish, DB2 creates
the database for you. A successful database creation confirmation message
is presented, as shown in Figure 44.
Figure 44. Confirmation of created database
- To configure the database you just created, click Yes, and the
Configuration Advisor will start, as shown in Figure 45.
With the Configuration Advisor, you can tune the database
without a strong knowledge of DB2. Simply provide the advisor with the
requested information about your system, such as planned workload and
connection information, and the wizard will give you a recommendation
of what changes are needed.
The database also can be configured through the Control Center under Tools > Wizards.
Figure 45. Configuration Advisor
-
At the end, you have a choice to apply the change immediately or to save the SQL to run
later, as shown in Figure 46. Any parameter can require a reactivation of the database.
Figure 46. Configuration Advisor Task creation summary
-
By default, DB2 sets the log path to:
$DBPATH/$INSTANCE/NODE0000/SQL0001/SQLOGDIR
To improve performance and avoid I/O contention, change this log
path to a different file system on different disks. To change the log path, open the
Control Center and drill down to the database. Right-click and select Configure
Database Logging as shown in Figure 47.
Figure 47. Configuring DB2 Logging
- Functions for administering databases, such as database backup and recovery, and data movement via EXPORT, IMPORT and LOAD are shown in Figure 48 and Figure 49.
Figure 48. DB2 database backup and recovery
Figure 49. Data movement via EXPORT, IMPORT, and LOAD
Resources - To install SuSE Linux Enterprise Server (SLES) 8, see the instructions in "Install Linux on iSeries" (developerWorks, August 2003) or "Install Linux on pSeries" (developerWorks, July 2003).
- At the SuSE Web site, you can find more information on SuSE Enterprise Server 8 for IBM iSeries/pSeries.
- To install WebSphere Application Server V5.0.2, see the instructions in "Installing and using WebSphere Application Server V5.0 for Linux on iSeries and pSeries" (developerWorks, October 2003).
- For questions, comments, or help, visit our tech support discussion forum.
- For additional developer resources, visit the Linux for iSeries home page, the Linux for pSeries home page, the DB2 Developer Domain, and WebSphere Developer Domain.
- For more information, read the IBM Redbook "Up and Running with DB2 for Linux" (SG24-6899-00, February 2003).
- Find more resources for building Linux apps in Speed-start your Linux app 2003.
- Find more resources for Linux developers in the developerWorks Linux zone.
- Learn more about IBM Software for Linux.
About the authors  | 
|  | Venkata Nagalla is a Senior e-business Architect for IBM's Developer Relations Technical Consulting in Austin, Texas. Venkata works with IBM's business partners -- from startups to large firms -- helping to excite, evangelize, educate, and enable them on IBM's e-business platform. Venkata has 19 years of experience in the software engineering field with IBM. His areas of expertise include object-oriented design and development and, most recently, IBM WebSphere Business Components. You can contact Venkata at nagalla@us.ibm.com. |
 | |  | Kevin Czap is a Senior e-business Architect and IBM Certified Solutions Designer and Technologist in Austin, Texas. His areas of interest are Linux, DB2, and Harley-Davidsons. You can contact Kevin at kczap@us.ibm.com |
Rate this page
|  |