IBM Books

Quick Beginnings for DB2 Extended Enterprise Edition for UNIX


Configuring TCP/IP on the Client

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

The following steps are required to set up a DB2 client to use TCP/IP communications:

  1. Identify and record parameter values.

  2. Configure the client:

    1. Resolve the server's host address.

    2. Update the services file.

    3. Catalog the TCP/IP node.

    4. Catalog the database.

  3. Test the connection between the client and server.


note

Due to the characteristics of the TCP/IP protocol, the TCP/IP subsystem 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 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 13. TCP/IP Values Required at the Client
Parameter Description Sample Value Your Value
Hostname (hostname)

or

IP address (ip_address)

Use the hostname or ip_address of the remote server workstation.

To resolve this parameter:

  • Issue the hostname command at the server to obtain the hostname parameter.

  • Issue the ping server_hostname command to obtain the ip_address parameter.

serverhost

or

9.21.15.235

 

Connection Port

  • Connection Service name (svcename)

  • Port number/Protocol (port_number/tcp)

Values required in the services file.

The Connection Service name is an arbitrary name used to represent 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 services file at the server. (The svcename parameter is located in the database manager configuration file on the DB2 server.) This value must not be in use by any another applications, and must be unique within the services file. Ensure that you do not specify a port number that is being used by the Fast Communication Manager (FCM).

 

server1

 

3700/tcp

 

 
Node name (node_name)

A local alias, or nickname, that describes the node where the database resides. 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 describe how to configure this protocol on the client. Replace the sample values with your worksheet values.

A. Resolve the Server's Host Address



note

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 "Step B. Update the Services File".

The client workstation must know the address of the server to 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 host in the local hosts file. See Table 14 for the location of the hosts file for your particular platform.

Figure hint not displayed.

If you are planning on supporting a UNIX client that is using Network Information Services (NIS), and you are not using a name server on your network, you must update the hosts file located on your NIS master server.

Table 14. Location of the Local Hosts and Services Files
Platform Location
Macintosh

The hosts file is located in the folder called System Folder.
Note:This operating system does not use a services file. You must catalog this node using the Port_number parameter. See "Step C. Catalog the TCP/IP Node" for more information.

OS/2 Specified by the etc environment variable.

Issue the set etc command to determine the location of your local hosts or services files.
Note:For DOS and WIN-OS2 sessions, you might need to update the hosts and services files located in the tcpip_product\dos\etc directory.

Windows 3.x Typically in the tcpip_product\etc directory, but it depends on the products that you have installed.

Refer to your TCP/IP documentation for more information.

Windows 95 windows directory
Windows NT winnt\system32\drivers\etc directory
UNIX /etc directory

Using a local text editor, add an entry to the client's hosts file 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

serverhost
is the hostname

#
is a comment describing the entry

Notes:

  1. 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.

  2. For specific information on resolving host addresses, refer to your TCP/IP documentation.

Step B. Update the Services File



note

If you are planning to catalog the TCP/IP node using the port number (port_number), skip this step and go to "Step C. Catalog the TCP/IP Node".

If you are configuring a DB2 for Macintosh client, you must catalog the TCP/IP node using the port number (port_number). Go to "Step C. Catalog the TCP/IP Node" to catalog the node.

Using a local text editor, add the Connection Service name and port number to the client's services file for TCP/IP support. For example:

   server1  3700/tcp  # DB2 connection service port

where:

server1
is the Connection Service name

3700
is the port number for the Connection Port

tcp
is the communication protocol that you are using

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 UNIX client that is using Network Information Services (NIS), you must update the services file located on your NIS master server.

The file called services is located in the same directory as the local hosts file that you may have edited in "A. Resolve the Server's Host Address".

Ensure that you did not specify a port number that is being used by the Fast Communication Manager (FCM) or any other process.

See Table 14 for the location of the services file for your particular platform.


Step C. Catalog the TCP/IP Node

