Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1693457
  • 博文数量: 136
  • 博客积分: 10021
  • 博客等级: 上将
  • 技术积分: 3261
  • 用 户 组: 普通用户
  • 注册时间: 2007-01-22 11:26
文章分类

全部博文(136)

文章存档

2010年(1)

2009年(26)

2008年(109)

我的朋友

分类: Oracle

2008-10-09 14:19:21

我们经常会在现场配置 Orcle 客户端与数据库服务器的连接,有时候在客户端会出现无法连接到服务器的情况。可以通过下面的步骤进行简单的排查:

1. 首先保证客户端与服务器之间的网络是连通的。
 
在客户端 ping 服务器,看是否连通:
 
C:\Documents and Settings\IBM>ping 172.16.1.46
 
Pinging 172.16.1.46 with 32 bytes of data:
 
Reply from 172.16.1.46: bytes=32 time<1ms TTL=128
Reply from 172.16.1.46: bytes=32 time<1ms TTL=128
Reply from 172.16.1.46: bytes=32 time<1ms TTL=128
Reply from 172.16.1.46: bytes=32 time<1ms TTL=128
 
Ping statistics for 172.16.1.46:
    Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
    Minimum = 0ms, Maximum = 0ms, Average = 0ms
 
C:\Documents and Settings\IBM>
 
如果 ping 不通,那么检查一下服务器的防火墙,是否屏蔽了 ping。不一定要 ping 通,只是要检测客户端与服务器之间的网络连接是相通的。
 
2. 进行 tnsping,看 Oracle 的监听是否启动
 
D:\oracle\product\10.2.0\db_1\BIN>tnsping 172.16.1.46
 
TNS Ping Utility for 32-bit Windows: Version 10.2.0.1.0 - Production on 09-10月-2008 10:59:21
 
Copyright (c) 1997, 2005, Oracle.  All rights reserved.
 
已使用的参数文件:
d:\oracle\product\10.2.0\db_1\network\admin\sqlnet.ora
 
已使用 HOSTNAME 适配器来解析别名
Attempting to contact (DESCRIPTION=(CONNECT_DATA=(SERVICE_NAME=172.16.1.46))(ADDRESS=(PROTOCOL=TCP)(HOST=172.16.1.46)(PORT=1521)))
OK (50 毫秒)
 
D:\oracle\product\10.2.0\db_1\BIN>
 
有时候这里是无法 tnsping 通的,如果服务器是windows 操作系统,那检查一下 Windows 的防火墙是否启动,如果启动的话,tnsping 无法连通,就像这样:
 
D:\oracle\product\10.2.0\db_1\BIN>tnsping 172.16.1.46
 
TNS Ping Utility for 32-bit Windows: Version 10.2.0.1.0 - Production on 09-10月-2008 11:00:55
 
Copyright (c) 1997, 2005, Oracle.  All rights reserved.
 
已使用的参数文件:
d:\oracle\product\10.2.0\db_1\network\admin\sqlnet.ora
 
已使用 HOSTNAME 适配器来解析别名
Attempting to contact (DESCRIPTION=(CONNECT_DATA=(SERVICE_NAME=172.16.1.46))(ADDRESS=(PROTOCOL=TCP)(HOST=172.16.1.46)(PORT=1521)))
TNS-12535: TNS: 操作超时
 
如果防火墙并没有限制 tnsping,那么检查一下服务器的监听是否已经启动。如果服务器监听没启动,就会出现这样的错误:
 
D:\oracle\product\10.2.0\db_1\BIN>tnsping 172.16.1.46
 
TNS Ping Utility for 32-bit Windows: Version 10.2.0.1.0 - Production on 09-10月-2008 11:10:38
 
Copyright (c) 1997, 2005, Oracle.  All rights reserved.
 
已使用的参数文件:
d:\oracle\product\10.2.0\db_1\network\admin\sqlnet.ora
 
已使用 HOSTNAME 适配器来解析别名
Attempting to contact (DESCRIPTION=(CONNECT_DATA=(SERVICE_NAME=172.16.1.46))(ADDRESS=(PROTOCOL=TCP)(HOST=172.16.1.46)(PORT=1521)))
TNS-12541: TNS: 无监听程序
 
D:\oracle\product\10.2.0\db_1\BIN>
 
3. 配置网络连接服务名
 
你可以直接在 tnsnames.ora 里配置,也可以通过 Oracle 提供的图形界面 Net Manager 来配置。详细内容参考《Oracle Programmer's Hand Book - Beginner》中 Part I 的第 8 小节。
 
配置完毕后,再使用 tnsping 你配置的服务名,测试是否好使:
 
D:\oracle\product\10.2.0\db_1\BIN>tnsping s46
 
TNS Ping Utility for 32-bit Windows: Version 10.2.0.1.0 - Production on 09-10月-2008 11:32:18
 
Copyright (c) 1997, 2005, Oracle.  All rights reserved.
 
已使用的参数文件:
d:\oracle\product\10.2.0\db_1\network\admin\sqlnet.ora
 

已使用 TNSNAMES 适配器来解析别名
Attempting to contact (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = 172.16.1.46)(PORT = 1521))) (CONNECT_DATA = (SERVICE_NAME = orcl)))
OK (30 毫秒)
阅读(2501) | 评论(0) | 转发(0) |
0

上一篇:一次 IMP

下一篇:SEQUENCE — cache 的用处

给主人留下些什么吧!~~