栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 系统运维 > 运维 > Linux

Centos 8.1 yum 不能用更换 yum源

Linux 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

Centos 8.1 yum 不能用更换 yum源

安装软件或者执行yum makecache报错

[ root@HK ~]#yum install -y autofs
CentOS-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 autofs
CentOS-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 - base
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=baseOS&infra=$infra
#baseurl=http://mirror.centos.org/$contentdir/$releasever/baseOS/$basearch/os/
gpgcheck=1
enabled=1
gpgkey=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=$infra
baseurl=https://mirrors.aliyun.com/centos-vault/8.1.1911/baseOS/x86_64/os/
gpgcheck=0
enabled=1
gpgkey=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=$infra
baseurl=https://mirrors.aliyun.com/centos-vault/8.1.1911/baseOS/x86_64/os/
gpgcheck=0
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial
    执行下面两个命令后无报错即可
[ root@HK /etc/yum.repos.d]#yum clean all
32 files removed
[ root@HK /etc/yum.repos.d]#yum makecache
CentOS-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.
转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/724919.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号