Adsense

Wednesday, April 17, 2013

How to access DB2 remote database from the client machine (Db2 Catalog)


To connect the remote database from the client machine, we have to do the following things.

1) Install the DB2 Client Software
2) Catalog Remote Node
3) Catalog Remote Database
4) Connect the Remote Database

Steps in Detail
----------------------
Catalog TCP/IP Node
You have to make an entry to the client's node directory to describe the remote node. This entry specifies the chosen alias (node_name), the hostname (or ip_address), and the servicename (or port_number) that the client will use to access the remote server

Syntax : db2 catalog tcpip node Nodename remote Hostname server service

where Nodename is the name of the node to be added in the client machine . Node name should be unique in the client machine node director, where Hostname is Ip Address or Hostname of the Remote Machine, where service is the service name or Port
to see the node list , give the following command
Command : db2 list node directory

Command: db2 catalog tcpip node testnode remote 192.188.79.129 server 50001

When running the above command the following error may come : Error : SQL1092N : does not have the authority to perform the requested command.
if the above error comes , please run the following command.
db2 UPDATE DBM CFG USING CATALOG_NOAUTH YES
DB20000I The UPDATE DATABASE MANAGER CONFIGURATION command completed successfully.

Again issue the following commands.
------------------------------------------------
db2 catalog tcpip node testnode remote 192.188.79.129 server 50001

DB20000I The CATALOG TCPIP NODE command completed successfully.

DB21056W Directory changes may not be effective until the directory cache is refreshed.

Catalog Database
----------------
Syntax : db2 catalog database dbname as aliasname at node Nodename

where dbname is the remote database name , aliasname which is to be the displayed as dbname in the client name.
Command : db2 catalog database employee as emp_s at node testnode

DB20000I The CATALOG DATABASE command completed successfully.

DB21056W Directory changes may not be effective until the directory cache is refreshed.

Now we can connect the remote database as follows.

Syntax: db2 connect to aliasname user username using password

Command: db2 connect to emp_s user db2inst1 using db2inst1

2 comments:

  1. Hello, I've followed your process thoroughly and cataloged both node and db successfully. But when I'm trying to connect, db2 shows the following error:

    " SQL30081N A communication error has been detected. Communication protocol
    being used: "TCP/IP". Communication API being used: "SOCKETS". Location
    where the error was detected: "10.29.57.20". Communication function detecting
    the error: "connect". Protocol specific error code(s): "110", "*", "*".
    SQLSTATE=08001 "

    To be more clear, I've cataloged node with command:
    " db2 catalog tcpip node testnode remote 10.29.57.20 server 50000 "

    cataloged db with command:
    " db2 catalog database sample as smpl at node testnode "

    and tried connecting with command:
    " db2 connect to smpl user *username* using *password* "

    ReplyDelete
    Replies
    1. Is your issue resolved ? I am also facing the same.

      Delete