Kaushik
Kaushik

Reputation: 23

Unable to connect to remote DB in db2

Facing a weird issue in DB2. Unable to connect to remote DB. Catalogued Successfully. But when tried to connect to DB alias getting a error as

"SQL30061N The database alias or database name "NDTEST " was not found at the remote node."

OS :- Linux

DB2Level :-

DB21085I  This instance or install (instance name, where applicable:
"db2inst1") uses "64" bits and DB2 code release "SQL10055" with level
identifier "0606010E".
Informational tokens are "DB2 v10.5.0.5", "s141128", "IP23633", and Fix Pack
"5".
Product is installed at "/path/to/db2".

But we did not mention anything as "NDTEST ".

Database alias                       = QAZWSXED
 Database name                        = NEWDB(changedName)
 Node name                            = BASENNEW
 Database release level               = 10.00
 Comment                              =
 Directory entry type                 = Remote
 Authentication                       = SERVER_ENCRYPT
 Catalog database partition number    = -1
 Alternate server hostname            =
 Alternate server port number         =

 Node name                      = BASENNEW
 Comment                        =
 Directory entry type           = LOCAL
 Protocol                       = TCPIP
 Hostname                       = hostname
 Service name                   = portNumber

db2 connect to QAZWSXED
SQL30061N  The database alias or database name "NDTEST         " was not
found at the remote node.  SQLSTATE=08004

Upvotes: 1

Views: 6672

Answers (2)

Kaushik
Kaushik

Reputation: 23

Found the problem - There was one entry in DCS(Database Connection Services). To check DCS details

db2 list dcs directory

above command provided a DCS entry with Target Database Name as NDTest .

Working fine after removing/un cataloguing the DCS entry.

Upvotes: 1

kkuduk
kkuduk

Reputation: 601

Error means exactly what is say - there is no NEWDB databsae on BASENNEW node.

The fact that you were able to catalog the database doesn't mean it is actually there. There is no connection attempt during the CATALOG DATABASE command (one is not prompted for password).

E.g. if I would create local TCP/IP loopback for my instance:

$ db2 catalog tcpip node loop remote localhost server  61115

I can with no issues catalog both existing (SAMPLE) and non-existing database (BADDB):

$ db2 catalog database sample as loopsamp at node loop
DB20000I  The CATALOG DATABASE command completed successfully.
DB21056W  Directory changes may not be effective until the directory cache is 
refreshed.
$ db2 catalog database baddb as loopbad at node loop
DB20000I  The CATALOG DATABASE command completed successfully.
DB21056W  Directory changes may not be effective until the directory cache is 
refreshed.

I will be able to connect to the first one:

Enter current password for kkuduk: 

   Database Connection Info
 Database server        = DB2/LINUXX8664 11.5.0.0
 SQL authorization ID   = KKUDUK
 Local database alias   = LOOPSAMP

but connection attempt to non-existing one will fail with SQL30061N

db2 connect to loopbad user kkuduk
Enter current password for kkuduk: 
SQL30061N  The database alias or database name "BADDB             " was not 
found at the remote node.  SQLSTATE=08004

Please verify the node directory on the remote server by runnnig

$ db2 list db directory 

and see if you have an entry for your database which has type Indirect

Directory entry type                 = Indirect

Edit: I didn't notice your edit that changed the database name. If error returns stalled database name then indeed db2 terminate is needed to create new CLP client application (db2bp).

E.g. if I would uncatalog incorrect entry and cataloged it again I will get similar error as client will use cached entry pointing to incorrect database name:

$ db2 uncatalog db LOOPBAD
DB20000I  The UNCATALOG DATABASE command completed successfully.
DB21056W  Directory changes may not be effective until the directory cache is 
refreshed.
$ db2 catalog database sample as loopbad at node loop
DB20000I  The CATALOG DATABASE command completed successfully.
DB21056W  Directory changes may not be effective until the directory cache is 
refreshed.
$ db2 connect to loopbad user kkuduk
Enter current password for kkuduk: 
SQL30061N  The database alias or database name "BADDB             " was not 
found at the remote node.  SQLSTATE=08004

db2 terminate terminates the Db2 CLP client back end and reads correctly new entry from the catalog:

$ db2 terminate
DB20000I  The TERMINATE command completed successfully.
$ db2 connect to loopbad user kkuduk
Enter current password for kkuduk: 

   Database Connection Information

 Database server        = DB2/LINUXX8664 11.5.0.0
 SQL authorization ID   = KKUDUK
 Local database alias   = LOOPBAD

Upvotes: 1

Related Questions