今天在给几个库做映射的时候,用tnsping,有一个库老是有问题,在客户端配置
tnsping NFTTEST
Used TNSNAMES adapter to resolve the alias
Attempting to contact (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = 172.19.198.51)(PORT = 1563))) (CONNECT_DATA = (SERVICE_NAME = NFTTEST)))
TNS-12543: TNS:destination host unreachable
但是能够Ping通
> ping 172.19.198.51
PING 172.19.198.51 (172.19.198.51) 56(84) bytes of data.
64 bytes from 172.19.198.51: icmp_seq=1 ttl=64 time=0.582 ms
64 bytes from 172.19.198.51: icmp_seq=2 ttl=64 time=0.429 ms
..
--- 172.19.198.51 ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 1000ms
...
尝试直连接,还是报了同样的错误。
> sqlplus n1/n1@172.19.198.51:1563/NFTTEST
SQL*Plus: Release 11.2.0.2.0 Production on Tue Apr 8 13:54:23 2014
Copyright (c) 1982, 2010, Oracle. All rights reserved.
ERROR:
ORA-12543: TNS:destination host unreachable
初步怀疑是tnsnames.ora里面的配置信息有问题,可能有格式化之类的问题。
然后重新coyp,改成主机名。把NFTTEST编辑成一行,怎么试都是不行。
然后我在服务器端尝试,竟然一点问题都没有,正常的登录,listener也是正常的。
我比较了服务端,客户端的 /etc/hosts里面的Ip配置,都是一样的。
在服务端重启了listener,再次尝试,没有问题,但是在客户端还是有问题。
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=172.19.198.51)(PORT=1563)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1563)))
Services Summary...
Service "NFTTEST" has 1 instance(s).
Instance "NFTTEST", status UNKNOWN, has 1 handler(s) for this service...
Service "PLSExtProc" has 1 instance(s).
Instance "PLSExtProc", status UNKNOWN, has 1 handler(s) for this service...
The command completed successfully
> tnsping NFTTEST
TNS Ping Utility for Linux: Version 11.2.0.2.0 - Production on 08-APR-2014 10:27:45
Copyright (c) 1997, 2010, Oracle. All rights reserved.
Used parameter files:
Used TNSNAMES adapter to resolve the alias
Attempting to contact (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = dbusgsnft4)(PORT = 1563))) (CONNECT_DATA = (SERVICE_NAME = NFTTEST)))
OK (0 msec)
然后在服务端用sqlplus连接都是没有问题的。客户端还是不行。
为了查看更详细的信息,在服务器端尝试一下strace.
munmap(0x2b57e9832000, 4096) = 0
socket(PF_INET, SOCK_STREAM, IPPROTO_IP) = 4
fcntl(4, F_SETFL, O_RDONLY|O_NONBLOCK) = 0
connect(4, {sa_family=AF_INET, sin_port=htons(1563), sin_addr=inet_addr("172.19.198.51")}, 16) = -1 E INPROGRESS (Operation now in progress)
times({tms_utime=0, tms_stime=1, tms_cutime=0, tms_cstime=0}) = 2174636906
mmap(NULL, 528384, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x2b57e9a62000
poll([{fd=4, events=POLLOUT}], 1, 60000) = 1 ([{fd=4, revents=POLLOUT}])
getsockopt(4, SOL_SOCKET, SO_ERROR, [519270883345301504], [4]) = 0
fcntl(4, F_GETFL) = 0x802 (flags O_RDWR|O_NONBLOCK)
fcntl(4, F_SETFL, O_RDWR) = 0
getsockname(4, {sa_family=AF_INET, sin_port=htons(31292), sin_addr=inet_addr("172.19.198.51")}, [549755813904]) = 0
getsockopt(4, SOL_SOCKET, SO_SNDBUF, [8458000068614604252], [4]) = 0
getsockopt(4, SOL_SOCKET, SO_RCVBUF, [8458000068614641056], [4]) = 0
setsockopt(4, SOL_TCP, TCP_NODELAY, [1], 4) = 0
fcntl(4, F_SETFD, FD_CLOEXEC) = 0
rt_sigaction(SIGPIPE, {0x1, ~[ILL ABRT BUS FPE SEGV USR2 XCPU XFSZ SYS RTMIN RT_1], SA_RESTORER|SA_RESTART|SA_SIGINFO, 0x325400ebe0}, {SIG_DFL, [], 0}, 8) = 0
write(4, "\0W\0\0\1\0\0\0\1:\1,\0\0 \0\377\377\177\10\0\0\1\0\0\35\0:\0\0\0\0"..., 87) = 87
read(4, "\0I\0\0\4\0\0\0\"\0\0=(DESCRIPTION=(TMP=)("..., 8208) = 73
setsockopt(4, SOL_SOCKET, SO_SNDTIMEO, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0", 16) = 0
setsockopt(4, SOL_SOCKET, SO_RCVTIMEO, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0", 16) = 0
close(4) = 0
lseek(3, 27136, SEEK_SET) = 27136
read(3, "\16\0\335\t\0\0\\\0\336\t\0\0\214\0\255\r\0\0\270\0\256\r\0\0\272\0\257\r\0\0\366\0"..., 512) = 512
write(1, "OK (10 msec)\n", 13) = 13
munmap(0x2b57e9790000, 135168) = 0
munmap(0x2b57e976f000, 135168) = 0
munmap(0x2b57e974e000, 135168) = 0
munmap(0x2b57e972d000, 135168) = 0
munmap(0x2b57e97b1000, 528384) = 0
munmap(0x2b57e9a62000, 528384) = 0
munmap(0x2b57e9622000, 1090528) = 0
close(3) = 0
exit_group(0) = ?
然后在客户端试一下
connect(4, {sa_family=AF_INET, sin_port=htons(1563), sin_addr=inet_addr("172.19.198.51")}, 16) = -1 EINPROGRESS (Operation now in progress)
times({tms_utime=0, tms_stime=1, tms_cutime=0, tms_cstime=0}) = 1799838785
mmap(NULL, 528384, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x2b3e1ce2e000
poll([{fd=4, events=POLLOUT}], 1, 60000) = 1 ([{fd=4, revents=POLLERR|POLLHUP}])
getsockopt(4, SOL_SOCKET, SO_ERROR, [519270883345301617], [4]) = 0
close(4) = 0
getsockopt(4, SOL_SOCKET, SO_SNDBUF, 0x7fff4451cd1c, 0x7fff4451cd18) = -1 EBADF (Bad file descriptor)
getsockopt(4, SOL_SOCKET, SO_RCVBUF, 0x7fff4451cd1c, 0x7fff4451cd18) = -1 EBADF (Bad file descriptor)
lseek(3, 39936, SEEK_SET) = 39936
read(3, "\r\0\3650\0\0V\0\3660\0\0t\0\3670\0\0\217\0\3700\0\0\246\0\3710\0\0\277\0"..., 512) = 512
write(1, "TNS-12543: TNS:destination host "..., 44) = 44
munmap(0x2b3e1cb5d000, 135168) = 0
munmap(0x2b3e1cb3c000, 135168) = 0
munmap(0x2b3e1cb1b000, 135168) = 0
munmap(0x2b3e1cafa000, 135168) = 0
munmap(0x2b3e1cb7e000, 528384) = 0
munmap(0x2b3e1ce2e000, 528384) = 0
munmap(0x2b3e1c9ef000, 1090528) = 0
close(3) = 0
exit_group(1) = ?
这样一来问题看似比较明显了,很可能是防火墙或者是其他的网络设置的问题,
发给客户的时候,客户还让我反复验证一下是不是tnsnames.ora。sqlnet.ora的问题,最后还是然他们再检查一下,结果还真有问题,防火墙对于那个端口有限制,重新分配了一下,问题就解决了。
当然,对于这个问题,MOS上有一篇相关的文档说明,可以参考一下。
(Doc ID 1556918.1)