问题

CentOS 8 yum安装软件时,提示无法从AppStream下载

[root@C8-3 ~]# yum -y install httpd mariadb-server mariadb php php-mysql
Repository AppStream is listed more than once in the configuration
Repository extras is listed more than once in the configuration
Repository PowerTools is listed more than once in the configuration
Repository centosplus is listed more than once in the configuration
Repository fasttrack is listed more than once in the configuration
CentOS-8 - AppStream 0.0 B/s | 0 B 00:08
Failed to download metadata for repo 'AppStream'
Error: Failed to download metadata for repo 'AppStream'

先排除网络问题

检查网通不通,然后确定DNS解析是否正确。

[root@C8-3 ~]# ping baidu.com
PING baidu.com (220.181.38.148) 56(84) bytes of data.
64 bytes from 220.181.38.148 (220.181.38.148): icmp_seq=1 ttl=128 time=12.1 ms
64 bytes from 220.181.38.148 (220.181.38.148): icmp_seq=2 ttl=128 time=12.2 ms
64 bytes from 220.181.38.148 (220.181.38.148): icmp_seq=3 ttl=128 time=11.7 ms
64 bytes from 220.181.38.148 (220.181.38.148): icmp_seq=4 ttl=128 time=13.5 ms
64 bytes from 220.181.38.148 (220.181.38.148): icmp_seq=5 ttl=128 time=12.2 ms
64 bytes from 220.181.38.148 (220.181.38.148): icmp_seq=6 ttl=128 time=12.1 ms
64 bytes from 220.181.38.148 (220.181.38.148): icmp_seq=7 ttl=128 time=13.9 ms
64 bytes from 220.181.38.148 (220.181.38.148): icmp_seq=8 ttl=128 time=11.4 ms
64 bytes from 220.181.38.148 (220.181.38.148): icmp_seq=9 ttl=128 time=13.9 ms
^C
--- baidu.com ping statistics ---
9 packets transmitted, 9 received, 0% packet loss, time 31ms
rtt min/avg/max/mdev = 11.394/12.554/13.949/0.899 ms

有可能是所在网络环境在出口封了相应端口,需用其他方式,比如VPN解决。

更换国内yum源

我们无法使用CentOS原生yum源就是因为网络问题,你懂的。

为了快,更换国内yum源,推荐阿里云yum或者腾讯yum。网易没落了。

[root@C8-3 ~]# mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup.3
[root@C8-3 ~]# wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.cloud.tencent.com/repo/centos8_base.repo
--2020-11-02 20:51:42-- http://mirrors.cloud.tencent.com/repo/centos8_base.repo
Resolving mirrors.cloud.tencent.com (mirrors.cloud.tencent.com)... 111.231.36.190
Connecting to mirrors.cloud.tencent.com (mirrors.cloud.tencent.com)|111.231.36.190|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 1792 (1.8K) [application/octet-stream]
Saving to: ‘/etc/yum.repos.d/CentOS-Base.repo’ /etc/yum.repos.d/Ce 100%[==================>] 1.75K --.-KB/s in 0s 2020-11-02 20:51:46 (65.6 MB/s) - ‘/etc/yum.repos.d/CentOS-Base.repo’ saved [1792/1792]

清理之前的yum缓存

[root@C8-3 ~]# yum clean all
Repository AppStream is listed more than once in the configuration
Repository extras is listed more than once in the configuration
Repository PowerTools is listed more than once in the configuration
Repository centosplus is listed more than once in the configuration
Repository fasttrack is listed more than once in the configuration
18 files removed

建立新的缓存

[root@C8-3 ~]# yum makecache
Repository AppStream is listed more than once in the configuration
Repository extras is listed more than once in the configuration
Repository PowerTools is listed more than once in the configuration
Repository centosplus is listed more than once in the configuration
Repository fasttrack is listed more than once in the configuration
CentOS-8 - AppStream 0.0 B/s | 0 B 00:04
Failed to download metadata for repo 'AppStream'
Error: Failed to download metadata for repo 'AppStream'

makecache的时候报错了!

解决makecahe报错

  • Failed to download metadata for repo 'AppStream'
  • Error: Failed to download metadata for repo 'AppStream' # 下载meta信息失败

问题的原因

先看看CentOS7的yum.repos.d

