1. Login to the DB2 DBMS server.
2. Launch the DB2 Control Center.
3. Right-click the target instance.
4. Click Setup Communications.
5. The port number appears in the Properties window.
Method 1: /etc/services
1. Login to the machine that hosts the DB2 DBMS.
2.
vi the /etc/services file.
vi /etc/services
3.
Locate the socket service associated with your target database.
4. Identify the port number associated with the socket service.
Method 2: get instance
1.
Login to the machine that hosts the DB2 DBMS.
2.
su to your db2 instance owner.
For example:
su db2instance1
3.
Execute the .profile associated with the db2 instance owner.
For example:
. ./.profile
4.
cd into the $DB2INSTANCE/sqllib/bin directory.
cd $DB2INSTANCE/sqllib/bin
5.
Execute the db2 command.
./db2
6.
Use the get instance option to get the current instance name.
get instance
7.
Use get dbm cfg command to identify the socket service name.
get dbm cfg l grep SVCE # Example uses an "l" instead of a pipe due to limitations in markup display.
8.
Look for output similar to the following where db2inst64 is the service name:
TCP/IP Service name (SVCENAME) = db2inst64
9.
Use the db2 interface to grep the /etc/services file for the service name listed above.
For example:
grep db2inst64 /etc/services
10.
Look for output similar to the following:
db2inst64 50012/tcp # Connection port for DB2 instance instance