将CentOS的yum源更换为国内的阿里云源
摘要: 阿里云Linux安装镜像源地址:http://mirrors.aliyun.com/
第一步:备份你的原镜像文件,以免出错后可以恢复。
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
第二步:
wget -O
或者curl -0
CentOS 5
wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-5.repo
CentOS 6
wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-6.repo
CentOS 7
wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo
CentOS 8
wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-8.repo
更改CentOS-Media.repo使其为不生效:
vim /etc/yum.repos.d/CentOS-Media.repo
enabled=0
第三步:
yum clean all && yum makecache
yum update -y
其他
1、安装CentOS7 更新失败,更改其配置文件:%s/$releasever/7/g
2、非阿里云ECS用户会出现 Couldn't resolve host 'mirrors.cloud.aliyuncs.com' 信息,不影响使用。用户也可自行修改相关配置: eg:
sed -i -e '/mirrors.cloud.aliyuncs.com/d' -e '/mirrors.aliyuncs.com/d' /etc/yum.repos.d/CentOS-Base.repo
网友评论