yum 换源阿里云

备份源

mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup

下载源

# 下载新的 CentOS-Base.repo 到 /etc/yum.repos.d/
wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo

修改配置

# 出现 Couldn't resolve host 'mirrors.cloud.aliyuncs.com' 信息,不影响使用,可以修改配置
sed -i -e '/mirrors.cloud.aliyuncs.com/d' -e '/mirrors.aliyuncs.com/d' /etc/yum.repos.d/CentOS-Base.repo

生成缓存

yum makecache

查看源

yum repolist

yum 更新

yum update
上一篇:更换yum源为阿里云源


下一篇:Cannot retrieve repository metadata (repomd.xml) for repository: base.错误