Error: Failed to download metadata for repo ‘appstream‘: Cannot prepare internal mirrorlist

用 Docker 创建 Centos8 容器后,打算安装net-tools工具
执行yum -y install net-tools提示错误:

[root@71165717f07b /]# yum install net-tool
Failed to set locale, defaulting to C.UTF-8
CentOS Linux 8 - AppStream                                                                                  88  B/s |  38  B     00:00
Error: Failed to download metadata for repo 'appstream': Cannot prepare internal mirrorlist: No URLs in mirrorlist

解决:

  1. 先ping一下百度确认服务器网络没问题:

    [root@71165717f07b /]# ping baidu.com
    PING baidu.com (39.156.66.10) 56(84) bytes of data.
    64 bytes from 39.156.66.10 (39.156.66.10): icmp_seq=1 ttl=47 time=42.10 ms
    64 bytes from 39.156.66.10 (39.156.66.10): icmp_seq=2 ttl=47 time=42.10 ms
    64 bytes from 39.156.66.10 (39.156.66.10): icmp_seq=3 ttl=47 time=43.1 ms
    64 bytes from 39.156.66.10 (39.156.66.10): icmp_seq=4 ttl=47 time=43.1 ms
    64 bytes from 39.156.66.10 (39.156.66.10): icmp_seq=5 ttl=47 time=43.7 ms
    64 bytes from 39.156.66.10 (39.156.66.10): icmp_seq=6 ttl=47 time=46.9 ms
    64 bytes from 39.156.66.10 (39.156.66.10): icmp_seq=7 ttl=47 time=43.1 ms
    64 bytes from 39.156.66.10 (39.156.66.10): icmp_seq=8 ttl=47 time=51.7 ms
    64 bytes from 39.156.66.10 (39.156.66.10): icmp_seq=9 ttl=47 time=43.9 ms
    ^C
    --- baidu.com ping statistics ---
    9 packets transmitted, 9 received, 0% packet loss, time 8011ms
    rtt min/avg/max/mdev = 42.950/44.598/51.686/2.777 ms
    
  2. 如果网络没问题,那就是yum源的问题,更换一下:
    Ⅰ 进入到 yum 的仓库目录

    cd /etc/yum.repos.d/
    

    Ⅱ 注释所有CentOS-开头文件中的所有mirrorlist开头的行

    sed -i 's|mirrorlist|#mirrorlist|g' /etc/yum.repos.d/CentOS-*
    

    Ⅲ 修改所有CentOS-开头文件中的 yum 源为http://vault.centos.org

    sed -i 's|#baseurl=http://mirror.centos.org|baseurl=http://vault.centos.org|g' /etc/yum.repos.d/CentOS-*
    

    Ⅳ 生成新缓存

    yum makecache
    

    Ⅴ 更新 yum 列表

    yum update -y
    
  3. 重新安装需要的软件
    yum -y install net-tools

2020 年 12 月 8 号,CentOS 官方宣布了停止维护 CentOS Linux 的计划,并推出了 CentOS Stream 项目,即 CentOS Linux 8,但是 CentOS Linux 8 也于2021 年 12 月 31 日停止更新并停止维护,如果需要更新或下载东西,需要将镜像从 mirror.centos.org 更改为 vault.centos.org

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值