无法连接到db2中的远程数据库

时间:2019-12-03 13:09:34

标签: db2 db2-luw

面对DB2中一个奇怪的问题。无法连接到远程数据库。 已成功编目。但是当尝试连接到数据库别名时,出现错误

  

“ SQL30061N数据库别名或数据库名称“ NDTEST”不是   在远程节点上找到。”

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

但是我们没有提到任何东西“ 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

2 个答案:

答案 0 :(得分:1)

错误意味着确切的意思-BASENNEW节点上没有NEWDB数据库。

您能够对数据库进行分类的事实并不意味着它实际上已经存在。 CATALOG DATABASE命令期间没有尝试连接(不提示输入密码)。

例如如果我要为我的实例创建本地TCP / IP环回:

$ db2 catalog tcpip node loop remote localhost server  61115

我可以毫无问题地对现有数据库(SAMPLE)和不存在数据库(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.

我将能够连接到第一个:

Enter current password for kkuduk: 

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

但是尝试与不存在的连接的连接将失败,并使用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

请通过runnnig验证远程服务器上的节点目录

$ db2 list db directory 

并查看您的数据库是否有一个类型为间接

的条目
Directory entry type                 = Indirect

编辑: 我没有注意到您所做的修改更改了数据库名称。如果错误返回停止的数据库名称,则确实需要db2 terminate来创建新的CLP客户端应用程序(db2bp)。

例如如果我将不正确的条目取消目录并再次分类,我将得到类似的错误,因为客户端将使用指向错误数据库名称的缓存条目:

$ 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终止Db2 CLP客户端后端,并从目录中正确读取新条目:

$ 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

答案 1 :(得分:1)

发现问题-DCS(数据库连接服务)中只有一个条目。查看DCS详细信息

db2列表dcs目录

以上命令提供了一个DCS条目,其目标数据库名称为NDTest。

删除/取消对DCS条目的分类后,工作正常。