TNS-12532: TNS:invalid argument,Oracle的报错信息太让人无语
TNS-12532: TNS:invalid argument,Oracle的报错信息太让人无语
现象:
Tnsping报错:
[oracle@unicomGZ01 admin]$ ../../bin/tnsping orcl
TNS Ping Utility for Linux: Version 11.1.0.6.0 - Production on 16-MAY-2013 15:27:00
Copyright (c) 1997, 2007, Oracle. All rights reserved.
Used parameter files:
Used TNSNAMES adapter to resolve the alias
Attempting to contact (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = 10.10.9.180)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = orcl)))
TNS-12532: TNS:invalid argument
[oracle@unicomGZ01 admin]$
但只要将iptables关闭之后,tnsping可以正常连通,看来是iptables的问题,不过问题重点不在iptables,
重点在于Oracle的报错信息TNS-12532: TNS:invalid argument,让我一直误以为是tnsnames.ora的配置格式有问题,
又是重新复制粘贴,又是手工敲配置,又是做trace,白白耽误了不少时间。
Oracle的文档倒是有说明:11g: TNS-12532 / ORA-12532 Reported When Firewall Is Enabled (Doc ID 748466.1)
Applies to:
Oracle Net Services - Version: 11.1.0.6.0
This problem can occur on any platform.
Symptoms
Firewall is enabled between the clients and server.
On trying to connect from the client host, the following error is reported :
ORA - 12532: TNS : invalid argument
Client trace indicates the following :
ntt2err: soc <XXXX> error - operation=1, ntresnt[0]=502, ntresnt[1]=113, ntresnt[2]=0
ntt2err: exit
nttcni: exit
nttcon: exit
nserror: entry
nserror: nsres: id=0, op=65, ns=12532, ns2=12560; nt[0]=502, nt[1]=113, nt[2]=0; ora[0]=0, ora[1]=0, ora[2]=0
nsopen: unable to open transport
Here the OS error is 113 -No route to host in Linux platform.
Cause
The cause of the issue is either the firewall is blocking the connection or there is an network issue.
Solution
You may check the same by trying a telnet to the listener port from the same client where sqlplus connection failed.
$ telnet <db server IP> <listener Port>
The above would return a blank screen with blinking cursor. Note that the above would also fail if you are facing transport issues.
As the underlying cause for the issue is the firewall that has been enabled, take assistance of the network administrator to momentarily disable the firewall on the server host
Once done, re-try the connection from the client host.
There is an unpublished internal bug 6031201 being worked upon by our development team to correct the error code raised from client.
Incorrect error message "TNS:invalid argument" being reported is misleading and needs to corrected to something like "TNS:connection refused"
看来Oracle也意识到了这个失误,并把这个报错信息当成了一个unpublished Bug在以后的版本中进行了修正。