4

I am not able to connect my db2 application to my localhost database.

The db2 API used by the application need TCPIP and try to connect to host "localhost" and port "50001".

The error I have is .

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

I had to setup all below manually as I didn't have it on my machine

I had a look with wireshark to see what is happening but I can see that the communication is reset ..plus using telnet the communication is not established and netstat doesn't listen that port.

Do I have to issue some extra command to start listening?

Below all my setup.

db2 "get database manager configuration" | grep SVC
TCP/IP Service name                      (SVCENAME)     = db2c_db2inst1
SSL service name                         (SSL_SVCENAME) = 

Then the services

cat /etc/services | grep db2c_
db2c_db2inst1   50001/tcp       # DB2 connection service port

I also allow the firewall on that port.

 iptables -I INPUT -p tcp --dport 50001 -j ACCEPT  
 /sbin/service iptables save

 iptables -list

 Chain INPUT (policy ACCEPT)
 target     prot opt source               destination         
 ACCEPT     tcp  --  anywhere             anywhere            tcp dpt:db2c_db2inst1 
Abruzzo Forte e Gentile
  • 14,423
  • 28
  • 99
  • 173
  • Issue `db2set -all` to verify that this is set: `DB2COMM=TCPIP`. And make sure you do `db2stop` and `db2start` after changing any of the communication parameters. – mustaccio May 31 '13 at 12:39
  • HI. I tried db2set -all and I cannot see that string. I see the following i] DB2AUTOSTART=NO [g] DB2SYSTEM=my-host-name [g] DB2INSTDEF=db2inst1 [g] DB2ADMINSERVER=dasusr1 What does it mean? – Abruzzo Forte e Gentile May 31 '13 at 13:29
  • It means DB2 doesn't know it should start the TCP communications manager process. Use `db2set DB2COMM=TCPIP` to set the variable, then bounce the instance. – mustaccio May 31 '13 at 13:35
  • Hi. Still the same. I can see on the network a stright TCP Reset/Ack. I tried the following command "db2 list node directory show detail" and got as SERVICE port 50000. Should this value match the one in the service? – Abruzzo Forte e Gentile May 31 '13 at 14:09
  • "_Should this value match the one in the service?_" What do you think? – mustaccio May 31 '13 at 14:37
  • Have you connected to the database from the db2clp? – AngocA May 31 '13 at 18:34
  • Yes. Funny thing is that I sorted out this way: A.I uninstalled all db2 and re-installed it from scratch. B.This time, in order to set the port where db2 should listen, I did used the PORT NUMBER instead of the SERVICE NAME and it worked. My call was "update dbm cfg using svcename 50000". With the service name it looks like it doesn't work properly. – Abruzzo Forte e Gentile Jun 03 '13 at 08:33
  • @mustaccio: thanks for the confirm to my silly question but that didn't work. See how I fixed..next time I will go for explicit port numbers instead of services. – Abruzzo Forte e Gentile Jun 03 '13 at 08:35

1 Answers1

3

The steps should be:

  1. set DB2COMM=tcpip and bounce the instance

  2. check if it's tcpip4 or tcpip6 using
    netstat -an | grep -i port number (here 50001)

  3. get remote server IP using
    pctt -r

  4. catalog node with:
    db2 catalog tcpip4/tcpip6 node <nodename> remote <ip address> server <port number>

  5. catalog database
    db2 catalog DB <dbname> at node <nodename>

Dave L.
  • 9,595
  • 7
  • 43
  • 69
Saurabh Agrawal
  • 1,355
  • 3
  • 17
  • 33