欢迎您访问365答案网,请分享给你的朋友!
生活常识 学习资料

Centos8.1yum不能用更换yum源

时间:2023-08-30
安装软件或者执行yum makecache报错

[ root@HK ~]#yum install -y autofsCentOS-8 - AppStream 50 B/s | 38 B 00:00 Failed to download metadata for repo 'AppStream'Error: Failed to download metadata for repo 'AppStream'

还原快照后突然发现安装软件报错了

[ root@HK ~]#yum install -y autofsCentOS-8 - AppStream 50 B/s | 38 B 00:00 Failed to download metadata for repo 'AppStream'Error: Failed to download metadata for repo 'AppStream'

查看yum.repos.d,发现 base.repoAppStream.repo 里面的 baseurl地址已经访问不了了

[baseOS]name=CentOS-$releasever - basemirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=baseOS&infra=$infra#baseurl=http://mirror.centos.org/$contentdir/$releasever/baseOS/$basearch/os/gpgcheck=1enabled=1gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial

进入阿里官网找到 centos8 的 repo

centos8.1的 repo

复制这个链接 修改base.repo,加上注释 mirrorlist,注释掉 baseurl,粘贴链接在 baseurl后面

[ root@HK /etc/yum.repos.d]#vim CentOS-base.repo [baseOS]name=CentOS-8.1 - base#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=baseOS&infra=$infrabaseurl=https://mirrors.aliyun.com/centos-vault/8.1.1911/baseOS/x86_64/os/gpgcheck=0enabled=1gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial

修改 AppStream.repo ,加上注释 mirrorlist,注释掉 baseurl,粘贴链接在 baseurl 后面

[ root@HK /etc/yum.repos.d]#vim CentOS-AppStream.repo [AppStream]name=CentOS-8.1 - AppStream#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=AppStream&infra=$infrabaseurl=https://mirrors.aliyun.com/centos-vault/8.1.1911/baseOS/x86_64/os/gpgcheck=0enabled=1gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial

执行下面两个命令后无报错即可

[ root@HK /etc/yum.repos.d]#yum clean all32 files removed[ root@HK /etc/yum.repos.d]#yum makecacheCentOS-8.1 - AppStream 3.2 MB/s | 2.2 MB 00:00 CentOS-8.1 - base 8.3 MB/s | 2.2 MB 00:00 CentOS-8 - Extras 15 kB/s | 10 kB 00:00 metadata cache created.

Copyright © 2016-2020 www.365daan.com All Rights Reserved. 365答案网 版权所有 备案号:

部分内容来自互联网,版权归原作者所有,如有冒犯请联系我们,我们将在三个工作时内妥善处理。