Executing DB2 Commands from Command Line to Remote Server

前端 未结 1 1920
自闭症患者
自闭症患者 2021-01-01 03:43

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 data

相关标签:
1条回答
  • 2021-01-01 04:11

    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.

    0 讨论(0)
提交回复
热议问题