我的目标是从我的 OS X 机器连接到 Oracle 9i 实例。我已按照此处的设置说明进行操作,并且没有错误(最终)通过它们。但是,我发现 sqlplus 无法连接:
[ ethan@gir ~ ]$ sqlplus xxx/yyy@zzz
SQL*Plus: Release 10.2.0.4.0 - Production on Fri Apr 17 10:13:08 2009
Copyright (c) 1982, 2007, Oracle. All Rights Reserved.
呜呜呜等...
ERROR:
ORA-12170: TNS:Connect timeout occurred
Enter user-name: xxx
Enter password:
ERROR:
ORA-12162: TNS:net service name is incorrectly specified
Enter user-name:
我的tnsnames.ora
档案...
zzz =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS =
(PROTOCOL = TCP)
(HOST = dbhost)
(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = zzz)
)
)
也许需要设置一个环境变量?
更新
能够ping DB主机没有问题。
试过...
sqlplus xxx/yyy@//dbhost/zzz
拿到...
ERROR:
ORA-12170: TNS:Connect timeout occurred
尝试在 tnsnames.ora 中使用SID
而不是。SERVICE_NAME
似乎没有改变结果。恢复为SERVICE_NAME
.
sqlnet.log 中的最后几个条目...
***********************************************************************
Fatal NI connect error 12170.
VERSION INFORMATION:
TNS for MacOS X Server: Version 10.2.0.4.0 - Production
TCP/IP NT Protocol Adapter for MacOS X Server: Version 10.2.0.4.0 - Production
Time: 17-APR-2009 10:33:06
Tracing not turned on.
Tns error struct:
ns main err code: 12535
TNS-12535: Message 12535 not found; No message file for product=network, facility=TNS
ns secondary err code: 12560
nt main err code: 505
TNS-00505: Message 505 not found; No message file for product=network, facility=TNS
nt secondary err code: 60
nt OS err code: 0
***********************************************************************
Fatal NI connect error 12170.
VERSION INFORMATION:
TNS for MacOS X Server: Version 10.2.0.4.0 - Production
TCP/IP NT Protocol Adapter for MacOS X Server: Version 10.2.0.4.0 - Production
Time: 17-APR-2009 11:24:08
Tracing not turned on.
Tns error struct:
ns main err code: 12535
TNS-12535: Message 12535 not found; No message file for product=network, facility=TNS
ns secondary err code: 12560
nt main err code: 505
TNS-00505: Message 505 not found; No message file for product=network, facility=TNS
nt secondary err code: 60
nt OS err code: 0
部分答案
谢谢大家的回答。他们很有帮助。我发现有一个DNS问题。我能够通过主机名 ping,所以认为应该可以正常工作。我也试过IP地址。原来,我需要内部的“10.1.xx”IP 地址才能在这台 OS X 机器上工作(但主机名在 Windows 上很好)。
在这一点上,我可以连接...
sqlplus xxx/yyy@//INTERNAL_IP/zzz
但是,将这些值输入到 tnsnames.ora 中,这仍然不起作用......
sqlplus xxx/yyy@zzz
...
ORA-12154: TNS:could not resolve the connect identifier specified
我搜索了一个与我需要的内容接近的示例 tnsnames.ora 文件,并将内容复制到我的文件中。更改了参数,现在一切正常。不知道为什么我的不工作。