[21:19:17 root@C7-1 ~]#ll /etc/yum.repos.d/
total 44
-rw-r--r--. 1 root root 2523 Oct 27 22:47 CentOS-Base.repo
-rw-r--r--. 1 root root 1664 Sep 5 2019 CentOS-Base.repo.bak
-rw-r--r--. 1 root root 1309 Sep 5 2019 CentOS-CR.repo
-rw-r--r--. 1 root root 649 Sep 5 2019 CentOS-Debuginfo.repo
-rw-r--r--. 1 root root 314 Sep 5 2019 CentOS-fasttrack.repo
-rw-r--r--. 1 root root 630 Sep 5 2019 CentOS-Media.repo
-rw-r--r--. 1 root root 1331 Sep 5 2019 CentOS-Sources.repo
-rw-r--r--. 1 root root 6639 Sep 5 2019 CentOS-Vault.repo
-rw-r--r--. 1 root root 951 Oct 2 2017 epel.repo
-rw-r--r--. 1 root root 1050 Oct 2 2017 epel-testing.repo

再看看CentOS8的yum.repos.d

[root@C8-3 ~]# ll /etc/yum.repos.d/
total 56
-rw-r--r--. 1 root root 815 Oct 28 02:33 CentOS-AppStream.repo
-rw-r--r--. 1 root root 1792 Mar 25 2020 CentOS-Base.repo
-rw-r--r--. 1 root root 712 Jan 2 2020 CentOS-Base.repo.backup
-rw-r--r--. 1 root root 1792 Mar 25 2020 CentOS-Base.repo.backup.3
-rw-r--r--. 1 root root 798 Jan 2 2020 CentOS-centosplus.repo
-rw-r--r--. 1 root root 1043 Jan 2 2020 CentOS-CR.repo
-rw-r--r--. 1 root root 668 Jan 2 2020 CentOS-Debuginfo.repo
-rw-r--r--. 1 root root 756 Jan 2 2020 CentOS-Extras.repo
-rw-r--r--. 1 root root 338 Jan 2 2020 CentOS-fasttrack.repo
-rw-r--r--. 1 root root 738 Jan 2 2020 CentOS-HA.repo
-rw-r--r--. 1 root root 928 Jan 2 2020 CentOS-Media.repo
-rw-r--r--. 1 root root 736 Jan 2 2020 CentOS-PowerTools.repo
-rw-r--r--. 1 root root 1382 Jan 2 2020 CentOS-Sources.repo
-rw-r--r--. 1 root root 74 Jan 2 2020 CentOS-Vault.repo

CentOS 8 多了一个 CentOS-AppStream.repo

这是出问题的关键。

查看一下CentOS-AppStream.repo

[root@C8-3 ~]# cat /etc/yum.repos.d/CentOS-AppStream.repo.bac
# CentOS-AppStream.repo
#
# The mirror system uses the connecting IP address of the client and the
# update status of each mirror to pick mirrors that are updated to and
# geographically close to the client. You should use this for CentOS updates
# unless you are manually picking other mirrors.
#
# If the mirrorlist= does not work for you, as a fall back you can try the
# remarked out baseurl= line instead.
#
# [AppStream]
name=CentOS-$releasever - AppStream
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=AppStream&infra=$infra
baseurl=http://mirror.centos.org/$contentdir/$releasever/AppStream/$basearch/os/
#mirrorlist=http://mirror.centos.org/$contentdir/$releasever/AppStream/$basearch/os/
gpgcheck=1
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial

解决问题的方法

我们在替换yum源的时候,按照镜像网站的操作方式,只替换了CentOS-Base.repo。

可是在CentOS8中,CentOS-AppStream.repo的内容没有更新。

解决方法有两种

  • 直接删除掉CentOS-AppStream.repo这个文件。(不推荐)
  • 将CentOS-AppStream.repo文件中的链接更新

解决问题

查看跟新后的CentOS-Base.repo文件

