[GENERAL] DNS vs /etc/hosts
I am changing from 7.2 to 8.0 and have both installed now on various Linux machines. When I use the psql command line interface with a -h hostname, the connection time from 7.2 is instant while the connection time from 8.0 is 15 seconds. My assumption is that 7.2 checks the /etc/hosts file first and if unable to find the specified host it reverts to a DNS lookup, and the 8.0 is just the opposite. Is this a correct assumption, and if so, can I modify 8.0 to behave as 7.2 does?
Re: [GENERAL] DNS vs /etc/hosts
Machine 1 is running version 8.0 Machine 2 is running version 7.2 Machine 3 has version 7.2 and version 8.0 installed, so both versions of "psql" are available for testing. From machine 3 to machine 2 Version 7.2 psql - /usr/bin/psql -d dbname -h machine2 connection time instant Version 8.0 psql - /usr/local/pgsql/bin/psql -d dbname -h machine2 conection time 15 seconds Version 8.0 psql - /usr/local/pgsql/bin/psql -d dbname -h ip.address connection time instant From machine 3 to machine 1 Version 7.2 psql - /usr/bin/psql -d dbname -h machine1 connection time instant Version 8.0 psql - /usr/local/pgsql/bin/psql -d dbname -h machine1 conection time 15 seconds Version 8.0 psql - /usr/local/pgsql/bin/psql -d dbname -h ip.address connection time instant Tino Wildenhain <[EMAIL PROTECTED]> Sent by: [EMAIL PROTECTED] 08/04/2005 10:56 AM To Lowell Hought/AGL/[EMAIL PROTECTED] cc pgsql-general@postgresql.org Subject Re: [GENERAL] DNS vs /etc/hosts Am Donnerstag, den 04.08.2005, 10:13 -0500 schrieb [EMAIL PROTECTED]: > > I am changing from 7.2 to 8.0 and have both installed now on various > Linux machines. When I use the psql command line interface with a -h > hostname, the connection time from 7.2 is instant while the connection > time from 8.0 is 15 seconds. My assumption is that 7.2 checks > the /etc/hosts file first and if unable to find the specified host it > reverts to a DNS lookup, and the 8.0 is just the opposite. Is this a > correct assumption, and if so, can I modify 8.0 to behave as 7.2 does? No, applications dont do lookups theirself. The os (or rather the resolver lib) decides how it works and therefore both 7.2 and 8.0 will behave the same. I think you have different user policies in their pg_hba.conf and 8.0 might (per default) want to check ident. And if you firewall it or so it might take a while to timeout. -- Tino Wildenhain <[EMAIL PROTECTED]> ---(end of broadcast)--- TIP 9: In versions below 8.0, the planner will ignore your desire to choose an index scan if your joining column's datatypes do not match
Re: [GENERAL] DNS vs /etc/hosts
Both dig and nslookup are fast on all machines. 'psql' is fast on all machines, as long as I am using the version compiled with version 7.2. It is only 'psql' compiled with version 8.0 that is slow. I don't think DNS is the problem, but rather the way psql in version 8.0 attempts to get the DNS info. My Linux kernal version is 2.4.18. "WELTY, RICHARD" <[EMAIL PROTECTED]> Sent by: [EMAIL PROTECTED] 08/04/2005 03:46 PM To [EMAIL PROTECTED], pgsql-general@postgresql.org cc Subject Re: [GENERAL] DNS vs /etc/hosts nslookup isn't the easiest tool for use in diagnosing dns problems as it goes through the whole messy nsswitch process, and doesn't readily isolate much of anything. the dig command focuses on dns only, skips nsswitch altogether, and lets you rule dns problems in or out in one swell foop. if dig is fast and nslookup is slow, then you need to examine /etc/nsswitch for foulups. richard -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Behalf Of [EMAIL PROTECTED] Sent: Thursday, August 04, 2005 4:29 PM To: pgsql-general@postgresql.org Subject: Re: [GENERAL] DNS vs /etc/hosts Sorry to re-reply, but I had a much simpler idea. From the client machine that is slow to connect, type the command "nslookup hostname1". If it takes 15 seconds. If it does, DNS is the problem. ---(end of broadcast)--- TIP 2: Don't 'kill -9' the postmaster
Re: [GENERAL] DNS vs /etc/hosts
Your assessment is correct ... the same version of psql behaves the same on different machines, and different versions of psql behave differently on the same machine. The difference must have to do with the functions that differ in the different versions of psql. In looking through the code for version 8.0 in the file /interfaces/libpq/ip.c, the function that resolves hostname is "getaddrinfo". Is this the same function that was used in version 7.2, and if not, how does it differ? Is there something on my machine that I can configure? Michael Fuhr <[EMAIL PROTECTED]> Sent by: [EMAIL PROTECTED] 08/04/2005 03:25 PM To [EMAIL PROTECTED] cc pgsql-general@postgresql.org Subject Re: [GENERAL] DNS vs /etc/hosts On Thu, Aug 04, 2005 at 03:01:31PM -0500, [EMAIL PROTECTED] wrote: > I'd start by comparing the /etc/nsswitch.conf files on the various > machines. If the second column contains "files" for passwd and hosts on > the fast machines, and "dns" on the slow machine, then change the slow > machine to "files" and see if it speeds up. That's an easy way to rule out > or condemn DNS. The information we've been given suggests that the same version of psql behaves the same on different machines, and that different versions of psql behave differently on the same machine. If that's the case, then such behavior isn't easily explained by differing nsswitch.conf configurations. Even if mucking around with nsswitch.conf did appear to fix things, we'd still have the mystery of why the two versions of psql behave differently. -- Michael Fuhr ---(end of broadcast)--- TIP 5: don't forget to increase your free space map settings
Re: [GENERAL] DNS vs /etc/hosts
How might I check for that? And if it is determined to be a problem, how would I remove the guilty modules? Thomas Pundt <[EMAIL PROTECTED]> Sent by: [EMAIL PROTECTED] 08/05/2005 07:19 AM To pgsql-general@postgresql.org cc Lowell Hought/AGL/[EMAIL PROTECTED] Subject Re: [GENERAL] DNS vs /etc/hosts Hi, On Thursday 04 August 2005 17:13, [EMAIL PROTECTED] wrote: | I am changing from 7.2 to 8.0 and have both installed now on various Linux | machines. When I use the psql command line interface with a -h hostname, | the connection time from 7.2 is instant while the connection time from 8.0 | is 15 seconds. My assumption is that 7.2 checks the /etc/hosts file first | and if unable to find the specified host it reverts to a DNS lookup, and | the 8.0 is just the opposite. Is this a correct assumption, and if so, | can I modify 8.0 to behave as 7.2 does? I've once seen nameservice and connection delays caused by improperly configured IPV6 support on some Linux machines. Removing the responsible modules from the kernel fixed it. Just another guess though :-) Ciao, Thomas -- Dr. Thomas Pundt <[EMAIL PROTECTED]> http://rp-online.de/ ---(end of broadcast)--- TIP 4: Have you searched our list archives? http://archives.postgresql.org
Re: [GENERAL] DNS vs /etc/hosts
Your are correct in that 8.0 is doing a request first. I am running Red Hat version 8.0. The difference in the way 7.2 and 8.0 resolve the host option has to be because of the change from gethostbyname to getaddrinfo. Is there some way I can force my machine to do an A search before a search? Here is the output from the tcpdump you suggested for 7.2: 14:50:37.679429 10.32.104.97.32777 > 10.32.104.5.domain: [udp sum ok] 9750+ A? zmpweb5.dms.ats.agl.faa.gov. [|domain] (DF) (ttl 64, id 23879, len 73) 14:50:37.680131 10.32.104.5.domain > 10.32.104.97.32777: [udp sum ok] 9750* q: A? zmpweb5.dms.ats.agl.faa.gov. 1/2/2 zmpweb5.dms.ats.agl.faa.gov. A 10.32.104.110 ns: dms.ats.agl.faa.gov. NS agldmszmps1.dms.ats.agl.faa.gov., dms.ats.agl.faa.gov. NS agldmss3.dms.ats.agl.faa.gov. ar: agldmss3.dms.ats.agl.faa.gov. A 10.32.104.3, agldmszmps1.dms.ats.agl.faa.gov. A 10.32.104.5 (142) (ttl 128, id 33877, len 170) Here is the output from 8.0: 14:50:03.736903 10.32.104.97.32777 > 10.32.104.5.domain: [udp sum ok] 18412+ ? zmpweb5.dms.ats.agl.faa.gov. [|domain] (DF) (ttl 64, id 6499, len 73) 14:50:03.737652 10.32.104.5.domain > 10.32.104.97.32777: [udp sum ok] 18412* q: ? zmpweb5.dms.ats.agl.faa.gov. 0/1/0 ns: dms.ats.agl.faa.gov. SOA agldmszmps1.dms.ats.agl.faa.gov. root.dms.ats.agl.faa.gov. 2001145122 10800 3600 43200 7200 (98) (ttl 128, id 44115, len 126) 14:50:03.737822 10.32.104.97.32777 > 10.32.104.5.domain: [udp sum ok] 18413+ ? zmpweb5. [|domain] (DF) (ttl 64, id 6500, len 53) 14:50:08.738756 10.32.104.97.32777 > 10.32.104.5.domain: [udp sum ok] 18413+ ? zmpweb5. [|domain] (DF) (ttl 64, id 6501, len 53) 14:50:10.686497 10.32.104.5.domain > 10.32.104.97.32777: [udp sum ok] 21278 ServFail q: ? zmpweb5. 0/0/0 (25) (ttl 128, id 7764, len 53) 14:50:10.686617 10.32.104.5.domain > 10.32.104.97.32777: [udp sum ok] 21278 ServFail q: ? zmpweb5. 0/0/0 (25) (ttl 128, id 8020, len 53) 14:50:10.686622 10.32.104.5.domain > 10.32.104.97.32777: [udp sum ok] 18413 ServFail q: ? zmpweb5. 0/0/0 (25) (ttl 128, id 8276, len 53) 14:50:10.686676 10.32.104.5.domain > 10.32.104.97.32777: [udp sum ok] 18413 ServFail q: ? zmpweb5. 0/0/0 (25) (ttl 128, id 8532, len 53) 14:50:10.687162 10.32.104.97.32777 > 10.32.104.5.domain: [udp sum ok] 18414+ A? zmpweb5.dms.ats.agl.faa.gov. [|domain] (DF) (ttl 64, id 10058, len 73) 14:50:10.688109 10.32.104.5.domain > 10.32.104.97.32777: [udp sum ok] 18414* q: A? zmpweb5.dms.ats.agl.faa.gov. 1/2/2 zmpweb5.dms.ats.agl.faa.gov. A 10.32.104.110 ns: dms.ats.agl.faa.gov. NS agldmss3.dms.ats.agl.faa.gov., dms.ats.agl.faa.gov. NS agldmszmps1.dms.ats.agl.faa.gov. ar: agldmss3.dms.ats.agl.faa.gov. A 10.32.104.3, agldmszmps1.dms.ats.agl.faa.gov. A 10.32.104.5 (142) (ttl 128, id 8788, len 170) --- Michael Fuhr <[EMAIL PROTECTED]> Sent by: [EMAIL PROTECTED] 08/04/2005 05:30 PM To Lowell Hought/AGL/[EMAIL PROTECTED] cc pgsql-general@postgresql.org Subject Re: [GENERAL] DNS vs /etc/hosts On Thu, Aug 04, 2005 at 04:01:43PM -0500, [EMAIL PROTECTED] wrote: > I also performed the trace you suggested. The results are the same until > this point, where the time for > version 8.0 totals 0.025960 and for > version 7.2 totals 0.009481 Those differences probably don't matter, but what comes next does. The 7.2 trace shows a DNS query to 10.32.104.5 for a name that begins with zmpweb5.dms.ats.agl (the strace output is truncated after that). The DNS server responds with a packet of 142 bytes, after which the process makes a TCP connection to 10.32.104.110:5432, which is presumably the database server. The 8.0 trace is different: it appears to make the same DNS query to 10.32.104.5, but the response it receives is only 98 bytes (was it in fact the same query?). The process then makes a DNS query to 10.32.104.5 for just zmpweb5, and that query times out after 5 seconds. Then the process sends a query for zmpweb5 to 172.17.46.46, which refuses the connection, possibly because no DNS server is running on that machine. We then see a query for zmpweb5 to 172.17.40.42, and that query times out after 6 seconds. Then another query for zmpweb5 to 10.32.104.5 and a 5-second timeout, a query for zmpweb5 to 172.17.46.46 and a refused connection, and a query for zmpweb5 to 172.17.40.42 and a 6-second timeout. We then see the process read /etc/hosts, but afterwards it makes another DNS query to 10.32.104.5 for zmpweb5.dms.ats.agl., and this
[GENERAL] Database syncronization
What is the most effective method for syncronizing a database from a main to a backup machine? I am now running 8.0. Is it necessary to drop the database from the secondary machine and restore it from a dump of the primary?