Friday, 29 August 2014

Notes to self - Setting up DB2 Client connectivity

It's been ~10 years since I last did this ( DB2 on Unix to DB2 on z/OS or OS/400 ), but I now have a requirement to deliver a DB2 client for WebSphere MQ interaction ( MQ will use ODBC rather than JDBC ).

I knocked this up using a pair of VMs on my Macbook .....

Response File -  ~/db2client.rsp

PROD                      = CLIENT
FILE                      = /opt/ibm/db2/V10.1
LIC_AGREEMENT             = ACCEPT
INSTALL_TYPE              = TYPICAL

Install DB2 Client Binaries - as root

./db2setup -r ~/db2client.rsp

Create DB2 User and Group - as root

groupadd db2users
useradd -g db2users -d /home/db2user1 db2user1
passwd db2user1

Create DB2 Instance ( required for client connectivity ) - as root

/opt/ibm/db2/V10.1/instance/db2icrt -a CLIENT db2user1

Catalog Remote DB2 Server ( Node ) - as db2user1

db2 catalog tcpip node rhel6 remote rhel6 server DB2c_db2inst1

( node and remote refer to DB2 server hostname, server refers to DB2 service name in /etc/services )

Validate Node Directory

db2 list node directory

Test Connectivity - as db2user1

db2 attach to rhel6 user db2inst1 using passw0rd
db2 list applications
db2 detach

Catalog Remote Database - as db2user1

db2 catalog database foobar at node rhel6

( database refers to database alias on remote server, node refers to previously catalogued node )

Validate DB Directory - as db2user1

db2 list db directory

Create Database on Server - as db2inst1

db2 "create table snafu(surname char(16) not null,firstname char(10) not null)"

Use Database - as db2user1

db2 connect to foobar user db2inst1 using passw0rd
db2 list tables for all | more
db2 "select * from db2inst1.snafu"
db2 "describe select * from db2inst1.snafu"
db2 "insert into db2inst1.snafu(surname,firstname) values('Hay','Dave')"
db2 "select * from db2inst1.snafu"
db2 terminate

Shiny :-)

No comments: