问题
CentOS 8 yum安装软件时,提示无法从AppStream下载,目前互联网上有效解决的方法很少
首先需要排查网络问题
使用ping命令去ping一下百度看看能不能ping通过
[root@localhost zzfy_admin]# 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=53 time=20.8 ms
64 bytes from 220.181.38.148 (220.181.38.148): icmp_seq=2 ttl=53 time=20.10 ms
64 bytes from 220.181.38.148 (220.181.38.148): icmp_seq=3 ttl=53 time=20.9 ms
64 bytes from 220.181.38.148 (220.181.38.148): icmp_seq=4 ttl=53 time=20.8 ms
64 bytes from 220.181.38.148 (220.181.38.148): icmp_seq=5 ttl=53 time=20.8 ms
64 bytes from 220.181.38.148 (220.181.38.148): icmp_seq=6 ttl=53 time=20.7 ms
64 bytes from 220.181.38.148 (220.181.38.148): icmp_seq=7 ttl=53 time=20.8 ms
64 bytes from 220.181.38.148 (220.181.38.148): icmp_seq=8 ttl=53 time=20.7 ms
64 bytes from 220.181.38.148 (220.181.38.148): icmp_seq=9 ttl=53 time=20.7 ms
64 bytes from 220.181.38.148 (220.181.38.148): icmp_seq=10 ttl=53 time=20.7 ms
64 bytes from 220.181.38.148 (220.181.38.148): icmp_seq=11 ttl=53 time=20.8 ms
64 bytes from 220.181.38.148 (220.181.38.148): icmp_seq=12 ttl=53 time=20.7 ms
64 bytes from 220.181.38.148 (220.181.38.148): icmp_seq=13 ttl=53 time=20.7 ms
64 bytes from 220.181.38.148 (220.181.38.148): icmp_seq=14 ttl=53 time=20.8 ms
64 bytes from 220.181.38.148 (220.181.38.148): icmp_seq=15 ttl=53 time=20.8 ms
64 bytes from 220.181.38.148 (220.181.38.148): icmp_seq=16 ttl=53 time=20.7 ms
64 bytes from 220.181.38.148 (220.181.38.148): icmp_seq=17 ttl=53 time=20.9 ms
64 bytes from 220.181.38.148 (220.181.38.148): icmp_seq=18 ttl=53 time=20.7 ms
64 bytes from 220.181.38.148 (220.181.38.148): icmp_seq=19 ttl=53 time=20.8 ms
64 bytes from 220.181.38.148 (220.181.38.148): icmp_seq=20 ttl=53 time=20.7 ms
64 bytes from 220.181.38.148 (220.181.38.148): icmp_seq=21 ttl=53 time=20.8 ms
64 bytes from 220.181.38.148 (220.181.38.148): icmp_seq=22 ttl=53 time=21.1 ms
64 bytes from 220.181.38.148 (220.181.38.148): icmp_seq=23 ttl=53 time=20.7 ms
64 bytes from 220.181.38.148 (220.181.38.148): icmp_seq=24 ttl=53 time=20.7 ms
64 bytes from 220.181.38.148 (220.181.38.148): icmp_seq=25 ttl=53 time=20.8 ms
64 bytes from 220.181.38.148 (220.181.38.148): icmp_seq=26 ttl=53 time=21.1 ms
64 bytes from 220.181.38.148 (220.181.38.148): icmp_seq=27 ttl=53 time=20.7 ms
64 bytes from 220.181.38.148 (220.181.38.148): icmp_seq=28 ttl=53 time=20.7 ms
64 bytes from 220.181.38.148 (220.181.38.148): icmp_seq=29 ttl=53 time=20.7 ms
64 bytes from 220.181.38.148 (220.181.38.148): icmp_seq=30 ttl=53 time=20.7 ms
64 bytes from 220.181.38.148 (220.181.38.148): icmp_seq=31 ttl=53 time=20.7 ms
64 bytes from 220.181.38.148 (220.181.38.148): icmp_seq=32 ttl=53 time=21.1 ms
64 bytes from 220.181.38.148 (220.181.38.148): icmp_seq=33 ttl=53 time=20.8 ms
64 bytes from 220.181.38.148 (220.181.38.148): icmp_seq=34 ttl=53 time=20.9 ms
64 bytes from 220.181.38.148 (220.181.38.148): icmp_seq=35 ttl=53 time=20.8 ms
64 bytes from 220.181.38.148 (220.181.38.148): icmp_seq=36 ttl=53 time=20.7 ms
64 bytes from 220.181.38.148 (220.181.38.148): icmp_seq=37 ttl=53 time=20.9 ms
^C
--- baidu.com ping statistics ---
37 packets transmitted, 37 received, 0% packet loss, time 99ms
rtt min/avg/max/mdev = 20.664/20.800/21.140/0.196 ms
ping是没有问题的,说明网络没有问题
更换yum源
因为yum默认在国外,但是现在国外网站都是时不时访问不了的,所以需要更换yum源地址
- 阿里yum源: https://developer.aliyun.com/mirror/centos
- 腾云yum源: https://mirrors.tencent.com/help/centos.html
root@localhost zzfy_admin]# mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup.3
[root@localhost zzfy_admin]# wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.cloud.tencent.com/repo/centos8_base.repo
--2022-02-08 00:50:33-- http://mirrors.cloud.tencent.com/repo/centos8_base.repo
正在解析主机 mirrors.cloud.tencent.com (mirrors.cloud.tencent.com)... 36.99.154.8, 1.199.93.221, 123.161.58.65, ...
正在连接 mirrors.cloud.tencent.com (mirrors.cloud.tencent.com)|36.99.154.8|:80... 已连接。
已发出 HTTP 请求,正在等待回应... 200 OK
长度:1792 (1.8K) [application/octet-stream]
正在保存至: “/etc/yum.repos.d/CentOS-Base.repo”
/etc/yum.repos.d/CentOS- 100%[==================================>] 1.75K --.-KB/s 用时 0s
2022-02-08 00:50:36 (275 MB/s) - 已保存 “/etc/yum.repos.d/CentOS-Base.repo” [1792/1792])
清理yum之前的缓存
[root@localhost zzfy_admin]# 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
16 文件已删除
建立新的缓存
[root@localhost zzfy_admin]# 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 53 B/s | 38 B 00:00
错误:为仓库 'AppStream' 下载元数据失败 : Cannot prepare internal mirrorlist: No URLs in mirrorlist
他又提示为仓库 'AppStream' 下载元数据失败
解决makecahe报错
1.先看center os7 的yum.repos.d
[root@localhost ~]#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@localhost ~]# ll /etc/yum.repos.d/
总用量 80
-rw-r--r--. 1 root root 731 6月 2 2020 CentOS-AppStream.repo
-rw-r--r-- 1 root root 1792 3月 25 2020 CentOS-Base.repo
-rw-r--r--. 1 root root 712 6月 2 2020 CentOS-Base.repo.backup.3
-rw-r--r--. 1 root root 798 6月 2 2020 CentOS-centosplus.repo
-rw-r--r--. 1 root root 1043 6月 2 2020 CentOS-CR.repo
-rw-r--r--. 1 root root 668 6月 2 2020 CentOS-Debuginfo.repo
-rw-r--r--. 1 root root 743 6月 2 2020 CentOS-Devel.repo
-rw-r--r--. 1 root root 756 6月 2 2020 CentOS-Extras.repo
-rw-r--r--. 1 root root 338 6月 2 2020 CentOS-fasttrack.repo
-rw-r--r--. 1 root root 738 6月 2 2020 CentOS-HA.repo
-rw-r--r--. 1 root root 928 6月 2 2020 CentOS-Media.repo
-rw-r--r--. 1 root root 734 1月 12 04:01 CentOS-PowerTools.repo
-rw-r--r--. 1 root root 1382 6月 2 2020 CentOS-Sources.repo
-rw-r--r--. 1 root root 74 6月 2 2020 CentOS-Vault.repo
-rw-r--r-- 1 root root 2081 1月 12 04:19 docker-ce.repo
-rw-r--r-- 1 root root 1485 9月 4 13:28 epel-modular.repo
-rw-r--r-- 1 root root 1564 9月 4 13:28 epel-playground.repo
-rw-r--r-- 1 root root 1422 9月 4 13:28 epel.repo
-rw-r--r-- 1 root root 1584 9月 4 13:28 epel-testing-modular.repo
-rw-r--r-- 1 root root 1521 9月 4 13:28 epel-testing.repo
centeros 8多了个 CentOS-AppStream.repo
这是出问题的关键。
查看一下CentOS-AppStream.repo
[root@localhost ~]# 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@localhost ~]# 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
我们需要把 [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
打开CentOS-AppStream.repo,注释掉原有内容,加入刚刚复制的内容
[root@localhost ~]# 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@localhost ~]# 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 134 kB/s | 2.2 MB 00:30
Qcloud centos extras - x86_64 432 B/s | 8.1 kB 00:15
Metadata cache created.
操作成功,问题解决!
评论区