You must add 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 svcename (or port_number) that the client will use to access the remote server.

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

  1. Log on to the system as a user with System Administrative (SYSADM) or System Controller (SYSCTRL) authority.

    note

    If you have trouble logging on to the system, see "Logging on to the System".



    note

    If you are configuring communications for a Windows 3.x client, you can use the Client Setup tool to complete this task. Go to "Using the Client Setup Tool to Configure a Windows 3.x Client" to catalog a node using the Client Setup tool.

  2. If you are using a UNIX client, set up the instance environment and invoke the DB2 command line processor as follows:

    1. Run the start up script as follows:
         . INSTHOME/sqllib/db2profile    (for Bourne or Korn shell)
         source INSTHOME/sqllib/db2cshrc (for C shell)
      

      where INSTHOME is the home directory of the instance.

    2. Start the DB2 command line processor by issuing the db2 command.

  3. Catalog the node by issuing the following commands in the command line processor:
       catalog tcpip node node_name remote [  hostname | ip_address ] server [ svcename | port_number ]
       terminate
    

    For example, to catalog the remote server serverhost on the node called db2node, using the service name server1, use:

       catalog tcpip node db2node remote serverhost server server1
       terminate
    

    To catalog a remote server with the IP address 9.21.15.235 on the node called db2node, using the Port number 3700, use:

       catalog tcpip node db2node remote 9.21.15.235 server 3700
       terminate
    


note

If you need to change values that were set with the catalog node command, first run the uncatalog node command in the command line processor as follows:

   uncatalog node node_name

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


Step 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.

  1. Log on to the system as a user with System Administrative (SYSADM) or System Controller (SYSCTRL) authority.

    note

    If you have trouble logging on to the system, see "Logging on to the System".

  2. Fill in the Your Value column in the following worksheet.

    Table 15. 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 name (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  


    note

    If you are configuring communications for a Windows 3.x client, you can use the Client Setup tool to complete this task. Go to "Using the Client Setup Tool to Configure a Windows 3.x Client" to catalog a database using the Client Setup tool.

  3. If you are using a UNIX client, set up the instance environment and invoke the DB2 command line processor as follows:

    1. Run the start up script as follows:
         . INSTHOME/sqllib/db2profile    (for Bourne or Korn shell)
         source INSTHOME/sqllib/db2cshrc (for C shell)
      
      where INSTHOME is the home directory of the instance.

    2. Start the DB2 command line processor by issuing the db2 command.

  4. Catalog the database by issuing the following commands in the command line processor:
       catalog database database_name as database_alias at node node_name
       terminate
    
    For example, to catalog a remote database called sample so that it has the alias tor1, on the node db2node, use:
       catalog database sample as tor1 at node db2node
       terminate
    


    note

    If you need to change values that were set with the catalog database command, first run the uncatalog database command in the command line processor as follows:

       uncatalog database database_alias
    

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


Step 3. Test the Client-to-Server Connection

When the configuration of the server and client is complete, use the following steps to verify that you can access data from a remote database:

note

You will need to connect to a remote database to test the connection. If you do not have a database on the server, create the sample database on the server to test the connection. See "Creating the Sample Database" for more information.

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

  2. Enter the following command in the client's Command Center or command line processor to connect the client to the remote database:
       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. If the database manager is configured for CLIENT authentication, the userid and password must be valid on the client.

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 SQL command in the Command Center or command line processor:

   "select tabname from syscat.tables"

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

note

You are ready to start using the DB2 server. See Chapter 16. "Getting Started with DB2 Universal Database" for details.

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. DB2COMM can be set in the db2profile or db2cshrc file.

    Figure hint not displayed.

    Check the settings for the db2comm registry value by issuing the db2set DB2COMM command. For more information, see Chapter 21. "Controlling Your DB2 Environment".

  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 (enter the db2stop and db2start commands on the server).

  6. Ensure that you did not specify a port number that is being used by the Fast Communication Manager (FCM) or any other process.


Figure hint not displayed.

If there are problems starting a protocol's connection managers, a warning message is displayed and the error messages are logged in the db2diag.log file, located in the instance directory.

Additionally, any failure encountered while executing the db2start command is logged to a time-stamped file in the log subdirectory within the instance directory. This file contains the db2start results from each database partition server in the instance.

If there is no error when the db2start command is run, these files are removed.

Refer to the Troubleshooting Guide for information on the db2diag.log file.

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 must match, or the service name must map to, the port number used on the server.

  4. The node name (node_name), 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.

After you verify these items, refer to the Troubleshooting Guide if the connection still fails.


[ Top of Page | Previous Page | Next Page | Table of Contents | Index ]

[ DB2 List of Books | Search the DB2 Books ]