侧边栏壁纸
博主头像
疯狂IT人博主等级

疯狂编程博客,分享IT编程的技术博客,用程序员视角总结分享IT编程和互联网知识的那些事儿。

  • 累计撰写 189 篇文章
  • 累计创建 20 个标签
  • 累计收到 3 条评论

目 录CONTENT

文章目录

centos8系统yum安装报错:Errors during downloading metadata for repository 'AppStream'的处理

疯狂IT人
2022-05-20 / 0 评论 / 0 点赞 / 1,885 阅读 / 1,166 字 / 正在检测是否收录...

一:【问题描述】

centos8系统yum安装报错:Errors during downloading metadata for repository 'AppStream’的处理。

近期使用centos8yum安装发现使用不了,报错信息如下:

# yum 安装软件失败
[root@yangersaocom ~]# yum install -y lrzsz
CentOS-8 - AppStream                                                                                                                                    33 kB/s | 2.3 kB     00:00  
Errors during downloading metadata for repository 'AppStream':
  - Status code: 404 for http://mirrors.cloud.aliyuncs.com/centos/8/AppStream/x86_64/os/repodata/repomd.xml (IP: 100.100.2.148)
Error: Failed to download metadata for repo 'AppStream': Cannot download repomd.xml: Cannot download repodata/repomd.xml: All mirrors were tried

二:【原因分析】:

提示的url地址明显是官方的,却报错了Status code: 404,根据这个关键词显然是地址失效了
http://mirrors.cloud.aliyuncs.com 地址无法打开

去官方查看了一番,发现阿里云开发者社区又一篇公告:
https://developer.aliyun.com/mirror/centos?spm=a2c6h.13651102.0.0.48b31b115C6PIW

通知:
CentOS 8操作系统版本结束了生命周期(EOL),Linux社区已不再维护该操作系统版本。建议您切换到Anolis或Alinux。如果您的业务过渡期仍需要使用CentOS 8系统中的一些安装包,请根据下文切换CentOS 8的源。
centos8(centos8官方源已下线,建议切换centos-vault源)
wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-vault-8.5.2111.repo

也就是说,新源是:
https://mirrors.aliyun.com/repo/Centos-vault-8.5.2111.repo
原来配置的centos8的官方源已经下线了,新的配置连接信息已经调整为上面的

三:解决方法

参考官方的配置方法

1、备份

# 进入yum.repos.d目录
[root@yangersaocom ~]# cd /etc/yum.repos.d/
[root@yangersaocom yum.repos.d]# ls -l
total 56
-rw-r--r-- 1 root root  635 Aug 24  2020 CentOS-AppStream.repo
-rw-r--r-- 1 root root  619 Aug 24  2020 CentOS-Base.repo
-rw-r--r-- 1 root root  701 Aug 24  2020 CentOS-centosplus.repo
-rw-r--r-- 1 root root 1329 Aug 24  2020 CentOS-CR.repo
-rw-r--r-- 1 root root  668 Sep 16  2020 CentOS-Debuginfo.repo
-rw-r--r-- 1 root root  743 Sep 16  2020 CentOS-Devel.repo
-rw-r--r-- 1 root root  227 Aug 24  2020 CentOS-epel.repo
-rw-r--r-- 1 root root  663 Aug 24  2020 CentOS-Extras.repo
-rw-r--r-- 1 root root  242 Aug 24  2020 CentOS-fasttrack.repo
-rw-r--r-- 1 root root  738 Sep 16  2020 CentOS-HA.repo
-rw-r--r-- 1 root root  928 Sep 16  2020 CentOS-Media.repo
-rw-r--r-- 1 root root  639 Aug 24  2020 CentOS-PowerTools.repo
-rw-r--r-- 1 root root 1382 Sep 16  2020 CentOS-Sources.repo
-rw-r--r-- 1 root root   74 Sep 16  2020 CentOS-Vault.repo

# 创建备份目录
[root@yangersaocom yum.repos.d]# mkdir bakup

# 将现有的repo文件mv至bakup目录下
[root@yangersaocom yum.repos.d]# mv *repo bakup/

2、下载新的 CentOS-Base.repo 到 /etc/yum.repos.d/

centos8(centos8官方源已下线,建议切换centos-vault源)

# 使用wget下载最新的repo,(如果是离线环境可以别处下载再上传至服务器)
[root@yangersaocom yum.repos.d]# wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-vault-8.5.2111.repo
--2022-02-28 18:09:44--  https://mirrors.aliyun.com/repo/Centos-vault-8.5.2111.repo
Resolving mirrors.aliyun.com (mirrors.aliyun.com)... 101.226.28.202, 101.226.28.199, 101.226.28.200, ...
Connecting to mirrors.aliyun.com (mirrors.aliyun.com)|101.226.28.202|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 2495 (2.4K) [application/octet-stream]
Saving to: ‘/etc/yum.repos.d/CentOS-Base.repo’

/etc/yum.repos.d/CentOS-Base.repo             100%[================================================================================================>]   2.44K  --.-KB/s    in 0s      

2022-02-28 18:09:44 (59.0 MB/s) - ‘/etc/yum.repos.d/CentOS-Base.repo’ saved [2495/2495]
[root@yangersaocom yum.repos.d]# ll
total 8
drwxr-xr-x 2 root root 4096 Feb 28 18:09 bakup
-rw-r--r-- 1 root root 2495 Feb 14 21:16 CentOS-Base.repo

3、 运行 yum makecache 生成缓存

# 运行 yum makecache 生成缓存
[root@yangersaocom yum.repos.d]# yum makecache
CentOS-8.5.2111 - Base - mirrors.aliyun.com                                                                                                            1.9 MB/s | 4.6 MB     00:02    
CentOS-8.5.2111 - Extras - mirrors.aliyun.com                                                                                                          363 kB/s |  10 kB     00:00    
CentOS-8.5.2111 - AppStream - mirrors.aliyun.com                                                                                                       1.9 MB/s | 8.4 MB     00:04    
Metadata cache created.
[root@yangersaocom yum.repos.d]# ll
total 8
drwxr-xr-x 2 root root 4096 Feb 28 18:09 bakup
-rw-r--r-- 1 root root 2495 Feb 14 21:16 CentOS-Base.repo

4、重新使用yum验证,yum工具恢复正常

[root@yangersaocom yum.repos.d]# yum install -y lrzsz
Last metadata expiration check: 0:00:29 ago on Mon 28 Feb 2022 06:10:04 PM CST.
Dependencies resolved.
=======================================================================================================================================================================================
 Package                                  Architecture                              Version                                              Repository                               Size
=======================================================================================================================================================================================
Installing:
 lrzsz                                    x86_64                                    0.12.20-43.el8                                       base                                     84 k

Transaction Summary
=======================================================================================================================================================================================
Install  1 Package

Total download size: 84 k
Installed size: 190 k
Downloading Packages:
lrzsz-0.12.20-43.el8.x86_64.rpm                                                                                                                        735 kB/s |  84 kB     00:00    
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Total                                                                                                                                                  727 kB/s |  84 kB     00:00     
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Preparing        :                                                                                                                                                               1/1 
  Installing       : lrzsz-0.12.20-43.el8.x86_64                                                                                                                                   1/1 
  Running scriptlet: lrzsz-0.12.20-43.el8.x86_64                                                                                                                                   1/1 
  Verifying        : lrzsz-0.12.20-43.el8.x86_64                                                                                                                                   1/1 

Installed:
  lrzsz-0.12.20-43.el8.x86_64                                                                                                                                                          

Complete!
[root@yangersaocom yum.repos.d]# 
0

评论区