从命令行执行DB2命令到远程服务器 [英] Executing DB2 Commands from Command Line to Remote Server

查看:151
本文介绍了从命令行执行DB2命令到远程服务器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两台运行Workgroup的DB2服务器。例如,Server1和Server2。



从Server2,在命令提示符下,我想对Server1上的已知数据库运行SQL命令。



有人可以向我解释完成这一步所需的步骤。而且我只需要使用DB2ADMIN登录crendentials,还是需要设置一些其他登录?

解决方案

您需要将Server1数据库在Server2上。



您没有提到服务器是Windows还是* nix。



如果服务器是* nix,您需要使用其.profile中加载了db2可执行文件的用户登录。 (如果您不确定,请检查db2实例所有者的.profile。)



如果服务器是Windows,那么您可以以任何可以看到IBM的身份登录DB2程序组,并可以打开DB2命令窗口或类似的。



从Server2的命令行,您需要将Server1编目为TCPIP节点。该文档是这里。这可能是这样的:

  db2 catalog tcpip node server1 remote Server1 server 50000 

接下来,您需要在节点上编目数据库。该文档是 here 。这可能是这样的:

  db2目录数据库< dbname>在节点server1 

如果需要检查命令的结果,可以使用列表NODE DIRECTORY LIST DATABASE DIRECTORY 以查看db2已编目的文件。



一旦你完成了所有这些,你应该能够从Server2连接到Server1上的数据库由:

  db2连接到< dbname>用户<用户名>使用< pwd> 

连接完成后,您应该能够查询远程数据库。



此信息将保留在本地db2目录中,除非您明确删除它。 (您可以通过注销,登录并使用LIST NODE DIRECTORY或LIST DB DIRECTORY来验证)。如果要删除条目,可以使用 UNCATALOG DATABASE UNCATALOG NODE 命令。


I have two DB2 servers running Workgroup. For example, Server1 and Server2.

From Server2, at a command prompt I would like to run a SQL command against a known database on Server1.

Can someone explain to me exactly the steps I need to do in order to accomplish this. And do I simply use DB2ADMIN login for crendentials or do I need to setup some other login?

解决方案

You need to catalog the Server1 database on Server2.

You haven't mentioned if the servers are Windows or *nix.

If the servers are *nix, you need to log in with a user that has the db2 executables loaded in it's .profile. (Check the .profile of the db2 instance owner if you are not sure).

If the servers are Windows, then you can log in as anybody that can see the IBM DB2 Program Group, and can open the DB2 Command Window or similar.

From the command line on Server2 you need to catalog Server1 as a TCPIP node. The doc is here. It will probably be something like this:

db2 catalog tcpip node server1 remote Server1 server 50000

Next you need to catalog the database on the node. The doc is here. It will probably be something like this:

db2 catalog database <dbname> at node server1

If you need to check the results of the commands, you can use LIST NODE DIRECTORY or LIST DATABASE DIRECTORY to see what db2 has cataloged.

Once you have done all that you should be able to connect to the database on Server1 from Server2 by:

db2 connect to <dbname> user <username> using <pwd>

Once the connection has been made you should be able to query the remote database.

This information will stay in the local db2 catalog unless you explicitly remove it. (You can verify that by logging out, logging back in and using LIST NODE DIRECTORY or LIST DB DIRECTORY). If you want to remove the entries, you can use the UNCATALOG DATABASE and UNCATALOG NODE commands.

这篇关于从命令行执行DB2命令到远程服务器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