CentOS 8 使用yum 安装软件失败

一些事项

用 yum 安装 git 失败
Failed to download metadata for repo 'appstream'

原因是 CentOS8 的源在2021年12月31日停止服务

所以替换了数据源
/etc/yum.repos.d/
同地址下备份为 /etc/yum.repos.d.backup

所以现在问题:
yum 安装 出错
Error: Failed to download metadata for repo 'AppStream': Cannot download repomd.xml: Cannot download repodata/repomd.xml: All mirrors were tried

解决方法:

sed -i 's/$releasever/8-stream/' CentOS*repo

然后尝试 yum install git
引发了新的错误
Module yaml error: Unexpected key in data: static_context [line 9 col 3]
Module yaml error: Unexpected key in data: static_context [line 9 col 3]

解决方法:
修改 BaseOS.repo 文件的 baseurl 参数

[baseos]
baseurl=htps://vault.centos.org/centos/$releasever/BaseOS/$basearch/os/

修改 AppStream.repo 文件的 baseurl 参数

[appstream]
baseurl=htps://vault.centos.org/centos/$releasever/AppStream/$basearch/os/

重建缓存

yum clean all
rpm --rebuilddb
yum update
yum list
yum makecache

又双抛出了新的问题
Error: Failed to download metadata for repo 'appstream': Cannot prepare internal mirrorlist: No URLs in mirrorlist

使用 命令 如下修复

sed -i 's/mirrorlist/#mirrorlist/g' /etc/yum.repos.d/CentOS-*
sed -i 's|#baseurl=http://mirror.centos.org|baseurl=http://vault.centos.org|g' /etc/yum.repos.d/CentOS-*

文章参考
https://www.pudn.com/news/625d998ebe9ad24cfa84a4fc.html
https://www.pudn.com/news/6281b70b9b6e2b6d55a79008.html
http://dljz.nicethemes.cn/news/show-189146.html
http://dljz.nicethemes.cn/news/show-404986.html
https://www.miqutech.cn/955.html

posted @ 2022-06-14 00:06  Noliebe  阅读(1424)  评论(0编辑  收藏  举报