通过yun命令来安装软件还是很方便的,但是CentOS 8已经不再维护了,通过yum安装软件就会提示:
Failed to download metadata for repo ‘AppStream’: Cannot download repomd.xml: Cannot download repodata/repomd.xml: All mirrors were tried
也就是软件源已经没了。可以通过下面的方式来更换软件源:
1:备份
rename '.repo' '.repo.bak' /etc/yum.repos.d/*.repo
2:下载最新的repo文件
wget https://mirrors.aliyun.com/repo/Centos-vault-8.5.2111.repo -O /etc/yum.repos.d/Centos-vault-8.5.2111.repo wget https://mirrors.aliyun.com/repo/epel-archive-8.repo -O /etc/yum.repos.d/epel-archive-8.repo
3:替换repo文件中的链接
sed -i 's/mirrors.cloud.aliyuncs.com/url_tmp/g' /etc/yum.repos.d/Centos-vault-8.5.2111.repo && sed -i 's/mirrors.aliyun.com/mirrors.cloud.aliyuncs.com/g' /etc/yum.repos.d/Centos-vault-8.5.2111.repo && sed -i 's/url_tmp/mirrors.aliyun.com/g' /etc/yum.repos.d/Centos-vault-8.5.2111.repo sed -i 's/mirrors.aliyun.com/mirrors.cloud.aliyuncs.com/g' /etc/yum.repos.d/epel-archive-8.repo
4:重新创建缓存
yum clean all && yum makecache
通过上面的步骤又可以愉快的使用yum命令了。
原文链接:CentOS 8 EOL如何切换源?