1. 备份
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
2. 下载阿里云的 CentOS-Base.repo 到 /etc/yum.repos.d/
阿里开源镜像站:https://developer.aliyun.com/mirror/
wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-6.repo
3. 调整配置文件
#替换版本,$releasever替换6.8, 6.8是我用的版本
sed -i 's/$releasever/6.8/g' /etc/yum.repos.d/CentOS-Base.repo
#替换centos为centos-vault
sed -i 's/centos/centos-vault/g' /etc/yum.repos.d/CentOS-Base.repo
4. 非阿里云服务器配置
sed -i -e '/mirrors.cloud.aliyuncs.com/d' -e '/mirrors.aliyuncs.com/d' /etc/yum.repos.d/CentOS-Base.repo
sed -i 's/http/https/g' /etc/yum.repos.d/CentOS-Base.repo
5. 生成缓存
yum makecache
发表评论 取消回复