Installing DB2 9.1 on Ubuntu Dapper (6.06)
DB2 is one of the few industrial strength, fully featured database systems that has a community edition available for free use. It supports stored-procedures, and all the standard MySQL-esque features, in addition to triggers and all sorts of data partitioning. And it even ships with a full set of administrative GUI tools. Unfortunately, nobody has taken the time to document the process of getting DB2 installed on Ubuntu Dapper (6.06 LTS). This is my attempt to do so and save others some of the confusion that I went though getting it to work.
If you’re feeling adventurous, you can read the official DB2 9.1 documentation and the many, many DB2 Manuals available on IBMs site.
Getting DB2
There are a number of verions of DB2 available from IBM. Unless you have usage requirements that demand advanced data replication, partitioning, and clusteriing, the freely distributed Express-C community version of DB2 should suffice. The only notable limitation imposed by this version is a 2CPU/4GB Ram hardware constraint on the physical host on which the software is installed. More information on the varying DB2 versions, their features, and their constraints can be found on the official IBM DB2 page. You can get DB2 Express-C at the IBM downloads page.
Installing DB2
The DB2 installation package is rpm-based, so we’ll need to install an rpm-compatible installer for Ubuntu. For this, we apt-get alien, an rpm package installer:
$ sudo apt-get install alien
Now we may db2_install installation script that is bundled with DB2. This needs to be done as root:
$ tar xzvf db2exc_91_LNX_x86.tar.gz
$ sudo exp/disk1/db2_install
This should take a few minutes to install. At the time of this writing, the installation procedure had approximately ten steps and lasted about three to five minutes. Note that depending on the version of gcc that you have installed (if at all), you may need to install libstdc++5, as it is required for successful installation. This is easily obtained:
$ sudo apt-get install libstdc++5
Setting Up Groups/Users
Now that we have DB2 installed, we need to configure it for use. We start by creating the standard DB2 user groups: instance owners, fenced users, and administrators. (Note that these commands need to be run as root — the sudo is dropped here for notational simplicity and a # is added in its place for clarity).
# groupadd -g 999 db2iadm1
# groupadd -g 998 db2fadm1
# groupadd -g 997 dasadm1
Now we’ll create a default user for each group:
# useradd -u 1002 -g dasadm1 -m -d /home/dasusr1 dasusr1 -p password2
# useradd -u 1003 -g db2fadm1 -m -d /home/db2fenc1 db2fenc1 -p password3
# useradd -u 1004 -g db2iadm1 -m -d /home/db2inst1 db2inst1 -p password4
Creating the Adminstrative Database
Now we need to create a DB2 Administration Server to administer all instances of DB2 under the purview of this installation:
# /opt/ibm/db2/V9.1/instance/dascrt -u dasusr1
Note here that dasusr1 may be any user that is a member of the dasadm1 group we set up earlier.
DB2 Instance Semantics. Creating an Instance.
A DB2 instance is an environment that acts as a logical container for a collection of databases. It’s an abstraction that allows the creation and usage of multiple independent DB2 environments using the same physical resources.
We need an instance to hold all of our databases. We’l create a default instance using the db2inst1 user we just created as its owner:
# /opt/ibm/db2/V9.1/instance/db2icrt -u db2fenc1 db2inst1
As we noted, db2inst1 is the instance owner, while db2fenc1 credentials are used to execute fenced stored procedures and executables.
Starting and Stopping an Instance
A DB2 instance is an environment that acts as a logical container for a collection of In order to start and stop the DB2 instance (remember, we may have multiple instances for a given installation on a physical host), we log in as the owner and call db2start after inializing the DB2 environment:
$ su db2inst1
$. ~/sqllib/db2profile
$db2start
Stopping the environment is just as simple: we’d call db2stop instead of db2start.
You may enable (or disable) automatic DB2 instance start/stop on system start-up/shut-down by calling:
$ db2iauto -on db2inst1
where db2inst1 is the login name of the instance. Replacing the -on flag with -off disables this feature.
The Sample Database
If you wish to build the sample database bundled with DB2 in order to play around, call db2sampl while logged into a DB2 instance owner account:
$ su db2inst1
$ . ~/sqllib/db2profile
$ db2sampl
That’s It.
This concludes the bare-minimum needed to set up a working DB2 environment on Ubuntu. Note that this configuration does not allow for external connections over TCP/IP. We’d need to start a separate service
References
[1] Official DB2 9.1 documentation
[2] DB2 Manuals
Posting your comment
I.D.E.A.中文站 · Ubuntu下的….. | January 9, 2007 @ 10:30 am
[…] Ubuntu 6.06LTS下安装DB2 UDB V9.1 http://project-tigershark.com/people/rob/blog/2007/01/02/installing-db2-91-on-ubuntu-dapper-606 […]
Gunnar | January 16, 2007 @ 2:14 am
Hey, I followed your tutorial but on a 6.10 server. Thanks very much. It’s quicker than doing the usual RTFM stuff.
It seems that there are some issues with the Admin Server, i.e. it doesn’t come up. Do you know where I can look for a log file? There doesn’t seem to anything at /var/log
Another question, how do I enable/coinfigue the service for connecting via TCP/IP? I’ve installed DB2 in an Ubuntu VM and need remote connectivity. A pointer to an external guide would be cool.
Thanks, Gunnar
Frank | June 5, 2007 @ 3:25 pm
Worked like a charm on Edgy Eft.
Thanks,
Frank
holger | June 29, 2007 @ 2:50 am
Hi,
there is a db2-package now, that pretty much boils the installation down to one line and makes apt do all the work. I published a mini-howto at my blog
A happy reader | June 29, 2007 @ 4:23 am
Thank you very much for this article, DB2 V9.1 is now running on my Debian etch 4.0!
Shubhakant | August 17, 2007 @ 7:26 pm
Thanks a ton for concise and a great writeup. Got my V9.1 running in 5 mins.
Luke stedman | October 10, 2007 @ 5:36 am
Excellent guide, thanks!
Luís Pontes | November 19, 2007 @ 7:34 pm
Regarding Gunnar questions:
DB2 Administration server has to be started/stopped by dasusr1.
To start DAS execute:
su - dasusr1 - “db2admin start”
To stop DAS execute:
su - dasusr1 - “db2admin stop”
DAS log is here /home/dasusr1/das/dump/db2dasdiag.log
DB2 instance log is here: /home/db2inst1/sqllib/db2dump/db2diag.log
In order to get db2 accepting connections via tcpip:
1) As root add the following set of lines to /etc/services:
db2c_db2inst1 50000/tcp
DB2_db2inst1 60000/tcp
DB2_db2inst1_1 60001/tcp
DB2_db2inst1_2 60002/tcp
DB2_db2inst1_END 60003/tcp
2) As db2inst1 execute the following commands:
db2set DB2COMM=tcpip
db2 update dbm cfg using svcename db2c_db2inst1
db2stop
db2start
DAS service will listen on port 523 tcp and udp.
DB2 instance will listen on port 50000 tcp.
Hope it helps !
Luís