DB2 Connect Quick Beginnings for Linux**

Configuring TCP/IP on the Client

This section assumes that TCP/IP is functional on the client and server workstations. See Software Requirements for the communication protocol requirements for your platform. See Possible Client-to-Server Connectivity Scenarios for the supported communication protocols for your particular client and server.

To set up TCP/IP communications on a DB2 client, perform the following steps:

Step  1.

Identify and record parameter values.

Step  2.

Configure the client:

  1. Resolve the server's host address.
  2. Update the services file.
  3. Catalog a TCP/IP node.
  4. Catalog the database.

Step  3.

Test the connection between the client and server.



Figure hint not displayed.

Due to the characteristics of the TCP/IP protocol, TCP/IP may not be immediately notified of the failure of a partner on another host. As a result, a client application accessing a remote DB2 server using TCP/IP, or the corresponding agent at the server, may sometimes appear to be hung. DB2 uses the TCP/IP SO_KEEPALIVE socket option to detect when there has been a failure and the TCP/IP connection has been broken.

If you are experiencing problems with your TCP/IP connection, refer to the Troubleshooting Guide for information on how to adjust this parameter and other common TCP/IP problems.

Step 1. Identify and Record Parameter Values

As you proceed through the configuration steps, complete the Your Value column in the following table. You can fill in some of the values before you start configuring this protocol.

Table 9. TCP/IP Values Required at the Client
Parameter Description Sample Value Your Value

Host Name

  • Hostname (hostname) or
  • IP address (ip_address)

Use the hostname or ip_address of the remote server workstation.

To resolve this parameter:

  • Enter the hostname command at the server to obtain the hostname.
  • Contact your network administrator to obtain the ip_address or enter the ping hostname command.

 serverhost

or

9.21.15.235

 

Service Name

  • Connection Service name (svcename) or
  • Port number/Protocol (port_number/tcp)

Values required in the services file.

The Connection Service name (svcename) is an arbitrary name that represents the Port number (port_number) on the client.

The port number for the client must be the same as the port number that the svcename parameter maps to in the /etc/services file at the server. (The svcename parameter is located in the database manager configuration file on the server.) This value must not be in use by any other applications, and must be unique within the services file.

This value generally must be 1024 or higher.

Contact your database administrator for the values used to configure the server or enter the db2 get dbm cfg command on the server.

 

db2cdb2inst1

 

 

 

 

 

50000/tcp

 

 
Node name (node_name)

A local alias, or nickname, that describes the remote server (referred to as a node) to which you are trying to connect. You can choose any name you want; however, all node name values within your local node directory must be unique.

db2node  

Step 2. Configure the Client

The following steps configure this protocol on the client. Replace the sample values with your worksheet values.

A. Resolve the Server's Host Address



Figure car not displayed.

If your network has a name server, or you are planning to directly specify the IP address (ip_address) of the server, skip this step and proceed to B. Update the Services File.

The client must know the address of the server with which it is attempting to establish communications. If a name server does not exist on your network, you may directly specify a hostname that maps to the IP address (ip_address) of the server in the local hosts file. The hosts file for your platform is located in the /etc directory.

Figure hint not displayed.

If you plan to support a Linux client that uses Network Information Services (NIS), and your network does not use a name server, you must update the hosts file located on your NIS master server.

Edit the client's hosts file and add an entry for the server's hostname. For example:

   9.21.15.235     serverhost   # host address for serverhost

where:

9.21.15.235
is the ip_address of the remote DB2 server.

serverhost
is the remote DB2 server's hostname.

#
denotes the start of a comment that describes this entry


Figure hint not displayed.

If the server is not in the same domain as the client, you must provide a fully qualified domain name such as serverhost.vnet.ibm.com, where vnet.ibm.com is the domain name.

B. Update the Services File



Figure car not displayed.

If you plan to catalog a TCP/IP node using a port number (port_number), skip this step and go to C. Catalog a TCP/IP Node.

Using a local text editor, add the Connection Service name and port number to the client's services file for TCP/IP support. The services file for your platform is located in the /etc directory. For example:

   db2cdb2inst1  50000/tcp  # DB2 connection service port for remote server

where:

db2cdb2inst1
is an arbitrary unique connection service name in the client's /etc/services file.

50000
is the port number that the svcename maps to on the remote DB2 server. You must use the same port number on the DB2 client and the DB2 server.

tcp
is the communication protocol that you are using

#
denotes the start of a comment that describes this entry

The port number used on the client must match the port number used on the server.

Figure hint not displayed.

If you are planning on supporting a Linux client that uses Network Information Services (NIS), you must update the services file located on your NIS master server.

The file called services is located in the /etc directory.

C. Catalog a TCP/IP Node

You must add an entry to the client's node directory to describe the remote server node. This entry specifies the chosen alias (node_name), the hostname or ip_address, and the svcename or port_number that the client will use to access the remote server.

To catalog a TCP/IP node, perform the following steps:

Step  1.

Log on to the system with a valid DB2 user ID. For more information, see Appendix D, Naming Rules.

Figure hint not displayed.

If you are adding a database to a system that has a DB2 Connect server product installed, log on to this system as a user with System Administrative (SYSADM) or System Controller (SYSCTRL) authority on the instance. For more information, see Working with the System Administrative Group.

This restriction is controlled by the catalog_noauth database manager configuration parameter. For more information, refer to the Administration Guide.

Step  2.

Set up the instance environment and invoke the DB2 command line processor by entering one of the following commands:

   . INSTHOME/sqllib/db2profile    (for Bash, Bourne or Korn shell)
   source INSTHOME/sqllib/db2cshrc (for C shell)

where INSTHOME represents the home directory of the instance.

Step  3.

