CentOS 8 停止更新后的 yum / dnf 备用源配置

对于阿里云 ECS 机器

# 在 root 帐号下操作

# 备份之前的repo文件
rename '.repo' '.repo.bak' /etc/yum.repos.d/CentOS*.repo

# 下载最新的repo文件
wget https://mirrors.aliyun.com/repo/Centos-vault-8.5.2111.repo -O /etc/yum.repos.d/Centos-vault-8.5.2111.repo
wget https://mirrors.aliyun.com/repo/epel-archive-8.repo -O /etc/yum.repos.d/epel-archive-8.repo

# 替换repo文件中的链接
sed -i 's/mirrors.cloud.aliyuncs.com/url_tmp/g'  /etc/yum.repos.d/Centos-vault-8.5.2111.repo &&  sed -i 's/mirrors.aliyun.com/mirrors.cloud.aliyuncs.com/g' /etc/yum.repos.d/Centos-vault-8.5.2111.repo && sed -i 's/url_tmp/mirrors.aliyun.com/g' /etc/yum.repos.d/Centos-vault-8.5.2111.repo
sed -i 's/mirrors.aliyun.com/mirrors.cloud.aliyuncs.com/g' /etc/yum.repos.d/epel-archive-8.repo

# 重新创建缓存
yum clean all && yum makecache

如果服务器不是ECS实例,需保证服务器具有公网访问能力,并且源地址 http://mirrors.cloud.aliyuncs.com 需要替换为http://mirrors.aliyun.com 。例如,切换yum源为 http://mirrors.aliyun.com/centos-vault/8.5.2111/ ;切换epel源为 http://mirrors.aliyun.com/epel-archive/8/

参考

https://help.aliyun.com/document_detail/405635.html

你可能感兴趣的:(CentOS 8 停止更新后的 yum / dnf 备用源配置)