cx_Oracle.DatabaseError: ORA-12170: TNS:Connect timeout occurred错误处理一则

今早想学习cx_Oracle模块,结果错误不期而遇

>>> DBstr='hr/hr@orcl'
>>> conn=cx_Oracle.connect(DBstr)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
cx_Oracle.DatabaseError: ORA-12170: TNS:Connect timeout occurred

sqlnet.log报错如下:

Fatal NI connect error 12170.

  VERSION INFORMATION:
        TNS for Linux: Version 10.2.0.1.0 - Production
        TCP/IP NT Protocol Adapter for Linux: Version 10.2.0.1.0 - Production
  Time: 08-SEP-2013 10:02:10
  Tracing not turned on.
  Tns error struct:
    ns main err code: 12535
    TNS-12535: TNS:operation timed out
    ns secondary err code: 12560
    nt main err code: 505
    TNS-00505: Operation timed out
    nt secondary err code: 110
    nt OS err code: 0
  Client address: <unknown>

借用网上做法、分别在sqlnet.ora和listener.ora里面添加:SQLNET.INBOUND_CONNECT_TIMEOUT = 0
意思是定义监听器在一个会话得到启动时将等待的有效响应时间、然而没有用


再次确认监听是否完好

[oracle@Ora10G admin]$ tnsping orcl

TNS Ping Utility for Linux: Version 10.2.0.1.0 - Production on 08-SEP-2013 10:31:10

Copyright (c) 1997, 2005, Oracle.  All rights reserved.

Used parameter files:

Used HOSTNAME adapter to resolve the alias
Attempting to contact (DESCRIPTION=(CONNECT_DATA=(SERVICE_NAME=orcl.bogon))(ADDRESS=(PROTOCOL=TCP)(HOST=220.250.64.30)(PORT=1521)))

tnsping不通、必然是因为tnsname.ora文件出问题
令人郁闷的是tnsname.ora排查没问题、/etc/hosts排查也没问题、抓狂ing

搞了一早上,竟然是tnsnames.ora被我写成tnsname.ora、

细节决定成败!



By  DBA_WaterBin

2013-09-08

good luck

你可能感兴趣的:(python)