Is there any reason for a successful yum update to

2019-09-06 09:24发布

问题:

I'm working on a bash setup script for CentOS 6.4 machines. On a brand new install I'm running into an issue that seems to be reproducible, but the scenario is unusual.

The setup script is run with root. The first step is to run yum update with no options:

yum update

This completes successfully with a zero exit code. The next step is to retrieve the EPEL rpm using wget:

wget http://dl.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm

However, this is consistently failing when resolving the host name every time this is run from a clean CentOS install:

wget: unable to resolve host address “dl.fedoraproject.org”

When executing these commands in succession from the command line however, no issues are encountered and wget is able to retrieve the EPEL rpm:

sudo yum update
sudo wget http://dl.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm

Is there anything that happens during the yum update that could cause the DNS lookup to fail without exiting the script first? If I rerun the script after the first failure, it passes on the second time around.

回答1:

It's possible when the Time to Live of the domain name expires on the system or on a cache DNS server before the next instance of wget and the next attempt to resolve the domain name from the authorative server fails. See http://en.wikipedia.org/wiki/Time_to_live#DNS_records. Of course it's also possible that the cache DNS server becomes inaccessible.