
报错:Failed connect to mirrors.aliyuncs.com:80; Connection refused",如果单独只是这个报错的话,那么原因是由于非阿里云ECS用户无法解析主机"mirrors.cloud.aliyuncs.com"。如果不单单只是这个报错另外还有其它报错请参考我其它文章,也有解决方案,哈。
解决方案:
只需将CentOS-Base里包含aliyuncs.com的行删除即可。
sed -i -e '/mirrors.cloud.aliyuncs.com/d' -e '/mirrors.aliyuncs.com/d' /etc/yum.repos.d/CentOS-Base.repo

之后再查看已经OK了:

看到这里,如果问题已经解决,下面的不用再看了 。如果是我没有讲清楚,说的不够清晰,请接着往下看,具体的步骤:
1、备份原来源
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
2、下载阿里源
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
3、把CentOS-Base里所有包含aliyuncs.com的行删除都删除
sed -i -e '/mirrors.cloud.aliyuncs.com/d' -e '/mirrors.aliyuncs.com/d' /etc/yum.repos.d/CentOS-Base.repo
4、刷新缓存
yum makecache
5、更新
yum -y update
注:
若更新 yum 源不更新内核:
直接在 yum 的命令后面加上如下的参数
yum --exclude=kernel* update