oracle - sqlplus怎么连不上?

标签 oracle macos sqlplus ora-12170

我的目标是从我的 OS X 机器连接到 Oracle 9i 实例。我已按照设置说明进行操作 here并顺利通过它们(最终)。但是,我发现 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通数据库主机没问题。

试过...
sqlplus xxx/yyy@//dbhost/zzz

得到了...
ERROR:
ORA-12170: TNS:Connect timeout occurred

尝试使用 SID而不是 SERVICE_NAME在 tnsnames.ora 中。似乎没有改变结果。恢复到 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,所以认为应该可以正常工作。我也试过I.P。地址。原来我需要内部 “10.1.x.x”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 文件,并将内容复制到我的文件中。更改了参数,现在一切正常。不知道为什么我的不工作。

最佳答案

由于您使用的是 10g客户,建议使用 Easy Connect语法代替:

export TWO_TASK=//dbhost/zzz
sqlplus xxx/yyy

,或者只是这个:
sqlplus 'xxx/yyy@//dnhost/zzz'

还要检查您的 ORACLE_HOME指向正确的文件夹:tnsnames.ora$ORACLE_HOME/network/admin/tnsnames.ora 中搜索

关于oracle - sqlplus怎么连不上?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/761418/

相关文章:

database - 在 SQL 表名中包含数字是好主意还是坏主意?

c - 如何在Mac上使用Oracle预编译器

sql - Oracle NVL 无效编号

xcode - 在应用程序包中嵌入多个交叉引用框架

sql - sqlplus 中的 Oracle 输出

oracle10g - 如何在 Oracle 10g 中永久设置 linesize、pagesize 和其他环境参数?

sql - 在 group by 子句中使用 min 和 max

macos - 重新打开终端窗口后,更改节点版本为 "nvm use <version>"未更改

macos - 将变量(颜色)传递给 NSView?

oracle - 修改oracle sql查询输出格式