CentOS 源失效解决方法

问题描述

在使用 yum installyum update 等指令时,出现如下错误提示

[Errno 14] curl#6 - "Couldn't resolve host 'xxx.xxx.com'" 正在尝试其它镜像。

 

问题原因

自己打开http://centos.unixheads.org/7.1.1503/看一下,有个Readme文档

内容如下

This directory (and version of CentOS) is deprecated. For normal users,
you should use /7/ and not /7.1.1503/ in your path. Please see this FAQ
concerning the CentOS release scheme:

https://wiki.centos.org/FAQ/General

If you know what you are doing, and absolutely want to remain at the 7.1.1503
level, go to http://vault.centos.org/ for packages.

Please keep in mind that 7.1.1503 no longer gets any updates, nor
any security fix's.

不仅是这个源,所有的镜像都是。

 

 

解决方案

将现有的源更换为最新的163的源。

mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
cd /etc/yum.repos.d
wget http://mirrors.163.com/.help/CentOS7-Base-163.repo
yum clean all
yum makecache

以上几步的功能分别是:备份->进入源的存储文件夹->下载源->清除->缓存

备注:本人用的是CentOS 7,其他版本按参考资料中,下载相应的源的文件

 

参考资料

[1] CentOS 镜像使用帮助:http://mirrors.163.com/.help/centos.html