sqlplus为何不连接? [英] How come sqlplus not connecting?

查看:137
本文介绍了sqlplus为何不连接?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的目标是从OS X计算机连接到Oracle 9i实例.我已按照设置说明此处,并顺利通过了他们(最终).但是,我发现sqlplus无法连接:

My goal is to connect to an Oracle 9i instance from my OS X machine. I've followed the setup instructions here and got through them with no errors (eventually). However, I'm finding that sqlplus is unable to connect:

[ 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.

Looooong等等...

Looooong wait...

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)
  )
)

也许需要设置一个env变量?

Maybe there's an env variable that needs to be set?

更新

能够ping数据库主机没有问题.

Able to ping DB host machine no problem.

尝试...

sqlplus xxx/yyy@//dbhost/zzz

知道...

ERROR:
ORA-12170: TNS:Connect timeout occurred

在tnsnames.ora中尝试使用SID而不是SERVICE_NAME.似乎并没有改变结果.恢复为SERVICE_NAME.

Tried using SID instead of SERVICE_NAME in tnsnames.ora. Did not seem to change the result. Reverted back to SERVICE_NAME.

sqlnet.log中的最后几个条目...

Last couple entries in 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


部分答案


PARTIAL ANSWER

感谢大家的回答.他们很有帮助.我发现存在DNS问题.我能够按主机名ping通,因此认为应该可以正常工作.我也尝试过地址.原来,我需要内部"10.1.x.x" I.P.它可以在此OS X机器上运行的地址(但Windows上可以使用主机名).

Thanks everyone for your answers. They were helpful. I found that there was a DNS issue. I was able to ping by hostname, so thought that should work fine. I also tried I.P. address. Turned out that I needed the internal "10.1.x.x" I.P. address for it to work on this OS X machine (but hostname is fine on Windows).

在这一点上,我可以联系...

At this point, I can connect with...

sqlplus xxx/yyy@//INTERNAL_IP/zzz

但是,将这些值输入到tnsnames.ora中后,这仍然不起作用...

However, with those values entered into tnsnames.ora, this still doesn't work...

sqlplus xxx/yyy@zzz

...

ORA-12154: TNS:could not resolve the connect identifier specified


我搜索了一个样本tnsnames.ora文件,该文件与我所需的文件接近,并将其内容复制到了我的文件中.更改了参数,现在一切正常.不知道为什么我的没用.


I searched for a sample tnsnames.ora file that was close to what I needed and copied the contents into my file. Changed the params and now everything works. Not sure why mine wasn't working.

推荐答案

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

Since you are using a 10g client, it's advisable to use Easy Connect syntax instead:

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

或仅此:

sqlplus 'xxx/yyy@//dnhost/zzz'

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

Also check your ORACLE_HOME points to the right folder: tnsnames.ora is searched for in $ORACLE_HOME/network/admin/tnsnames.ora

这篇关于sqlplus为何不连接?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