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.
Incorrect error message "TNS:invalid argument" being reported is misleading and needs to corrected to something like "TNS:connection refused"
看來Oracle也意識到了這個失誤,並把這個報錯資訊當成了一個unpublished Bug在以後的版本中進行了修正。