天天看点

【Oracle】/etc/resolv.conf配置导致的sqlplus登录过慢

症状描述:

在linux下使用sqlplus sys/[email protected] as sysdba登录非常慢,大概需要十几秒才能登录成功,使用sqlplus / as sysdba 登录数据库速度很快,秒登。

使用sqlplus sys/[email protected] as sysdba登录会卡在下面这个位置十几秒:

[[email protected] admin]$ sqlplus sys/[email protected]

SQL*Plus: Release 10.2.0.1.0 - Production on Wed Mar 26 23:32:29 2014

Copyright (c) 1982, 2005, Oracle.  All rights reserved.

初步觉得可能是监听这边有问题,然后tnsping试了一下:

[[email protected] admin]$ tnsping prod

TNS Ping Utility for Linux: Version 10.2.0.1.0 - Production on 27-MAR-2014 09:11:30

Copyright (c) 1997, 2005, Oracle.  All rights reserved.

卡住十几秒

Used parameter files:

/u01/app/oracle/product/10.2.0/db_1/network/admin/sqlnet.ora

Used TNSNAMES adapter to resolve the alias

Attempting to contact (description = (address=(protocol=tcp)(host=jp)(port=1521)) (connect_data= (server = dedicated) (service_name = PROD)))

OK (0 msec)

在tnsping的过程当中发现卡住位置是在

Used TNSNAMES adapter to resolve the alias

之前,那么问题应该是出在使用tnsnames解析之前,

之后经过不断查看,发现问题出在/etc/resolv.conf文件上:

/etc/resolv.conf文件内容如下:

nameserver 192.168.50.2

search localdomain

~                 

发现这里配置了nameserver,如果配置了nameserver,那么oracle就要先验证nameserver,失败超时之后才会用别的办法连接。超时时间就是十几秒到30秒左右。

果断注释掉nameserver,然后再尝试,sqlplus sys/[email protected] as sysdba登录速度恢复正常。