DB2 Client Install on Linux

Allowing client machines to connect to a DB2 database is not as simple as regular databases. If you are using a client application, such as a Java web application, usually the application server has what is needed to configure a DB2 connection pool. However, if you need to access DB2 from the command line, the process is a little more complicated. Here are steps that will work with IBM DB2 v9.5 (example is for AMD64 architecture):

  • Get download link from http://www-306.ibm.com/software/data/db2/9/download.html
  • Run the following commands:
    wget <use link retrieved above>
    tar xvzf v9.5_linuxx64_client.tar.gz
    client/db2_install (accept defaults)
    groupadd -g 999 db2iadm1
    groupadd -g 998 db2fadm1
    groupadd -g 997 dasadm1
    useradd -u 1004 -g db2iadm1 -m -d /home/db2inst1 db2inst1
    useradd -u 1003 -g db2fadm1 -m -d /home/db2fenc1 db2fenc1
    useradd -u 1002 -g dasadm1 -m -d /home/dasusr1 dasusr1
    /opt/ibm/db2/V9.5/instance/db2icrt -a server -u db2fenc1 db2inst1
    cp /home/db2inst1/sqllib/db2profile /etc/profile.d/db2profile.sh
  • If you run into errors during the install process such as:

    /root/client/db2/linuxamd64/install/db2_install: line 277: /root/tmp/db2_install.15043.rsp: Not a directory
    /root/client/db2/linuxamd64/install/db2_install: line 285: /root/tmp/db2_install.15043.rsp: Not a directory
    /root/client/db2/linuxamd64/install/db2setup: /tmp/db2.tmp.15043/db2/linuxamd64/install//db2chgpath: /bin/sh: bad interpreter: Permission denied
    /root/client/db2/linuxamd64/install/db2setup: /tmp/db2.tmp.15043/db2/linuxamd64/install//db2setup_exec: /bin/sh: bad interpreter: Permission denied

    Because /tmp is mounted with the noexec option the db2_install fails. It looks like it prefers to copy all the files to tmp then install (not a secure method).

    Open up the platform specific db2_install file (noted above in the errors)

    db2/linuxamd64/install/db2_install

    Edit the TMPDIR line:

    TMPDIR=${DB2TMPDIR:-/tmp}

    to something like

    TMPDIR=${DB2TMPDIR:-/root/tmp}

    (*directory must exist or be created!)

    Next, make sure DB2TMPDIR is a valid environment variable matching above:

     [root@server ~/] export DB2TMPDIR=~/tmp

    Then start the db2_install from the top level directory, IE

     ./db2_install
  • there is one more step: adding the catalog entry to for the remote database which consists of two steps
  • create the instance alias using the following commands:
        db2 "catalog tcpip node remoteinst remote remotehost server 50000"
        db2 "terminate"
    
  • create the database alias using the following commands:

        db2 "catalog database testdb as remotedb at node remoteinst authentication server"
        db2 "terminate"
    

References:

This entry was posted in DB2 and tagged , . Bookmark the permalink.

NewPush has solutions to fit your business needs.  For more than a decade, our focus has been to take on the technical challenges that are the hardest and most time-consumming.  Our goal is to free up your resources to focus on the core activities of your business and to drive your business performance.  Please visit our main site at newpush.com for more information or call us at +1-303-423-4500.