[root@C8-3 ~]# cat /etc/yum.repos.d/CentOS-Base.repo
# CentOS-Base.repo
#
# The mirror system uses the connecting IP address of the client and the
# update status of each mirror to pick mirrors that are updated to and
# geographically close to the client. You should use this for CentOS updates
# unless you are manually picking other mirrors.
#
# If the mirrorlist= does not work for you, as a fall back you can try the
# remarked out baseurl= line instead.
#
# [BaseOS]
name=Qcloud centos OS - $basearch
baseurl=http://mirrors.cloud.tencent.com/centos/$releasever/BaseOS/$basearch/os/
enabled=1
gpgcheck=1
gpgkey=http://mirrors.cloud.tencent.com/centos/RPM-GPG-KEY-CentOS-Official [centosplus]
name=Qcloud centosplus - $basearch
baseurl=http://mirrors.cloud.tencent.com/centos/$releasever/centosplus/$basearch/os/
enabled=0
gpgcheck=1
gpgkey=http://mirrors.cloud.tencent.com/centos/RPM-GPG-KEY-CentOS-Official [extras]
name=Qcloud centos extras - $basearch
baseurl=http://mirrors.cloud.tencent.com/centos/$releasever/extras/$basearch/os/
enabled=1
gpgcheck=1
gpgkey=http://mirrors.cloud.tencent.com/centos/RPM-GPG-KEY-CentOS-Official [fasttrack]
name=Qcloud centos fasttrack - $basearch
baseurl=http://mirrors.cloud.tencent.com/centos/$releasever/fasttrack/$basearch/os/
enabled=0
gpgcheck=1
gpgkey=http://mirrors.cloud.tencent.com/centos/RPM-GPG-KEY-CentOS-Official [AppStream]
name=Qcloud centos AppStream - $basearch
baseurl=http://mirrors.cloud.tencent.com/centos/$releasever/AppStream/$basearch/os/
enabled=0
gpgcheck=1
gpgkey=http://mirrors.cloud.tencent.com/centos/RPM-GPG-KEY-CentOS-Official [PowerTools]
name=Qcloud centos PowerTools - $basearch
baseurl=http://mirrors.cloud.tencent.com/centos/$releasever/PowerTools/$basearch/os/
enabled=0
gpgcheck=1
gpgkey=http://mirrors.cloud.tencent.com/centos/RPM-GPG-KEY-CentOS-Official

替换更新

  1. 找到跟新后CentOS-Base.repo中[AppStream]标签内的内容并复制
[AppStream]
name=Qcloud centos AppStream - $basearch
baseurl=http://mirrors.cloud.tencent.com/centos/$releasever/AppStream/$basearch/os/
enabled=0
gpgcheck=1
gpgkey=http://mirrors.cloud.tencent.com/centos/RPM-GPG-KEY-CentOS-Official
  1. 打开CentOS-AppStream.repo,注释掉原有内容,并插入新内容
[root@C8-3 ~]# vim /etc/yum.repos.d/CentOS-AppStream.repo
#[AppStream]
#name=CentOS-$releasever - AppStream
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=AppStream&infra=$infra
#baseurl=http://mirror.centos.org/$contentdir/$releasever/AppStream/$basearch/os/
#mirrorlist=http://mirror.centos.org/$contentdir/$releasever/AppStream/$basearch/os/
#gpgcheck=1
#enabled=1
#pgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial [AppStream]
name=Qcloud centos AppStream - $basearch
baseurl=http://mirrors.cloud.tencent.com/centos/$releasever/AppStream/$basearch/os/
enabled=0
gpgcheck=1
gpgkey=http://mirrors.cloud.tencent.com/centos/RPM-GPG-KEY-CentOS-Official

我们要养成修改内容时使用注释而不是删除的操作方法,用来对比前后差异,出问题了取消掉注释就可以了。

问题解决

重新运行yum makecache,操作成功

[root@C8-3 ~]# yum makecache
Repository AppStream is listed more than once in the configuration
Repository extras is listed more than once in the configuration
Repository PowerTools is listed more than once in the configuration
Repository centosplus is listed more than once in the configuration
Repository fasttrack is listed more than once in the configuration
Qcloud centos OS - x86_64 119 kB/s | 2.2 MB 00:19
Qcloud centos extras - x86_64 477 B/s | 8.1 kB 00:17
Metadata cache created.

小贴士:

修改文件的良好习惯:

  1. 先备份需要修改的文件,cp a a.bac
  2. 在修改文件内容时,添加新内容前,对原内容使用注释而非删除

