How to access remote database from DB2 client?

If you want to access a remote DB2 (v9.7) database from another host that’s running DB2 client. You have to do following things on client machine:

  1. Adding remote host in host file
  2. Switch user to DB2 user (e.g. db2inst1)
  3. Catalog remote node
  4. Catalog remote database

Adding remote host in host file

Open /etc/hosts file and add your remote host with it’s IP address. You can vi this file and make changes. You must have root privileges to do this operation.

Switch to DB2 user

Switch to DB2 user by following command in shell.

su - db2inst1

Catalog remote node

Since now you have added you remote host in the host file (suppose your hostname is lpar0). Execute following command in the shell:

catalog tcpip node lpar0 remote lpar0 server 50000

50000 is the port of DB2 database.

Cataloging remote database

Now execute following command.

. DB2_INST_HOME/sqllib/db2profile

catalog database mysampledb as mysampledb at node lpar0 authentication server

Check your connectivity

connect to mysampledb user ctginst1 using admin

Where ctginst1 and admin are user name and password of mysampledb on host lpar0.

References

  1. CATALOG TCPIP/TCPIP4/TCPIP6 NODE command
  2. Cataloging a database from a DB2 client using the CLP
Related Posts Plugin for WordPress, Blogger...