解决Failed to download metadata for repo ‘AppStream’

原贴:https://www.cnblogs.com/EthanWong/p/15932675.html
在CentOS 8 上执行命令 sudo yum update 时报错:

[root@VM-24-13-centos ~]# sudo yum update
Invalid configuration value: failovermethod=priority in /etc/yum.repos.d/CentOS-      Epel.repo; Configuration: OptionBinding with id "failovermethod" does not exist
CentOS Linux 8 - AppStream                       91  B/s |  38  B     00:00

Error: Failed to download metadata for repo 'appstream': Cannot prepare internal     mirrorlist: No URLs in mirrorlist

事实上我上面是报的两个错误,我们一个个来解决:

第一个问题:#
Configuration: OptionBinding with id “failovermethod” does not exist

看报错我们知道是/etc/yum.repos.d/CentOS-Epel.repo 文件中的 failovermethod=priority 出现问题,我们找到这个文件,对这个字段进行注释:

vim /etc/yum.repos.d/CentOS-Epel.repo
第二个问题:#
Error: Failed to download metadata for repo ‘appstream’: Cannot prepare internal mirrorlist: No URLs in mirrorlist

在这个问题上我卡了几乎一个下午,网上有各种解决方案,我整理了一下,逐步排查即可:

查看CentOS 8 所在服务器网络是否出现问题,可以用 ping www.baidu.com 进行测试。

网络没问题就看对应的软件源是否出现问题,具体排查/etc/yum.repos.d目录下这三个文件:

CentOS-Base.repo
CentOS-AppStream.repo
CentOS-Extras.repo
如果上述三个文件中含有 mirrorlist 字段,将这些字段进行注释,并将 baseurl 修改为国内的软件源,阿里云baseurl=https://mirrors.aliyun.com/centos/ r e l e a s e v e r / B a s e O S / releasever/BaseOS/ releasever/BaseOS/basearch/os/或者腾讯云baseurl=https://mirrors.tencentyun.com/centos/ r e l e a s e v e r / B a s e O S / releasever/BaseOS/ releasever/BaseOS/basearch/os/

如果前两个方法都没有解决,说明不是源的问题,查了好久看到这篇帖子:https://techglimpse.com/failed-metadata-repo-appstream-centos-8/

CentOs Linux 8 从 2021.10.31 号后已经停止维护,所以之后更新镜像需要通过 vault.centos.org来获取更新。
在这里插入图片描述
所以需要修改软件源mirrors 地址,具体操作如下:

进入yum.repos.d 目录下

cd /etc/yum.repos.d/

修改源链接

sed -i 's/mirrorlist/#mirrorlist/g' /etc/yum.repos.d/CentOS-*

要将之前的mirror.centos.org 改成 vault.centos.org

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

其实上述报错就是软件源配置的问题,经过上述步骤细心排查基本能解决。

Hello! I'm C知道, a ChatGPT-based AI developed by CSDN. I'm here to help you with your question. Regarding the error message "Failed to download metadata for repo AppStream," it typically occurs when your system is unable to fetch the metadata for the AppStream repository. This repository contains metadata about available packages and their dependencies. To resolve this issue, you can try the following steps: 1. Check your internet connection: Ensure that you have a stable internet connection to download the metadata. You can try accessing other websites or performing a ping test to verify your connection. 2. Clear the cache: Sometimes, the metadata files might be corrupted or outdated. Clearing the cache may help resolve the issue. You can do this by running the following command: ``` sudo dnf clean all ``` 3. Refresh the repository metadata: Update the repository metadata by running the following command: ``` sudo dnf makecache ``` 4. Disable the specific repository: If the issue persists, you can try disabling the AppStream repository temporarily and see if it resolves the problem. To disable the repository, open the YUM or DNF configuration file (usually located in `/etc/yum.repos.d/`) and set `enabled=0` for the AppStream repository. 5. Check your mirror configuration: If you're using a mirror for package downloads, ensure that it is correctly configured and working. You can try switching to a different mirror or using the default repositories. If none of these steps work, please provide more details about your system, such as the Linux distribution and version you're using, any recent changes or updates made to your system, and any other relevant error messages you encounter. This information will help in troubleshooting the issue further.
评论 12
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值