Installing db2 9 express-c on a headless Ubuntu/Redhat (RHEL) box with db2setup and a response file

Ok, so after posting my summarized HOW TO guide on how to manually install and uninstall DB2 9 express-c via db2_install in a situation (headless) where you don’t have an X-Server available, nor forwarding, or you simply just want to install over SSH in a quick bind….via command line only, I received some great pointers from folks about another headless option. That being using response files with the db2setup command.

Just to note, there are two ways you can install DB2 via the command line without any sort of x-server.

  1. Via the process described below in detail below by using a response file and db2setup
  2. Via the db2_install manual method (command line) which is described in detail in my other article.

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;

  1. db2 instance owner = db2inst1
  2. db2 fence user = db2fenc1
  3. 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

g) You can certainly change MORE options than what I specifically call out below in the response file editing section (such as the install path etc), however I am just pointing out the options you MUST change to get the install rolling with a basic install.


  1. The following instructions are taken from the official document located here.
  2. Login as root
  3. As root, open up /etc/services and add the following line at the end of the file db2c_db2inst1 50000/tcp # DB2 connection service port, (NOTE you can change the port to something other than the default if you want, i.e. security reasons)
  4. Go to IBM and download DB2 Express-C
  5. Save the tarball file in /tmp/db2expc9
  6. cd /tmp/db2expc9 and extract the tarball with tar -xvzf the_db29_tarball_filename.tar.gz
  7. cd expc
  8. cd db2/linux/samples
  9. cp db2expc.rsp my-db2expc.rsp
  10. chmod +w my-db2expc.rsp
  11. vi my-db2expc.rsp or if you don’t like the vi editor use your editor of choice.
  12. Ok, this is a response file which is basically automated input which will be fed into the db2setup “wizard” so you can feed it all the input without running it in GUI mode. Its time to party and get going on this file so lets move on to the next bullet. An IMPORTANT note, any line with a * or # is a COMMENT within the file and is not processed.
  13. Before we continue, click here to view a handy reference that contains descriptions of all the configurable settings within a response file
  14. Scroll down to LIC_AGREEMENT and change “DECLINE” to say “ACCEPT” after reading the license agreement.
  15. Scroll down to INTERACTIVE and change to “YES” so that the db2setup will interactively prompt us for the location of the install files (from the tarball we downloaded)
  16. Scroll down to CONFIG_ONLY and set this to “NO”
  17. Scroll down to INSTALL_TYPE and set this to “CUSTOM”
  18. Just below the INSTALL_TYPE is a list of 6 commented out options. Now given this is a headless machine you are installing to, you probably only care about uncommenting the DB2_DATA_SOURCE_SUPPORT, DB2_SAMPLE_DATABASE and LDAP_EXPLOITATION options as the other ones are options for GUI tools which you don’t care about.
  19. Just below those 6 options, comes the “non-typical” instal options. You will need to evaluate each one to see if you want it installed. Again, given you are on a headless machine, you probably want to skip
    everything that is a GUI tool. The item I kept was TEXT_SEARCH
  20. Next is the languages section, again, I don’t need all that so I left them commented out which will result in english being the default installed
  21. Next is the “upgrade” section, again you need to evaluate this, however given the assumptions of this article (brand-new install) you will leave these alone (commented out)
  22. Now scroll to the Instance Creation Settings section. This is an important one as here is where we specify instance information and the users that are to be created.

Instance Creation Settings

  1. Ok, we are still within the response file and you should be at the “Instance Creation Settings” section. This section contains the parameters for the db2inst1 user that will be created, who is also the instance owner for the single db2 instance that will be created called db2inst1
  2. In this section you will see a bunch of db2inst1.SOMEPROPNAME settings. I am only going to point out the ones you might consider changing below, the defaults should be fine for you.
  3. db2inst1.GROUP_NAME = I changed the value to be db2inst1 so the group name is the same as the username. This is optional of course but just my preference.
  4. db2inst1.HOME_DIRECTORY = /home/db2inst1
  5. db2inst1.PASSWORD = set to some password, you might want to change after the install manually via a command line with passwd db2inst1
  6. db2inst1.AUTOSTART = leave to YES if you want db2 to start on reboots
  7. db2inst1.PORT_NUMBER = 50000, you might want to change this from the default for security reasons, you call, remember to update your iptables scripts as well as the /etc/services that we made earlier!

Fenced User Creation Settings

Yes there is more! Lets keep going….

  1. Ok, we are still within the response file and you should be at the “Fenced User Creation Settings” section. This section contains the parameters for the db2fenc1 user that will be created.
  2. In this section you will see a bunch of db2fenc1.SOMEPROPNAME settings. I am only going to point out the ones you might consider changing below, the defaults should be fine for you.
  3. db2fenc1.FENCED_GROUP_NAME = I changed the value to be db2fenc1 so the group name is the same as the username. This is optional of course but just my preference.
  4. db2fenc1.FENCED_HOME_DIRECTORY = /home/db2fenc1
  5. db2fenc1.FENCED_PASSWORD = set to some password, you might want to change after the install manually via a command line with passwd db2fenc1

Instance DBM Config Settings

This section contains a bunch of configuration settings for our db2inst1 instance. If you just want to get up running, you can skip this and they can be changed later, however you will need to know what you are doing as these are tweaks to the instance for performance and other optimizations. Skip mucking with this for now.

Administration Server Creation Settings

