简体   繁体   中英

How to identify DB2 port number

I have to make DB2 connection in java using port number. Is there any command in DB2 or any way that can get the DB2 port number?

I have not used the default port 50000 while making DB2 connection as this port can be changed during DB2 installation. Please suggest any DB2 command or any other alternative.

On the Windows DB2 server, open a DB2 Command Window and execute the command

db2 get database manager configuration | findstr /i svce

This should provide some output like:

 TCP/IP Service name                          (SVCENAME) = db2c_DB2
 SSL service name                         (SSL_SVCENAME) =

SVCENAME is the port that DB2 is listening on. To resolve this name to an actual port number, you need to refer to the services file, which is located at %SystemRoot%\\system32\\drivers\\etc\\services .

Go to DB2 command prompt.

Issue the command to get the db2 instance

Command : db2 get instance

Issue the command to find the TCP/IP service name

Command : db2 get dbm cfg | grep SVCE

Example

db2 get dbm cfg | grep SVCE

TCP/IP Service name (SVCENAME) = db2c_db2inst9 The TCP/IP service name is " db2c_db2inst9 "

Use the TCP/IP service name to find the port number in the /etc/services file

Command : grep TCP/IPservicename /etc/services

Change TCP/IPservicename with the current service name.

Example

grep db2c_db2inst9 /etc/services

db2c_db2inst9 50090/tcp

The DB2 instance is running on the port number 50090

On the Linux/Unix DB2 server, open a shell terminal and logon with the instance owner. Execute the below command:

        db2 "get dbm cfg"|grep -i svce

Like the answer of Ian Bjorhvde you show the TCP/IP Service name, SVCENAME you can view in the file /etc/service .

Probably you have different instances in your server, that means, DB2 is listening in different ports. First, you have to list the instances in the server

db2ilist

You will get a set of instance names. For each one you have to get the port name

Windows

set DB2INSTANCE=instname
db2 get dbm cfg

Linux

export DB2INSTANCE=instname
db2 get dbm cfg

If you do not change the instance, you will only get the service name of the current instance. Another way to get that information from the client is via the Configuration Assistant (db2ca). With advanced view, you right click on an instance, and then you will get the details of the instance: port number, service name, etc.

这将为计算机上安装的所有db2实例提供端口(适用于Linux或AIX系统)

netstat -aan | grep -i db2

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM