Monday, November 7, 2011
Hi ,In this post i am going to explain how to install DB2 9 Express C on UBUNTU using command line interface.

DB2 ON UBUNTU
Assumptions for this article:
a) The steps below were done with db2 Express-C 9.7 and on Ubuntu 9.04 Server edition, but the procedure should apply to other versions within the major versions quite well.
b) The steps below have also been executed on a headless Red Hat Enterprise 5.X (RHEL) server with no problem, so the procedures below will likely work for many other Linux distros as well.
c) This assumes you have root access to the machine, OR where
root
is referred to below, assumes a literally the user root OR a user with root authority through such means as sudo
or other applicable permissions.
d) This assumes you have no previous DB2 installation, or if so, you have already properly removed it
d) This assumes the following usernames for the following DB2 users;
- db2 instance owner =
db2inst1
- db2 fence user =
db2fenc1
- db2 admin owner (das user) =
db2das1
e) This assumes that DB2 will be installed in /opt/ibm/db2/V9.7 (or whatever the version is you are installing. This path will be referred to throughout the rest of this document as
DB2DIR
f) This article only shows configuring a single DB2 instance called
db2inst1
, bound to the instance owner (user) named db2inst1
INSTALLATION
This section is a summary of the steps laid out at this official DB2 install document:
- Login as root
- Go to IBM and download DB2 Express-C
- Save the tarball file in
/tmp/db2expc9
cd /tmp/db2expc9
and extract the tarball with
tar -xvzf the_db29_tarball_filename.tar.gz
cd expc
- Optionally execute
./db2prereqcheck
followed by (required)./db2_install
. Thedb2prereqcheck
simply will check your system requirements and quit, basically doing the same thing thatdb2_install
does at startup, butdb2_install
will continue on to install if the pre requirements are met. (see next bullet). - Now at this point you may get one or more of the following errors or warnings saying something to the effect of
The required library file libaio.so.1 is not found on the system
OR you might get a warning statingCan't use the string to find the version of libstdc++
. The solution to either of these errors/warnings, is to run the following commands:- apt-get install libaio1 (ubuntu)
- apt-get install libstdc++5 (ubuntu)
- yum install libstdc++ (rhel)
- yum install libaio (rhel)
After installing these 2 packages you may STILL get the warning aboutlibstdc++
however just ignore than and run the following forced install with the command./db2_install -f sysreq
. If you still continue to get some sort of error please read the system requirements - Assuming the install command completed successfully (check the output, at the end of the install process you should see
The Execution completed successfully
and review the install log located at/tmp/db2_install.log.XXXX
). You now have the core db2 express c files installed under your DB2DIR which is/opt/ibm/db2/V9.7
… however conveniently DB2 IS NOT READY to run, we still need to do more configuring….
CONFIGURING
Ok, now that you have the core db2 express C files installed under your DB2DIR
/opt/ibm/db2/V9.7
it is time to manually do what a DB2 install program should be doing for you, you now get to act like a bash script and do all the things below manually, have fun…- The steps below are a summary of this DB2 install document. In short we are going to create the required DB2 users, create the DB2 admin server instance, create our single usable DB2 instance, then configure DB2 to talk over TCP/IP (I feel like this is 1995….)
- login as root
- Lets create the our single DB2 instance owner user by executing:
useradd -m db2inst1
- set a good password for this user with:
passwd db2inst1
- Create the db2 fenced user:
useradd -m db2fenc1
- Set a good password for this user with:
passwd db2fenc1
- Create the db2 admin server user:
useradd -m db2das1
- Set a good password for this user with:
passwd db2das1
- Now we have our base users and we now need to create the db2 administration server instance with the command:
DB2DIR/instance/dascrt -u db2das1
. - Ok, now we can create the actual usable db2 instance with the following command:
DB2DIR/instance/db2icrt -a server -u db2fenc1 db2inst1
. - Now that the instance if created lets create some links with:
DB2DIR/cfg/db2ln
- Awesome! We are almost there, but FIRST we must jump into our time machine and go back to the early 1990′s when software was not really pre-configured to use TCP/IP for communications….as is DB2 by default… so lets configure it to talk via TCP/IP on a particular port.
- As root, open up
/etc/services
and add the following line at the end of the filedb2c_db2inst1 3700/tcp # DB2 connection service port
, (NOTE you can change the port to something other than the default if you want, i.e. security reasons) - Now lets logout
- Login as
db2inst1
using the password you set earlier - execute a
db2stop
followed by adb2start
- Execute the following command to configure db2 to use the TCP/IP settings as follows: Bring up the db2 CLP with
db2
. Next type the following command in the CLP prompt:update database manager configuration using svcename db2c_db2inst1
. REMEMBER to adjust the service name and port number accordingly if you used something different in your/etc/services
above. - The output should be “The update database manager command completed successfully”. Execute a
db2stop
followed by adb2start
- Next you can verify that the TCP/IP comm settings took effect by typing (while still in the db2 clp prompt):
get database manager config
, in the resulting output you should see the “TCP/IP Service name” which matches the service name in your/etc/services
file. - Exit the db2 CLP prompt by typing
quit
- Now lets fire up the actual TCP/IP communication by entering the following command:
db2set DB2COMM=tcpip
, followed by adb2stop
followed by adb2start
- Verify that DB2 is listening on your port by typing
netstat -na
and look for your port listed in the output. - Yeah! DB2 is now running on this box and you are good to go to begin creating databases etc. Remember to adjust your iptables firewall rules accordingly per your requirements to restrict access to only the hosts you want to permit.
VERIFY
Hey, lets create a basic database and verify we can use it to see that DB2 works.
- Login as db2inst1, the db2 instance owner
- execute a
db2 create database bitsoi
- Connect with
db2 connect to bitsoi user db2inst1
- Enter the password
- You are now connected if you seee the “database connection information” output
- Fire up the CLP with
db2
- At the prompt type
create table myTest (name varchar(10))
- If successful, insert a record with
insert into myTest (name) values ('bitsofinfo')
- Select it with
select * from myTest
- Yeah, it works, exit with a
quit
and when back at the command line typedb2 terminate
UNINSTALLING
So you are probably thinking, “hey, how about we just run that db2_deinstall command?” Wrongo buddy, that would be way too obvious and easy. Instead we need to follow the steps below.
- The steps below are a summary of the official document located here.
- Optionally backup, then DROP all of your databases, this is your call.. and at your own risk….
- Login as the db2 admin server owner, in our example case this is
db2das1
and stop the db2 admin server by executing adb2admin stop
command. - when completed logout
- login as root
- execute
DB2DIR/instance/dasdrop
to drop the das server instance - logout and login as the db2 instance owner
db2inst1
- execute a
db2stop force
- execute a
db2 terminate
- logout and login as root
- execute
DB2DIR/instance/db2idrop db2inst1
to drop the our db2 instance - Finally… now we get to actually run the deinstaller, as root execute
DB2DIR/install/db2_deinstall -a
DB2 should now be completely removed, except for your users
db2inst1, db2fence1 and db2dasusr1
. You can optionally remove those by doing auserdel USERNAME
from the command line as root for each user as well as remembering to cleanup their home directories.
SUMMARY
I hope this document helped you out. DB2 is a great product and don’t let lack of thousands of user blog posts/articles/howtos etc. on the web scare you away from it. Please send any comments to improve this HOW TO my way.

Installing DB2 9 Express C on UBUNTU!
Subscribe to:
Post Comments (Atom)
Currently have 0 comments: