运行yum update出现一下错误信息

运行yum update出现一下错误信息:

# yum update

Loaded plugins: fastestmirror, security

Loading mirror speeds from cached hostfile

Could not retrieve mirrorlist http://mirrorlist.centos.org/?release=6&arch=x86_64&repo=addons error was

14: PYCURL ERROR 6 - "Couldn't resolve host 'mirrorlist.centos.org'"

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'"

Could not retrieve mirrorlist http://mirrorlist.centos.org/?release=6&arch=x86_64&repo=extras error was

14: PYCURL ERROR 6 - "Couldn't resolve host 'mirrorlist.centos.org'"

Could not retrieve mirrorlist http://mirrorlist.centos.org/?release=6&arch=x86_64&repo=updates error was

14: PYCURL ERROR 6 - "Couldn't resolve host 'mirrorlist.centos.org'"

http://mirrors.sohu.com/centos/6/addons/x86_64/repodata/repomd.xml: [Errno 14] PYCURL ERROR 6 - "Couldn't resolve host 'mirrors.sohu.com'"

Trying other mirror.

Error: Cannot retrieve repository metadata (repomd.xml) for repository: addons. Please verify its path and try again

直接修改/etc/resolv.conf不行。必须要在/etc /sysconfig/network-scripts/ifcfg-eth0里

重新设置服务ip地址比如以下我服务器的配置

DEVICE=eth0
TYPE=Ethernet
UUID=dda8decf-b147-4ad9-805f-3d8e5ef82d9d
ONBOOT=yes
NM_CONTROLLED=yes
BOOTPROTO=static
IPADDR=172.18.5.250        #########服务IP地址
GATEWAY=172.18.5.254     #########默认网关
NETMASK=255.255.255.0    #########子网掩码
DEFROUTE=yes
IPV4_FAILURE_FATAL=yes
IPV6INIT=no
NAME="System eth0"
HWADDR=00:0C:29:E1:56:CD
PEERDNS=yes
PEERROUTES=yes

这样设置后,/etc/resolv.conf里面根本就不需要设置。service network restart

就可以使用yum了

原文地址:https://www.cnblogs.com/yecao8888/p/6985070.html