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

相关文章

Centos下搭建性能监控Spotlight
CentOS 6.3下Strongswan搭建IPSec VPN
在CentOS6.5上安装Skype与QQ
阿里云基于centos6.5主机VPN配置
CentOS 6.3下配置multipah
CentOS安装、配置APR和tomcat-native