您的位置:首页 > 运维架构 > Linux

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

2022-04-14 14:31 1581 查看

###问题

在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
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: