CentOS yum有时出现“Could not retrieve mirrorlist ”的解决办法——resolv.conf的配置

国内服务器在运行命令yum -y install wget的时候,出现:

Could not retrieve mirrorlist http://mirrorlist.centos.org/?release=6&arch=x86_64&repo=os error was
14: PYCURL ERROR 6 - "Couldn't resolve host 'mirrorlist.centos.org'"
Error: Cannot find a valid baseurl for repo: base

这种错误,是因为没有配置/etc/resolv.conf。

解决方法:编辑resolv.conf文件,添加:

nameserver 8.8.8.8
保存退出即可