when accessing the server-side database from the client in DB2, the Connect command cannot be used directly, and the communication node must be established, and then the database connection can be established on node basis . The specific actions on the command line are as follows:
->DB2 catalog TCPIP Node ABC remote serverName server 50000
->DB2 Catalog db databaseName at node ABC
->DB2 Connect to DatabaseName user Uid using PWD
Description
The ABC in catalog TCPIP node ABC is a knot named by you, and the knot name cannot be repeated with the existing knot name.
Catalog DB databaseName at node ABC refers to the knot name you started in the front.
ServerName Server name (remote database)
DatabaseName database name
Uid User Name
PWD Password
In addition, if the client has already established node with the same server, then if you want to connect to another database on the server, you do not need to create another node, just use the same node. In addition, the port after the server name is set up is not necessarily 50000, to see the DB engineers at the time of the setup.
Related instructions:
DB2 List DB directory lists accessible db
DB2 List node directory lists accessible nodes
Some of the other important DB2 commands
1. View the Local node directory
Command Window ENTER: DB2 list node Directory
2. Cataloging a TCP/IP node
Command window: DB2 catalog TCPIP node <node_name> remote
3. Cancel the node catalog
DB2 uncatalog Node <node_name>
4. View the System database directory
DB2 List Database Directory
5. View the local database directory
DB2 List Database directory on < letter >
A database in the local database directory that is not available in the System database directory can be accessed by selecting < database > right-clicking in the control center and then entering the database name you want to add or clicking the Refresh button to select the database.
6. Catalogue Database
DB2 Catalog Database <db_name> as <db_alias> at node <node_name>
7. Cancel the database catalog
DB2 Uncatalog Database <db_name>
8. Testing the connection of a remote database
DB2 Connect to <db_alias> user <user_id> using <password
Windows DB2 Port View/Modify/Assign
1. Port View
1. On the DB2 command line, run: DB2 get DBM CFG | Find "SVCENAME", you will get the following output:
TCP/IP Service name (SVCENAME) = DB2C_DB2
2. Open C:/windows/system32/drivers/etc/services and view the port number for the service name found in 1, such as:
DB2C_DB2 50000/tcp 2. Port Modifications
directly modify the corresponding port in the ttc/services. Then Db2stop, Db2start can be.
You can check whether it is started by Telnet Ip:port. 3. Assigning ports to new instance
1. Add Service: Edit etc/services file, add service name and port, such as increase:
Db2c_myinst 50006/tcp
2. Allocation Port:
DB2 UPDATE DBM CFG USING SVCENAME db2c_myinst
Linux/unix down DB2 Port View
DB2 Get dbm CFG | Grep-i Service
Find the corresponding port number grep in the/etc/services file with the output of the previous command (such as Db2c_db2inst1) db2c_db2inst1/etc/services
This is what you will see in this line from the last sentence of the output db2c_db2inst1 50000/tcp
50000 of which is the DB2. Occupy the port number