用 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
解决:
-
先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
-
如果网络没问题,那就是
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
-
重新安装需要的软件
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