Catalog the node by entering the following commands:

   db2 "catalog tcpip node node_name remote [hostname|ip_address]
        server [svcename|port_number"
   db2 terminate

For example, to catalog the remote server serverhost on the node called db2node, using the service name db2cdb2inst1, enter the following commands:

   db2 "catalog tcpip node db2node remote serverhost server db2cdb2inst1"
   db2 terminate

To catalog a remote server with the IP address 9.21.15.235 on the node called db2node, using the port number 50000, enter the following:

   db2 "catalog tcpip node db2node remote 9.21.15.235 server 50000"
   db2 terminate



Figure hint not displayed.

If you need to change values that were set with the catalog node command, perform the following steps:

Step  1.

Run the uncatalog node command in the command line processor as follows:

   db2 "uncatalog node node_name"

Step  2.

Recatalog the node with the values that you want to use.

D. Catalog the Database

Before a client application can access a remote database, the database must be cataloged on the server node and on any client nodes that will connect to it. When you create a database, it is automatically cataloged on the server with the database alias (database_alias) the same as the database name (database_name). The information in the database directory, along with the information in the node directory, is used on the client to establish a connection to the remote database.

To catalog a database on the client, perform the following steps:

Step  1.

Log on to the system with a valid DB2 user ID. For more information, see Appendix D, Naming Rules.

Figure hint not displayed.

If you are adding a database to a system that has a DB2 Connect server product installed, log on to this system as a user with System Administrative (SYSADM) or System Controller (SYSCTRL) authority on the instance. For more information, see Working with the System Administrative Group.

This restriction is controlled by the catalog_noauth database manager configuration parameter. For more information, refer to the Administration Guide.

Step  2.

Fill in the Your Value column in the following worksheet.

Table 10. Worksheet: Parameter Values for Cataloging Databases
Parameter Description Sample Value Your Value
Database name (database_name) The database alias (database_alias) of the remote database. When you create a database, it is automatically cataloged on the server with the database alias (database_alias) the same as the database name (database_name). sample  
Database alias (database_alias) An arbitrary local nickname for the remote database, on the client. If you do not provide one, the default is the same as the database name (database_name). This is the name that you use when connecting to a database from a client. tor1  
Node name (node_name) The name of the node directory entry that describes where the database resides. Use the same value for node name (node_name) that you used to catalog the node in the previous step. db2node  

Step  3.

Set up the instance environment and invoke the DB2 command line processor by entering one of the following commands:

   . INSTHOME/sqllib/db2profile    (for Bash, Bourne or Korn shell)
   source INSTHOME/sqllib/db2cshrc (for C shell)

where INSTHOME represents the home directory of the instance.

Step  4.

Catalog the database by entering the following commands:

   db2 "catalog database database_name as database_alias at node node_name"
   db2 terminate

For example, to catalog a remote database called SAMPLE so that it has the alias tor1, on the node db2node, enter the following commands:

   db2 "catalog database sample as tor1 at node db2node"
   db2 terminate


Figure hint not displayed.

If you need to change values that were set with the catalog database command, perform the following steps:

Step  a.

Enter the uncatalog database command as follows:

   db2 "uncatalog database database_alias"

Step  b.

Recatalog the database with the value that you want to use.

Step 3. Test the Client-to-Server Connection

When you have finished configuring the client for communications, perform the following steps to test the connection:

Figure hint not displayed.

You will need to connect to a remote database to test the connection.

Step  1.

Start the database manager by entering the db2start command on the server (if it was not automatically started at boot time).

Step  2.

Enter the following command to connect the client to the remote database:

   db2 "connect to database_alias user userid using password"

The values for userid and password must be valid for the system on which they are authenticated. By default, authentication takes place on the server for a DB2 server and on the host or AS/400 machine for a DB2 Connect server.

Authentication for connecting to host databases is set while configuring the DB2 Connect server. For more information, refer to the DB2 Connect User's Guide.

If the connection is successful, you will get a message showing the name of the database to which you have connected. You are now able to retrieve data from that database. For example, to retrieve a list of all the table names listed in the system catalog table, enter the following command:

   "select tabname from syscat.tables"

When you are finished using the database connection, enter the db2 connect reset command to end the database connection.

Figure car not displayed.

You are now ready to start using DB2. For more advanced topics, refer to the Administration Guide and the Installation and Configuration Supplement.

Troubleshooting the Client-to-Server Connection

If the connection fails, check the following items:

At the server:

__  1.

The db2comm registry value includes the value tcpip.

Figure hint not displayed.

Check the settings for the db2comm registry value by entering the db2set DB2COMM command. For more information, refer to the Administration Guide.

__  2.

The services file was updated correctly.

__  3.

The service name (svcename) parameter was updated correctly in the database manager configuration file.

__  4.

The database was created and cataloged properly.

__  5.

The database manager was stopped and started again (enter the db2stop and db2start commands on the server).



Figure hint not displayed.

If there are problems starting a protocol's connection managers, a warning message appears and the error messages are logged in the db2diag.log file. This file is located in the INSTHOME/sqllib/db2dump directory, where INSTHOME represents home directory of the instance owner.

For more information on the db2diag.log file, refer to the Troubleshooting Guide.

At the client:

__  1.

If used, the services and hosts files were updated correctly.

__  2.

The node was cataloged with the correct hostname (hostname) or IP address (ip_address).

__  3.

The port number matches, or the service name maps to, the port number used on the server.

__  4.

The node name (node_name) that was specified in the database directory points to the correct entry in the node directory.

__  5.

The database was cataloged properly, using the server's database alias (database_alias) that was cataloged when the database was created on the server, as the database name (database_name) on the client.

If the connection still fails after you verify these items, refer to the Troubleshooting Guide.


[ Top of Page | Previous Page | Next Page ]