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 deniedBecause
/tmpis mounted with thenoexecoption thedb2_installfails. It looks like it prefers to copy all the files to tmp then install (not a secure method).Open up the platform specific
db2_installfile (noted above in the errors)db2/linuxamd64/install/db2_install
Edit the
TMPDIRline:TMPDIR=${DB2TMPDIR:-/tmp}to something like
TMPDIR=${DB2TMPDIR:-/root/tmp}(*directory must exist or be created!)
Next, make sure
DB2TMPDIRis 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:
