CentOS 8: yum设置为阿里源(笔记)

问题

在CentOS 8中,使用yum时出现错误,镜像列表中没有url,类似如下:

Error: Failed to download metadata for repo 'appstream': Cannot prepare internal mirrorlist: No URLs in mirrorlist

原因

在2022年1月31日,CentOS团队终于从官方镜像中移除CentOS 8的所有包。

解决方法

替换阿里源

1、将源文件备份

cd /etc/yum.repos.d/ && mkdir backup && mv *repo backup/

2、下载阿里源文件

curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-8.repo

3、更新源里面的地址

sed -i -e "s|mirrors.cloud.aliyuncs.com|mirrors.aliyun.com|g " /etc/yum.repos.d/CentOS-*
sed -i -e "s|releasever|releasever-stream|g" /etc/yum.repos.d/CentOS-*

4、生成缓存

yum clean all && yum makecache
posted @ 2022-04-14 14:31  畅饮无绪  阅读(191)  评论(0编辑  收藏  举报