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
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步