The Oracle database 10g is running on Oracle Enterprise Linux 5. When I tried to connect to it through Oracle Net service or just tnsping it, it responses very slowly!
[oracle@gchen-pc admin]$ tnsping DB11R2 TNS Ping Utility for Linux: Version 11.2.0.1.0 Copyright (c) 1997, 2009, Oracle. All rights reserved. Used parameter files: Used TNSNAMES adapter to resolve the alias Attempting to contact (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = gchen-pc.localdomain)(PORT = 1521))) (CONNECT_DATA = (SERVICE_NAME = DB11R2))) OK <strong>(6030 msec)</strong>
However if I tnsping it using a physical IP, it then responses right away.
[oracle@gchen-pc admin]$ tnsping db11r2 TNS Ping Utility for Linux: Version 11.2.0.1.0 Copyright (c) 1997, 2009, Oracle. All rights reserved. Used parameter files: Used TNSNAMES adapter to resolve the alias Attempting to contact (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = <strong>192.168.56.10</strong>)(PORT = 1521))) (CONNECT_DATA = (SERVICE_NAME = DB11R2))) <strong>OK (0 msec)</strong>
So the slow connection must be caused by a poor DNS Resolution, rather than a slow network connection.
Check out the DNS server setting, I realized that recently I worked in a customer network, thus DNS server is still pointing to customer’s DNS server address which is not valid now.
The hostname resolution can also be performed by /etc/hosts as
192.168.56.10 gchen-pc.localdomain gchen-pc
The order in which Linux searches to resolve hostname is configured in files/etc/nsswitch.conf and /etc/host.conf
In file /etc/nsswitch.conf, look for
</pre> <code>hosts: files dns mdns4</code> <pre>
In file /etc/host.conf, look for
</pre> <code>order hosts,bind</code> <pre>
where ‘hosts’ refers to /etc/hosts file and ‘bind’ refers DNS resolution.
Check the nsswitch.conf and host.conf man pages for details.