I have two instances on two separate AIX servers. Both DB2 databases are up with their sample databases. I want to connect with one DB2 instance from the other instance.
I am new on DB2 and want to know how can I do that.
I have executed following commands:
This path is client instance:
#. /home/db2inst2/sqllib/db2profile
db2 catalog tcpip node db2serverinst remote lpar1 server 50005 remote_instance ctginst1
db2 => terminate
DB20000I The TERMINATE command completed successfully.
# db2 connect to db2serverinst user ctginst1
Enter current password for ctginst1: SQL1031N The database directory cannot be found on the indicated file system.
SQLSTATE=58031
The term "Connect to an instance" is not correct. The correct one is to attach:
If you want to execute commands from Machine A into Machine B, you have to catalog db2inst2 AND/OR db2inst3 in db2inst1 (catalog tcpip node). Remember that you have to give different names to each cataloged object.
Once you have cataloged a remote instance, you could also issue database commands, but you have to catalog remote databases. You can have a remote sample, and a local sample, but alias should be different.
If you cataloged db2inst2 instance as db2inst2 node in local node from Machine A. And you cataloged sample database as sample-2 alias in local node from Machine A. You could execute in Machine A.
Attach is for 'administrative' things, like list applciations, create db, etc. Connect is to use the database.
You have only cataloged DB2 instance. You need to catalog the database at the remote server:
Obviously, you'll need to replace the
XXXX
with the actual name of the remote database. Once you've cataloged the database, you can then connect:Note, this only defines the connection. You won't be able to access objects within this remote database from other databases within the local instance without configuring federation.