tnsping ping 失败,即使我可以成功连接到数据库

发布于 2024-10-14 10:21:35 字数 1180 浏览 3 评论 0原文

在尝试建立从我的工作站(实际上,我在 WinXP32 和 Win764 工作站上看到相同的行为)到 Oracle 服务器的连接时,我总是尝试的第一件事是 tnsping。当我这样做时,这就是我得到的结果:

> C:\>tnsping MYDBNAME
> 
> TNS Ping Utility for 32-bit Windows:
> Version 10.2.0.1.0 - Production on
> 25-JAN-2 011 15:03:35
> 
> Copyright (c) 1997, 2005, Oracle.  All
> rights reserved.
> 
> Message 3511 not found; No message
> file for product=NETWORK,
> facility=TNSMessage  3512 not found;
> No message file for product=NETWORK,
> facility=TNSAttempting to contact
> (DESCRIPTION = (ADDRESS_LIST =
> (ADDRESS = (PROTOCOL = TCP) (HOST =
> thisismyservername.com)(PORT = 1577)))
> (CONNECT_DATA = (SID = MYDBNAME)))
> Message 3509 not found; No message
> file for product=NETWORK, facility=TNS

所以,正如您所看到的,它正确地检测我的 tnsnames 文件,并为指定的数据库选取正确的服务器地址和端口,但 tnsping 失败并出现 3511 和 3509 错误。

奇怪的是,使用 sqlplus 或 Toad,从同一个工作站,我可以成功连接到同一个数据库。

谁能解释这里发生了什么?

FWIW:

ORACLE_HOME 系统环境变量(以及任何其他 Oracle 环境变量)设置。

更新

ORACLE_HOME 环境变量不一定必须设置,它似乎以某种方式取决于每台机器。我的具体问题是:Oracle 10g 有一个已知缺陷,即 tnsping.exe 根本无法工作。有补丁

In trying to establish connectivity from my workstation (actually, am seeing the same behavior on both WinXP32 and Win764 workstations) to an Oracle server, the first thing I always try is a tnsping. When I do so, this is what I get:

> C:\>tnsping MYDBNAME
> 
> TNS Ping Utility for 32-bit Windows:
> Version 10.2.0.1.0 - Production on
> 25-JAN-2 011 15:03:35
> 
> Copyright (c) 1997, 2005, Oracle.  All
> rights reserved.
> 
> Message 3511 not found; No message
> file for product=NETWORK,
> facility=TNSMessage  3512 not found;
> No message file for product=NETWORK,
> facility=TNSAttempting to contact
> (DESCRIPTION = (ADDRESS_LIST =
> (ADDRESS = (PROTOCOL = TCP) (HOST =
> thisismyservername.com)(PORT = 1577)))
> (CONNECT_DATA = (SID = MYDBNAME)))
> Message 3509 not found; No message
> file for product=NETWORK, facility=TNS

So, as you can see, it is properly detecting my tnsnames file, and picks up the correct server address and port for the specified database, but the tnsping fails with 3511 and 3509 errors.

The strange part is, using sqlplus or Toad, from the same workstation, I can connect to that very same database successfully.

Can anyone explain what is happening here?

FWIW:

The ORACLE_HOME system environment variable (and any other oracle environment variables) is not set.

Update

The ORACLE_HOME environment variable does not necessarily HAVE to be set, it seems to depend per machine somehow. My particular issue was: Oracle 10g has/had a known defect in that tnsping.exe simply didn't work. There is a patch

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

沫尐诺 2024-10-21 10:21:35

我相信当您的 ORACLE_HOME 环境变量设置不正确时,可能会发生这种情况。 tnsping 仍可从 PATH 获取,但无法找到其消息文件。 echo %ORACLE_HOME% 显示什么,Oracle 客户端实际安装在哪里?

这不一定会对 Toad 的访问产生任何影响,因为它不需要直接访问 ORACLE_HOME;您可能已经给出了完整的连接字符串,或者如果设置了 TNS_ADMIN,它可能能够获取服务名称。

编辑
您还可能有多个相互干扰的 Oracle 产品。如果是这样,请尝试转到“开始”->“所有程序”->“Oracle 安装产品”->“主选择器”,然后选择与您正在执行的 tnsping 相关的程序。 (实际上这是针对 9i 客户端的;我认为对于 10g,您可能需要使用通用安装程序,通过“已安装产品”->“环境”进行更改,但无法检查)。

I believe this can happen when your ORACLE_HOME environment variable is not set properly. tnsping is still available from the PATH, but it can't find its message files. What does echo %ORACLE_HOME% show, and where is the Oracle client actually installed?

This wouldn't necessarily have any effect on access from Toad as it doesn't need to access ORACLE_HOME directly; you may have given a full connection string, or it may be able to pick up a service name if TNS_ADMIN is set.

Edit
You might also have several Oracle products that are interfering with each other. If so try going to Start->All programs->Oracle Installation Products->Home Selector and picking the one that is related to the tnsping you're executing. (Actually this is for the 9i client; I think for 10g you might need to use the universal installer, changing via Installed Products->Environment, but can't check).

讽刺将军 2024-10-21 10:21:35

除了设置 ORACLE_HOME 变量之外,您还应该确保 c:\orant\bin;条目出现在您可能已安装的其他 Oracle 客户端的任何其他路径条目之前。

In addition to setting the ORACLE_HOME variable you should also make sure that the c:\orant\bin; entry comes before any other path entries to other oracle clients you may have installed.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文