Yes it continues, but this is an important one. This section covers the administration server and our DAS user which we are calling db2das1

  1. I am only going to point out the ones you might consider changing below, the defaults should be fine for you.
  2. DAS_USERNAME = db2das1
  3. DAS_GROUP_NAME = db2das1
  4. DAS_HOME_DIRECTORY = /home/db2das1
  5. DAS_PASSWORD = set to some password, you might want to change after the install manually via a command line with passwd db2das1

Global Profile Registry Settings

Giddyup… vi is reporting we are 71% done….. Again this is a configuration setting section however you may want to change certain ones, I will point out the ones I changed for my basic install needs.

  1. DB2CODEPAGE I set mine to the value “1208” which is UTF-8

Database Settings and the remainder of the file (skip it)

This section pertains to any “default” databases that you want the installer to automatically create and some other sections which are not necessary at this point. I skip these remaining sections.


  1. Ok, so if you have not already done so, save the my-db2expc.rsp file and exit your editor.
  2. cd /tmp/db2expc9/expc
  3. Execute ./db2setup -r /tmp/db2expc9/expc/db2/linux/samples/my-db2expc.rsp. This will fire off the installation
  4. If there are any errors in your response file, you should get them now, and can correct them, re-run if necessary
  5. Assuming that db2setup is running, just sit and wait it out…..
  6. When the install is done, you can view the log file (review it!) @ /tmp/db2setup.log
  7. To test your install, logout as root then login as db2inst1
  8. Exec db2stop followed by a db2start
  9. Verify that DB2 is listening on your port by typing netstat -na and look for your port listed in the output.
  10. 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.


Hey, lets create a basic database and verify we can use it to see that DB2 works.

  1. Login as db2inst1, the db2 instance owner
  2. execute a db2 create database bitsoi
  3. Connect with db2 connect to bitsoi user db2inst1
  4. Enter the password
  5. You are now connected if you seee the “database connection information” output
  6. Fire up the CLP with db2
  7. At the prompt type create table myTest (name varchar(10))
  8. If successful, insert a record with insert into myTest (name) values ('bitsofinfo')
  9. Select it with select * from myTest
  10. Yeah, it works, exit with a quit and when back at the command line type db2 terminate


There is a method to uninstall DB2 via a response file as well. See the official DB2 document here.

  1. BEFORE doing this, you STILL have to drop your db2 instances and admin server: click here and scroll to the uninstall section
  2. Login as root
  3. cd /tmp/db2expc9/expc
  4. cd db2/linux/samples
  5. cp db2un.rsp my-db2un.rsp
  6. chmod +w my-db2un.rsp
  7. vi my-db2un.rsp or if you don’t like the vi editor use your editor of choice.
  8. This is the uninstall response file. To remove everything just uncomment the first REMOVE_PROD link to remove everything
  9. cd /tmp/db2expc9/expc
  10. execute ./db2_deinstall -r db2/linux/samples/my-db2un.rsp
  11. When prompted enter your DB2DIR install dir (should be /opt/ibm/db2/V9.7 (or your version)
  12. Once this finishes, everything will be removed

The above process is not much different than reading my other article and scroll towards the bottom to read the uninstall procedure. I guess the response file uninstall method gives you better control over what you want removed…


Now, all of that said, I just want to express a concern I have with the DB2 docs online. Your average joe, maybe a new user wanting to try out DB2, who needs to install DB2 on a headless box, is going to start by reading the “Installing DB2 servers (Linux and UNIX)” document in the IBM docs.. They will quickly see the following note:

The DB2 Setup wizard is a graphical installer. You must have X windows software capable of rendering a graphical user interface for the DB2 Setup wizard to run on your machine. Ensure that the X windows server is running. Ensure that you have properly exported your display. For example, export DISPLAY=

Ok great, but hey, wouldn’t it be great if this document stated something to the effect of: “If you X windows software is not available you can either manually install via the db2_install command [link here], OR click here [link to response file instructions] to learn how to install via db2setup using response files”

Unfortunately it is not and the information about response file installs is buried down in the table of contents under “Response file installation”.. Which unfortunately is not really titled appropriately (nor linked to from the db2setup page) for the average new user to associate that “oh, this is how I can install without a GUI from the command line”.

The net result? A new user to DB2 express c, might just bail immediately and go with another piece of database software, because they can install much easier right out of the box on a headless machine without laboring through a dozen or so online HTML documents. Also don’t forget that since they are installing headless, they can’t even view those if the only machine they have is the box they are installing on. Not likely, but possible, and I for one would have no desire to bust out lynx or elinks etc. Ugh!

About these ads


  1. David
    Posted October 23, 2009 at 1:03 am | Permalink | Reply


    absolutely correct! I found myself lost in the DB2 online help. Expecting a server OS would be the first choice. This guide helped me to get DB2 Express C 9.7 up and running on Ubuntu 8.04 LTS Server.

    Thanks a lot!


  2. Posted May 17, 2010 at 2:48 am | Permalink | Reply

    Using this guide, I installed DB2 on an headless Debian in a snap! Thanks

  3. jtepoorten
    Posted August 29, 2012 at 5:39 pm | Permalink | Reply

    Thank you very much for posting these instructions to installing the IBM DB2 Express-C system using a command prompt with no available GUI.

  4. ryker
    Posted January 31, 2013 at 12:25 pm | Permalink | Reply

    Thank you! Your post helped me install db2 v10.1 on headless Ubuntu.
    I encountered 1 issue because of not having libaio1. Resolved it with sudo apt-get install libaio1.

One Trackback

  1. [...] Via the db2setup -r [responsefile] method which is described in detail in my other article. [...]

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s


Get every new post delivered to your Inbox.

Join 28 other followers

%d bloggers like this: