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

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/4799432/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-09 08:00:56  来源:igfitidea点击:

tnsping ping fails, even though I can successfully connect to database

windowsoraclewindows-7windows-xp

提问by tbone

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:

在尝试建立从我的工作站(实际上,我在 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

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.

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

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

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

Can anyone explain what is happening here?

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

FWIW:

FWIW:

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

设置ORACLE_HOME 系统环境变量(和任何其他 oracle 环境变量)。

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

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

采纳答案by Alex Poole

I believe this can happen when your ORACLE_HOMEenvironment variable is not set properly. tnspingis 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?

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

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

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

EditYou 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 tnspingyou'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).

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

回答by PricklyApps

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.

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