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

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

问题描述

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

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

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

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

有人可以准确地向我解释我需要执行哪些步骤才能完成此任务.我是简单地使用 DB2ADMIN 登录来获取凭据,还是需要设置其他登录方式?

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?

推荐答案

您需要在 Server2 上对 Server1 数据库进行编目.

You need to catalog the Server1 database on Server2.

你没有提到服务器是 Windows 还是 *nix.

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

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

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

如果服务器是 Windows,那么您可以以任何可以看到 IBM DB2 Program Group 并可以打开 DB2 命令窗口或类似工具的人身份登录.

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.

从 Server2 上的命令行,您需要将 Server1 编目为 TCPIP 节点.该文档是 这里.大概是这样的:

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

如果需要查看命令结果,可以使用列出节点目录LIST DATABASE DIRECTORY 以查看 db2 已编目.

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.

完成所有操作后,您应该能够通过以下方式从 Server2 连接到 Server1 上的数据库:

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.

除非您明确将其删除,否则此信息将保留在本地 db2 目录中.(您可以通过注销、重新登录并使用 LIST NODE DIRECTORY 或 LIST DB DIRECTORY 来验证这一点).如果要删除条目,可以使用 UNCATALOG DATABASEUNCATALOG NODE 命令.

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天全站免登陆