database DB2 无法连接到服务器
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 
原文地址: http://stackoverflow.com/questions/17088241/
Warning: these are provided under cc-by-sa 4.0 license.  You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
DB2 can't connect to the server
提问by Alex
I am tring to set up a db2 server on a Windows 7 machine and I cant connect to database from remote, only from local. I think I might miss some configuration.
我正在尝试在 Windows 7 机器上设置 db2 服务器,但我无法从远程连接到数据库,只能从本地连接。我想我可能会错过一些配置。
1) I turned off the firewall 2) my database information is:
1) 我关闭了防火墙 2) 我的数据库信息是:
Database 2 entry:
数据库 2 条目:
 Database alias                       = SAMPLE
 Database name                        = SAMPLE
 Local database directory             = C:
 Database release level               = f.00
 Comment                              =
 Directory entry type                 = Indirect
 Catalog database partition number    = 0
 Alternate server hostname            =
 Alternate server port number         =
Part of the output from netstat -acommand is:
netstat -a命令的部分输出是:
  TCP    [::]:49155             WIN-whatever:0      LISTENING
  TCP    [::]:49164             WIN-whatever:0      LISTENING
  TCP    [::]:49165             WIN-whatever:0      LISTENING
  TCP    [::]:50000             WIN-whatever:0      LISTENING
From the client if I ping my server it does not respond
Also if I scan it with nmap -sV <server_ip_address>it doesn't return me open ports and services which use it
从客户端,如果我 ping 我的服务器,它不会响应此外,如果我用nmap -sV <server_ip_address>它扫描它,它不会返回我打开的端口和使用它的服务
From the client, to connect, I run the following commands:
从客户端连接,我运行以下命令:
db2 list node directory
SQL1027N  The node directory cannot be found.
catalog tcpip node <i am not sure what does here> remote <server_ip_address> server <port_number> 
no output
this implies that something is wrong. I tried couple of things for node and nothing works I am have no idea what is going on and how to fix it.
这意味着有些事情是错误的。我为节点尝试了几件事,但没有任何效果我不知道发生了什么以及如何解决它。
Thank you for help
谢谢你的帮助
回答by mustaccio
First of all, the fact that you cannot ping the server and nmapdoesn't see the open ports means your problem, at least at this point, lies outside DB2. Once you fix your network issues, here's the procedure you can follow to set up remote connectivity to a DB2 database via TCP/IP.
首先,您无法 ping 服务器并且nmap看不到开放端口这一事实意味着您的问题,至少在这一点上,存在于 DB2 之外。修复网络问题后,您可以遵循以下过程来设置通过 TCP/IP 与 DB2 数据库的远程连接。
1) Optional. You can use either a service name or a port number to configure the DB2 instance. If you want to use the service name, on the serveradd a line to /etc/servicessimilar to db2c_db2inst1       50000/tcp, which assigns the service name "db2c_db2inst1" to the port 50000.
1) 可选。您可以使用服务名称或端口号来配置 DB2 实例。如果要使用服务名称,请在服务器上添加/etc/services类似于的行db2c_db2inst1       50000/tcp,将服务名称“db2c_db2inst1”分配给端口 50000。
2) On the serverupdate the DB2 instance configuration: db2 update dbm cfg using svcename db2c_db2inst1(or db2 update dbm cfg using svcename 50000if not using the service name). To verify: db2 get dbm cfg | grep SVCENAME.
2)在服务器上更新 DB2 实例配置:(db2 update dbm cfg using svcename db2c_db2inst1或者db2 update dbm cfg using svcename 50000如果不使用服务名称)。验证:db2 get dbm cfg | grep SVCENAME.
3) On the serverupdate the DB2 registry variable: db2set DB2COMM=TCPIP. To verify: db2set DB2COMM.
3)在服务器上更新 DB2 注册表变量:db2set DB2COMM=TCPIP. 验证:db2set DB2COMM.
4) On the serverrestart the instance: issue db2stop force, then db2start.
4)在服务器上重启实例: issue db2stop force,然后db2start.
5) On the remote client, assuming the DB2 client software is installed, issue db2 catalog tcpip node whatever remote <your server IP address> service <your DB2 port number>. Note that the node name ("whatever" in this example) is limited to 8 ASCII characters.
5)在远程客户端上,假设安装了 DB2 客户端软件,发出db2 catalog tcpip node whatever remote <your server IP address> service <your DB2 port number>. 请注意,节点名称(在此示例中为“whatever”)限制为 8 个 ASCII 字符。
6) On the remote clientissue db2 catalog database <your database name> at node whatever, referring to the node name ("whatever") that you defined in step 5.
6)在远程客户端问题上db2 catalog database <your database name> at node whatever,参考您在步骤 5 中定义的节点名称(“随便”)。
7) On the remote clientverify connectivity: db2 connect to <your database name> user <user name> using <password>
7)在远程客户端验证连通性:db2 connect to <your database name> user <user name> using <password>
回答by AngocA
Try to do a telnet on the instance port to check that everything is right from the client to the server
尝试在实例端口上执行 telnet 以检查从客户端到服务器的一切是否正确
telnet DB2-Server-name 50000
Where DB2-Server-name is the server name or IP address. Make sure you can get the server. 50000 is the most often DB2 port, but you have to check the configuration.
其中 DB2-Server-name 是服务器名称或 IP 地址。确保您可以获得服务器。50000 是最常用的 DB2 端口,但您必须检查配置。
Once you get connection to the server, you can configure the node with the previous answer.
连接到服务器后,您可以使用先前的答案配置节点。

