Cataloging database
In this post, I will show how to
catalog and access remote databases on Linux/UNIX machine.
Below are details of my instances, database and port number
Remote instance name: db2inst1
Remote database name: SAMPLE
Remote instance port number: 50001
Local instance name: db2inst3
Local database name: MAVA
I will make an attempt to catalog remote database SAMPLE residing in db2inst1
instance and will establish a connection to the remote database from my local
instance db2inst3.
For cataloging a database, one should have
1<hostname> -- hostname or IP address of
the server on which remote instance is running,
2<port number> -- port number of the remote
instance and
3<remotedbname> -- remote database name.
You can use below syntax, and substitute appropriate values to prepare
the commands
Syntax
db2 “catalog tcpip node <nodename> remote <hostname> server
<port number>”
Syntax
db2 “catalog db <remotedbname> as <remotedb alias> at node
<nodename>”
<nodename> is the local nickname you want
to set for the remote server (<hostname> above)
<remotedb alias> is the local nickname you want to set for remote database name.
Command
to be executed db2 "catalog tcpip node MAVAINST remote
db2v10 server 50001"
Command
to be executed db2 "catalog db SAMPLE as SAMPLE at node
MAVAINST"
Command
db2inst3@db2v10:~> db2 -v "list node directory"
list node directory
This is to list the node directory before cataloging.
Command
db2inst3@db2v10:~> db2 -v "list db directory"
list db directory
This is to list system database directory which
has one local(Indirect) database at this moment.
Command
db2inst3@db2v10:~> db2 -v "catalog tcpip node MAVAINST remote db2v10
server 50001"
catalog tcpip node MAVAINST remote db2v10 server 50001
Command
db2inst3@db2v10:~> db2 -v "catalog db SAMPLE as SAMPLE at node
MAVAINST"
catalog db SAMPLE as SAMPLE at node MAVAINST
DB20000I The CATALOG DATABASE
command completed successfully.
DB21056W Directory changes may not
be effective until the directory cache is
refreshed.
This is to catalog the
instance db2inst1 running at port number 50001 with nodename as MAVAINST and
database SAMPLE as SAMPLE.
Command
db2inst3@db2v10:~> db2 -v "list node directory"
list node directory
This is to list node directory after cataloging node.
Command
db2inst3@db2v10:~> db2 -v "list db directory"
list db directory
Command
db2inst3@db2v10:~> db2 -v "connect to SAMPLE user maruti"
Enter current password for maruti:
connect to SAMPLE user maruti
You can now see the cataloged remote database SAMPLE listed as 'Remote' in System database directory and the user 'maruti' trying to access the database SAMPLE by providing a password.
In order to connect to the cataloged remote database, ensure
In order to connect to the cataloged remote database, ensure
- DB2COMM = TCPIP is set
- connection is established using Database alias and user name which has connect privilege on remote database
Hope this helps!!!
No comments:
Post a Comment