Sie sind auf Seite 1von 6

DB2 Enablement Workshop

LAB 4 Client Connectivity


Estimated duration: 45 minutes This lab will help you solidify basic concepts of DB2 client connectivity. It is to be completed following the presentation DB2 Client Connectivity. Prerequisites: DB2 UDB Version 8.1.2 or higher has been installed (DB2 Express preferred) Remote DB2 Server is running 1. Issue the following command in the CLP: db2 => catalog tcpip node nodeX remote 192.168.9.99 server 54321 Note: The remote IP and port number does not exist. That is the intention of this step. Identify the following information from the above command: Local alias for remote instance _______________ Remote hostname/machine IP : _______________ Remote instances protocol: _______________ Remote instances port number: _______________ View the node entry created: db2 => list node directory Key Lesson: Network connections are considered unreliable. Therefore, DB2 allows you to catalog nodes that do not immediately exist 2. In the previous step, we purposely cataloged a node that does not exist to demonstrate a VERY common error encountered by new DB2 users. What is the error code message when you attempt the following command (This usually takes about 2 minutes to timeout) db2 => attach to nodeX user <userid> using <password> SQLCODE: Error Message: ___________________________________________________ ___________________________________________________ ____________________

EWLab4_Client_Connectivity.doc

Page 1 of 6

DB2 Enablement Workshop


LAB 4 Client Connectivity
Key Lesson: If you see this error, youve either cataloged the remote NODE wrong or the server has not been set up properly for remote client access. What is the difference between ATTACH and CONNECT? ______________________________________________________ ______________________________________________________ ______________________________________________________ 3. Remove the invalid node entry: db2 => uncatalog node nodeX 4. Verify that the requirements for remote connectivity for YOUR database server are met (since others may connect to your machine in the next few steps). Very likely, your default instance is set up correctly. This is more of an exercise of the validation process. Check #1) Has the DB2COMM registry variable been set to TCPIP? db2set all If not, set it db2set DB2COMM=tcpip Check #2) Has the service name parameter (SVCENAME) in the DBM CFG been set? db2 get dbm cfg If not, set it to a unique port number db2 update dbm cfg using svcename 50000 If you had to make any configuration settings, you will need to restart the instance before continuing. 5. You will now attempt to connect to a remote database server. Ask your neighbor (or instructor) for the following information: Remote Database Info: (PR) Protocol (IP) IP Address or hostname (PN) Instance Port Number (DB) Database Name

____________ ____________ ____________ _SAMPLE ___

EWLab4_Client_Connectivity.doc

Page 2 of 6

DB2 Enablement Workshop


LAB 4 Client Connectivity

6. Setup your client to connect remotely issuing the following commands: db2 => catalog admin PR node <admin_node_alias> remote IP db2 => catalog PR node <node_alias> remote IP server PN db2 => catalog database DB as <db_alias> at node <node_alias> Note: Substitute PR, IP, PN, and DB with the values collected in the previous step and pick your own values for: admin_node_alias, node_alias, and db_alias. Node and database aliases are limited to 8 characters Quick question: If a remote machine has two instances, each with their own database: a) How many node directory entries are required at the client? ________ b) How many admin node entries are required at the client? ________ 7. Verify your client configuration: db2 => list admin node directory db2 => list node directory db2 => list db directory 8. Verify that you can attach to the remote node and connect to the remote database db2 => attach to <node_alias> user <userid> using <password> db2 => connect to <db_alias> user <userid> using <password> Why is the userid and password required (by default) for ATTACH and CONNECT for remote instances and remote databases? __________________________________________________________________

9. On AIX and Linux, to work around a 32-bit architecture shared memory limitation, a LOOPBACK node is sometimes needed to support a larger number of local database connections. Perform the following as an exercise, even if you are not using AIX or Linux at this time: db2 => catalog admin tcpip node loopadm remote 127.0.0.1 db2 => catalog tcpip node loopback remote 127.0.0.1 server 50000 db2 => catalog database sample as loopsamp at node loopback db2 => connect to loopsamp user <userid> using <password>
EWLab4_Client_Connectivity.doc Page 3 of 6

DB2 Enablement Workshop


LAB 4 Client Connectivity
Key Lesson: Connecting to loopsamp is like connecting to a remote database, even though the database is actually local! 10. Clean up your client node and database directories: db2 => uncatalog node loopadm db2 => uncatalog node loopback db2 => uncatalog db loopsamp db2 => uncatalog db <remote_db> db2 => uncatalog node <remote_node> db2 => uncatalog node <remote_admin_node> Before proceeding to the next step, compare your answers to those in the solution 11. In this lab, you have learned how to manually set up client connectivity. The DB2 Client Configuration Assistant simplifies the task by automatically discovering remote databases and issuing the appropriate CATALOG commands for you. See how much easier it can be! Practice setting up remote connectivity using the DB2 Client Configuration Assistant. Windows: Start > Programs > IBM DB2 > Setup Tools > Configuration Assistant Linux: Open the IBM DB2 folder on your desktop and launch Configuration Assistant

EWLab4_Client_Connectivity.doc

Page 4 of 6

DB2 Enablement Workshop


LAB 4 Client Connectivity

12. Right clicking anywhere on the Configuration Assistant to invoke the Add Database Wizard 13. Follow these steps: Step 1 select Search the Network Step 2 double-click Other Systems (Search the Network). There may be a slight delay as it waits for remote DB2 systems to respond. Then, select the desired remote database to catalog. Step 3 Database Alias: RMT_SAMP (you already have a local SAMPLE database) Step 4 Click Finish 14. Test your connection to the remote database. Be sure to provide a userid and password that is valid on the REMOTE system.

LAB 4 SOLUTION
2. SQLCODE: SQL30081N

EWLab4_Client_Connectivity.doc

Page 5 of 6

DB2 Enablement Workshop


LAB 4 Client Connectivity
Error Message:
SQL30081N A communication error has been detected. Communication protocol being used: "TCP/IP". Communication API being used: "SOCKETS". Location where the error was detected: "". Communication function detecting the error: "connect". Protocol specific error code(s): "10060", "*", "*". SQLSTATE=08001

What is the difference between ATTACH and CONNECT? When working from a remote client, to administer a remote instance, you must first ATTACH to it. However, if you want to work with databases, whether local or remote, you must CONNECT to it. 6. If a remote machine has two instances, each with their own database: a) How many node directory entries are required at the client? 2 b) How many admin node entries are required at the client? 1 8. Why is the userid and password required (by default) for ATTACH and CONNECT for remote instances and remote databases? The default value of the AUTHENTICATION parameter on the DB2 servers DBM CFG is SERVER. That is, authentication uses userids and password defined or resolvable at the server.

EWLab4_Client_Connectivity.doc

Page 6 of 6