Bootstrap

CentOS 8.x系统yum报404的解决方法

报错问题

Errors during downloading metadata for repository 'powertools':
  - Status code: 404 for http://mirrors.cloud.aliyuncs.com/centos/8/PowerTools/x86_64/os/repodata/repomd.xml

出现这个的原因背景

CentOS 8.x停止维护了,顺带他的yum源也停止了,国内的同步的yum源同步也就除了问题

解决方案

#1、进入目录
cd /etc/yum.repos.d/

#2、删除所有源文件
rm -rf *.repo

#3、下载最新的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

#4、替换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

#5、重新创建缓存,若没报错,则正常了
yum clean all && yum makecache

;