oracle tnsconnect 显示操作超时
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/21026205/
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
tnsconnect shows operation timeout
提问by Krzysztof Kazmierczyk
Here is my use case:
这是我的用例:
- We are using virtual machine. Couple of days ago I have created new Oracle database. I cloned this machine and it got different IP address.
- Today I wanted to connect to the database using SQLPlus but I go connection timeout. I have tried tnsping command and here is the output of that command:
C:\Users\Administrator>tnsping clm
TNS Ping Utility for 64-bit Windows: Version 11.2.0.1.0 - Production on 09-JAN-2 014 08:36:31
Copyright (c) 1997, 2010, Oracle. All rights reserved.
Used parameter files: C:\app\Administrator\product\11.2.0\dbhome_1\network\admin\sqlnet.ora
Used EZCONNECT adapter to resolve the alias Attempting to contact (DESCRIPTION=(CONNECT_DATA=(SERVICE_NAME=))(ADDRESS=(PROTO COL=TCP)(HOST=9.142.60.187)(PORT=1521))) TNS-12535: TNS:operation timed out
- 我们正在使用虚拟机。几天前,我创建了新的 Oracle 数据库。我克隆了这台机器,它得到了不同的 IP 地址。
- 今天我想使用 SQLPlus 连接到数据库,但连接超时。我试过 tnsping 命令,这是该命令的输出:
C:\Users\Administrator>tnsping clm
适用于 64 位 Windows 的 TNS Ping 实用程序:版本 11.2.0.1.0 - 生产于 09-JAN-2 014 08:36:31
版权所有 (c) 1997、2010,甲骨文。版权所有。
使用的参数文件:C:\app\Administrator\product\11.2.0\dbhome_1\network\admin\sqlnet.ora
使用 EZCONNECT 适配器解析别名尝试联系 (DESCRIPTION=(CONNECT_DATA=(SERVICE_NAME=))(ADDRESS=(PROTO COL=TCP)(HOST=9.142.60.187)(PORT=1521))) TNS-12535: TNS:操作超时
What is weird, that the current database address is different than 9.142.60.187. sqlnet.ora also does not contain any interesting data:
奇怪的是,当前的数据库地址与 9.142.60.187 不同。sqlnet.ora 也不包含任何有趣的数据:
SQLNET.AUTHENTICATION_SERVICES= (NTS)
NAMES.DIRECTORY_PATH= (TNSNAMES, EZCONNECT) ? ADR_BASE = C:\app\Administrator\product\11.2.0\dbhome_1\log
SQLNET.AUTHENTICATION_SERVICES= (NTS)
NAMES.DIRECTORY_PATH= (TNSNAMES, EZCONNECT) ? ADR_BASE = C:\app\Administrator\product\11.2.0\dbhome_1\log
How can I make my connection to sqlplus available? What is interesting, I am able to connect to the database using jdbc driver and it works fine.
如何使与 sqlplus 的连接可用?有趣的是,我能够使用 jdbc 驱动程序连接到数据库并且工作正常。
回答by Guido Leenders
Your sqlnet.ora is configured to first try to use TNSNAMES (tnsnames.ora in your TNS_ADMIN directed folder as defined in registry, environment variable or taken from default location) to resolve clm
to a path through your network mapping SQL*Net to TCP/IP and possibly others.
您的 sqlnet.ora 配置为首先尝试使用 TNSNAMES(TNS_ADMIN 定向文件夹中的 tnsnames.ora,如在注册表、环境变量中定义或从默认位置获取)解析clm
为通过网络映射 SQL*Net 到 TCP/IP 的路径可能还有其他人。
From your tnsping that seems not to resolve. Therefore, SQL*Net tries the second one: EZCONNECT. See Oracle docs on that one.
从您的 tnsping 看来,似乎无法解决。因此,SQL*Net 尝试第二个:EZCONNECT。请参阅有关该文档的 Oracle 文档。
Probably you are using somewhere an EZCONNECT connection string like user/pwd@//9.142.60.187 without service name and port. Or my knowledge of EZCONNECT is too simple; somehow it seems to translate clm
into //9.142.60.187
. That might be explained by the answer to the following question: Do you have a hostname clm
in DNS or hosts file mapping to 9.142.60.187?
可能您在某处使用了 EZCONNECT 连接字符串,如 user/pwd@//9.142.60.187 没有服务名称和端口。或者我对EZCONNECT的了解太简单了;不知何故,它似乎转化clm
为//9.142.60.187
. 这可以通过以下问题的答案来解释:您clm
在 DNS 或主机文件中是否有映射到 9.142.60.187的主机名?
I do not recommend using EZCONNECT, I always like to have tnsnames.ora hard coded, specifying everything needed. EZCONNECT can work nonetheless.
我不推荐使用 EZCONNECT,我总是喜欢对 tnsnames.ora 进行硬编码,指定所需的一切。尽管如此,EZCONNECT 仍然可以工作。
Can you include IP address of clone in your sample?
你能在你的样本中包含克隆的 IP 地址吗?
Can you include outcome of ping clm
and nslookup clm
in your sample?
您可以包括的结果ping clm
和nslookup clm
你的样品?
回答by Alex Poole
Since tnsping clm
is using EZConnect, your tnsnames.ora
does not have an connection alias called CLM
, but clm
is being resolved as a host name to 9.142.60.187
. It's using port 1521 by default as it has no instructions to use a specific port. The connection to that address, or at least that port, is then timing out - it might not exist, it might route somewhere unreachable, or it might be blocked by a firewall.
由于tnsping clm
使用的是 EZConnect,您tnsnames.ora
没有名为 的连接别名CLM
,但clm
正在作为主机名解析为9.142.60.187
。它默认使用端口 1521,因为它没有使用特定端口的说明。到那个地址的连接,或者至少那个端口,然后超时——它可能不存在,它可能路由到某个无法访问的地方,或者它可能被防火墙阻止。
ping clm
should show the same address, and will probably also time out. That host may exist in your hosts
file, or is being resolved by DNS, possible with a default domain appended, which ping
would also show. If it is the name of your old server, you might need to update your hosts
file, which might magically make it start working.
ping clm
应该显示相同的地址,并且可能也会超时。该主机可能存在于您的hosts
文件中,或者正在由 DNS 解析,可能附加了默认域,这ping
也会显示。如果它是您旧服务器的名称,您可能需要更新您的hosts
文件,这可能会神奇地使其开始工作。
If your database is actually called CLM
then you can create an entry in your tnsnames.ora
that points to the correct IP address for your listener, which your JDBC connection is already using. Or you can use the EZConnect format as your connect string; something like sqlplus user/password@//<your IP>:1521/<your service name>
. You can use lsnrctl services
to check the IP address, port and service name if you aren't sure.
如果您的数据库被实际调用,CLM
那么您可以在您的数据库中创建一个条目,该条目tnsnames.ora
指向您的侦听器的正确 IP 地址,您的 JDBC 连接已经在使用该地址。或者您可以使用 EZConnect 格式作为连接字符串;类似的东西sqlplus user/password@//<your IP>:1521/<your service name>
。lsnrctl services
如果您不确定,您可以使用它来检查 IP 地址、端口和服务名称。
If you're on the same host as the database then you don't need to do either; presumably you're currently trying sqlplus user/password@clm
, but if ORACLE_SID
is set you can just do sqlplus user/password
and it will not trouble the listener.
如果您与数据库在同一台主机上,那么您也不需要这样做;大概您目前正在尝试sqlplus user/password@clm
,但是如果ORACLE_SID
设置了,您就可以这样做sqlplus user/password
,并且不会给听众带来麻烦。
回答by San
Change the ip address in (HOST=9.142.60.187)
to the current ip address of server. May be in the JDBC driver you are using host name instead of ip address and that's why it is working. You can also try giving host name in (HOST=9.142.60.187)
, e.g if host name is ora_server then change it to (HOST=ora_server)
将 ip 地址更改(HOST=9.142.60.187)
为服务器当前的 ip 地址。可能在 JDBC 驱动程序中您使用的是主机名而不是 ip 地址,这就是它工作的原因。您也可以尝试在 中提供主机名(HOST=9.142.60.187)
,例如,如果主机名是 ora_server 然后将其更改为(HOST=ora_server)