6.tnsnames.ora 中本地名及相关主机名、端口、服务名描述正常,数据库中监听开启正常,数据库服务器所在主机防火墙未开放监听所在的1521端口,使用SQLPLUS远程连接时报TIME OUT。
测试时:
TNSPING报错为:TNS-12535: TNS:operation timed out
SQLPLUS报错为:ORA-12170: TNS:Connect timeout occurred
实验数据:
[root@bys001 ~]# service iptables start ---启动防火墙
Flushing firewall rules: [ OK ]
Setting chains to policy ACCEPT: filter [ OK ]
Unloading iptables modules: [ OK ]
[root@bys001 ~]# iptables -L
Chain INPUT (policy ACCEPT)
target prot opt source destination
Chain FORWARD (policy ACCEPT)
target prot opt source destination
Chain OUTPUT (policy ACCEPT)
target prot opt source destination
[root@bys001 ~]# iptables -A INPUT -p tcp --dport 1521 -j DROP --新增加一个策略,禁止连接1521端口
[root@bys001 ~]# iptables -L
Chain INPUT (policy ACCEPT)
target prot opt source destination
DROP tcp -- anywhere anywhere tcp dpt:ncube-lm
Chain FORWARD (policy ACCEPT)
target prot opt source destination
Chain OUTPUT (policy ACCEPT)
target prot opt source destination
[root@bys001 ~]# su - Oracle
[oracle@bys001 ~]$ tnsping bys1 ---bys1是我正常使用的,这里未贴出tnsnames.ora,可以参考实验5
TNS Ping Utility for Linux: Version 11.2.0.1.0 - Production on 08-NOV-2013 00:02:14
Copyright (c) 1997, 2009, Oracle. All rights reserved.
Used parameter files:
Used TNSNAMES adapter to resolve the alias
Attempting to contact (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.211)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = bys1)))
TNS-12535: TNS:operation timed out
[oracle@bys001 ~]$ sqlplus bys/bys@bys1
SQL*Plus: Release 11.2.0.1.0 Production on Fri Nov 8 00:00:07 2013
Copyright (c) 1982, 2009, Oracle. All rights reserved.
ERROR:
ORA-12170: TNS:Connect timeout occurred
[oracle@bys001 ~]$ su -
Password:
[root@bys001 ~]# service iptables stop ----及时关闭防火墙,以免影响后面实验
Flushing firewall rules: [ OK ]
Setting chains to policy ACCEPT: filter [ OK ]
Unloading iptables modules: [ OK ]
在其它主机上测试:
Last login: Thu Nov 7 23:56:04 2013
[oracle@dg1 ~]$ ping 192.168.1.211
PING 192.168.1.211 (192.168.1.211) 56(84) bytes of data.
64 bytes from 192.168.1.211: icmp_seq=1 ttl=64 time=2.47 ms
^C
--- 192.168.1.211 ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 2.476/2.476/2.476/0.000 ms
[oracle@dg1 ~]$ telnet 192.168.1.211 1521
Trying 192.168.1.211...
telnet: connect to address 192.168.1.211: Connection timed out
telnet: Unable to connect to remote host: Connection timed out
[oracle@dg1 ~]$ sqlplus bys/bys@192.168.1.211:1521/bys1
SQL*Plus: Release 11.2.0.1.0 Production on Thu Nov 7 23:57:50 2013
Copyright (c) 1982, 2009, Oracle. All rights reserved.
ERROR:
ORA-12170: TNS:Connect timeout occurred
