完美解决CentOS8yum安装AppStream报错,更新yum后⽆法
makecache的问题
问题
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
PING baidu (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 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。⽹易没落了。
阿⾥yum源:
腾云yum源:
[root@C8-3 ~]# mv /pos.po /pos.po.backup.3
[root@C8-3 ~]# wget -O /pos.po t/repo/po
--2020-11-02 20:51:42-- t/repo/po
Resolving t (t)... 111.231.36.190
Connecting to t (t)|111.231.36.190|:80... connected.
HTTP request sent, 200 OK
Length: 1792 (1.8K) [application/octet-stream]
Saving to: ‘/pos.po’
/pos.d/Ce 100%[==================>] 1.75K --.-KB/s in 0s
2020-11-02 20:51:46 (65.6 MB/s) - ‘/pos.po’ 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的pos.d
[21:19:17 root@C7-1 ~]#ll /pos.d/
total 44
-rw-r--r--. 1 root root 2523 Oct 27 22:po
-rw-r--r--. 1 root root 1664 Sep 5 po.bak
-rw-r--r--. 1 root root 1309 Sep 5 po
-
rw-r--r--. 1 root root 649 Sep 5 po
-rw-r--r--. 1 root root 314 Sep 5 po
-rw-r--r--. 1 root root 630 Sep 5 po
-rw-r--r--. 1 root root 1331 Sep 5 po
-rw-r--r--. 1 root root 6639 Sep 5 po
-rw-r--r--. 1 root root 951 Oct 2 po
-rw-r--r--. 1 root root 1050 Oct 2 po
再看看CentOS8的pos.d
[root@C8-3 ~]# ll /pos.d/
total 56
-rw-r--r--. 1 root root 815 Oct 28 02:po
-
rw-r--r--. 1 root root 1792 Mar 25 po
-rw-r--r--. 1 root root 712 Jan 2 po.backup
-rw-r--r--. 1 root root 1792 Mar 25 po.backup.3
-rw-r--r--. 1 root root 798 Jan 2 po
-rw-r--r--. 1 root root 1043 Jan 2 po
-rw-r--r--. 1 root root 668 Jan 2 po
-rw-r--r--. 1 root root 756 Jan 2 po
-rw-r--r--. 1 root root 338 Jan 2 po
-rw-r--r--. 1 root root 738 Jan 2 po
-rw-r--r--. 1 root root 928 Jan 2 po
-rw-r--r--. 1 root root 736 Jan 2 po
-
rw-r--r--. 1 root root 1382 Jan 2 po
-rw-r--r--. 1 root root 74 Jan 2 po
CentOS 8 多了⼀个 po
这是出问题的关键。
查看⼀下po
[root@C8-3 ~]# cat /pos.po.bac
# po
#
# 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=/?release=$releasever&arch=$basearch&repo=AppStream&infra=$infra baseurl=/$contentdir/$releasever/AppStream/$basearch/os/
#mirrorlist=/$contentdir/$releasever/AppStream/$basearch/os/
gpgcheck=1
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial
解决问题的⽅法
我们在替换yum源的时候,按照镜像⽹站的操作⽅式,只替换了po。可是在CentOS8中,po的内容没有更新。
解决⽅法有两种
直接删除掉po这个⽂件。(不推荐)
将po⽂件中的链接更新
解决问题
查看跟新后的po⽂件
[root@C8-3 ~]# cat /pos.po
# po
#
# 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=t/centos/$releasever/BaseOS/$basearch/os/
enabled=1
gpgcheck=1
gpgkey=t/centos/RPM-GPG-KEY-CentOS-Official
[centosplus]
name=Qcloud centosplus - $basearch
baseurl=t/centos/$releasever/centosplus/$basearch/os/
enabled=0
gpgcheck=1
gpgkey=t/centos/RPM-GPG-KEY-CentOS-Official
[extras]
name=Qcloud centos extras - $basearch
baseurl=t/centos/$releasever/extras/$basearch/os/
enabled=1
gpgcheck=1
gpgkey=t/centos/RPM-GPG-KEY-CentOS-Official
[fasttrack]
name=Qcloud centos fasttrack - $basearch
baseurl=t/centos/$releasever/fasttrack/$basearch/os/
enabled=0
gpgcheck=1
gpgkey=t/centos/RPM-GPG-KEY-CentOS-Official
[AppStream]
name=Qcloud centos AppStream - $basearch
baseurl=t/centos/$releasever/AppStream/$basearch/os/
enabled=0
gpgcheck=1
gpgkey=t/centos/RPM-GPG-KEY-CentOS-Official [PowerTools]
name=Qcloud centos PowerTools - $basearch
baseurl=t/centos/$releasever/PowerTools/$basearch/os/
enabled=0
gpgcheck=1
gpgkey=t/centos/RPM-GPG-KEY-CentOS-Official
替换更新
1. 到跟新后po中[AppStream]标签内的内容并复制[AppStream]
name=Qcloud centos AppStream - $basearch
baseurl=t/centos/$releasever/AppStream/$basearch/os/
enabled=0
gpgcheck=1
gpgkey=t/centos/RPM-GPG-KEY-CentOS-Official
2. 打开po,注释掉原有内容,并插⼊新内容
[root@C8-3 ~]# vim /pos.po
#[AppStream]
#name=CentOS-$releasever - AppStream
#mirrorlist=/?release=$releasever&arch=$basearch&repo=AppStream&infra=$infra
#baseurl=/$contentdir/$releasever/AppStream/$basearch/os/
#mirrorlist=/$contentdir/$releasever/AppStream/$basearch/os/
#gpgcheck=1
#enabled=1
mysql下载app#pgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial
[AppStream]
name=Qcloud centos AppStream - $basearch
baseurl=t/centos/$releasever/AppStream/$basearch/os/
enabled=0
gpgcheck=1
gpgkey=t/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. 在修改⽂件内容时,添加新内容前,对原内容使⽤注释⽽⾮删除
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
发表评论