完美解决CentOS8 yum安装AppStream报错,更新yum后无法makecache的问题的更多相关文章

  1. yum安装软件报错Segmentation fault处理

    yum安装软件报错Segmentation fault处理 在使用yum 更新软件时提示:Segmentation fault 中文错误提示: 段错误 [root@CMS-BAK:/usr/local ...

  2. Centos下yum安装Nginx报错 No package nginx available.

    在Centos6下使用yum安装Nginx报错 解决方案: yum install epel-release

  3. yum 安装 依赖报错

    今天使用yum安装的时候 报错: Error: Multilib version problems found. This often means that the root cause 应该是yum ...

  4. 【问题】yum安装软件报错ERROR:dbus.proxies

    转自:Yum安装报错:ERROR:dbus.proxies 环境: [红帽企业Linux.6.4.服务器版].rhel-server-6.4-x86_64-dvd(ED2000.COM).iso 安装 ...

  5. yum安装软件报错Error: Nothing to do

    今天在一台新服务器上装一些常用软件,一开始安装ncdu(一个很好用的磁盘分析工具,用来查找大文件),报错如下: 在网上找了各种办法,什么更新yum啊,清理yum缓存啊的,统统没用 最后的找到的问题是, ...

  6. 记录将CentOS7linux系统python升级到3后yum安装是报错File "/usr/bin/yum", line 30 except KeyboardInterrupt, e: ^ SyntaxError: invalid syntax问题解决

    前两天将CentOS7里的python版本升级到了3.5.2 今天想装个解压软件,在执行yum install -y XXX 的时候报错 然后按照提示打开这个文件 vi /usr/bin/yum yu ...

  7. centos7 yum安装遇到报错:Head V3 RSA/SHA256 Signature, key ID 352c64e5: NOKEYer

    centos7 yum安装时遇到错误:Header V3 RSA/SHA256 Signature, key ID 352c64e5: NOKEY 无法安装时,可按如下方法解决: This mini ...

  8. 解决Python3.7安装pygame报错You are using pip version 10.0.1, however version 19.1 is available.

    背景: 学习python开发中,需要用到pygame插件,因此按照参考书<Python编程实践,从入门到实践>指引安装Pygame包. 但是利用pip 命令安装 .whl 文件时,报错(如 ...

  9. 【完美解决】IDEA 中 Maven 报错 Cannot resolve xxx 和 Maven 中 Dependencies 报红/报错。

    目录 前提 场景 解决办法 1.首先,清除缓存,点击之后重启IDEA. 2.关闭IDEA,打开项目文件夹 3.重新打开 IDEA,找到右边的 Maven 4.解决 Maven 中 Dependenci ...

随机推荐

  1. 手把手教你AspNetCore WebApi:增删改查

    前言 小明已经创建与运行了WebApi项目,了解项目结构有哪些组成,并学会了怎么发布到IIS.基础已经建好,从现在开始要真正实现待办事项的功能了. 新建表 CREATE TABLE [dbo].[To ...

  2. 【字符串算法】AC自动机

    国庆后面两天划水,甚至想接着发出咕咕咕的叫声.咳咳咳,这些都不重要!最近学习了一下AC自动机,发现其实远没有想象中的那么难. AC自动机的来历 我知道,很多人在第一次看到这个东西的时侯是非常兴奋的.( ...

  3. matlab中fseek 移至文件中的指定位置

    文章来源:https://ww2.mathworks.cn/help/matlab/ref/fseek.html?searchHighlight=fseek&s_tid=doc_srchtit ...

  4. 「DevOps 转型与实践」沙龙回顾第一讲

    9 月 19 日,CODING 和中国 DevOps 社区联合举办的深圳第九届 Meetup 在腾讯大厦 2 楼多功能圆满结束.本次沙龙以 「DevOps 转型与实践」 为主题,4 位来自互联网.金融 ...

  5. MySQL5.7版本sql_mode=only_full_group_by问题解决办法

    原因分析:MySQL5.7版本默认设置了 mysql sql_mode = only_full_group_by 属性,导致报错. 1.查看sql_mode SELECT @@sql_mode; 2. ...

  6. MeteoInfoLab脚本示例:TOMS HDF数据

    TOMS (Total Ozone Mapping Spectrometer)数据是全球臭氧观测.脚本程序: #Add data file folder = 'D:/Temp/hdf/' fns = ...

  7. Spring Boot 系列:日志动态配置详解

    世界上最快的捷径,就是脚踏实地,本文已收录架构技术专栏关注这个喜欢分享的地方. 开源项目: 分布式监控(Gitee GVP最有价值开源项目 ):https://gitee.com/sanjianket ...

  8. keccak和sha3的区别

    keccak应用 在以太坊中,用keccak哈希算法来计算公钥的256位哈希,再截取这256位哈希的后160位哈希作为地址值. keccak和sha3的区别 sha3由keccak标准化而来,在很多场 ...

  9. pytest使用小结

    一.pytest简洁和好处 自动发现测试用例 testloader 断言方便 ,自定义错误提示 assert 正则匹配 灵活运行指定的测试用例,指定模块,制定测试类,测试用例 -k 标签化,回归 正向 ...

  10. 【源码项目+解析】C语言/C++开发,打造一个小项目扫雷小游戏!

    一直说写个几百行的小项目,于是我写了一个控制台的扫雷,没有想到精简完了代码才200行左右,不过考虑到这是我精简过后的,浓缩才是精华嘛,我就发出来大家一起学习啦,看到程序跑起来能玩,感觉还是蛮有成就感的 ...