问题分析
第一种情况:网络连接问题
第二种情况:Centos停止维护的问题
问题解决
第一步,进入/etc/repos.d目录
root@localhost ~]# cd /etc/yum.repos.d/
第二步,修改文件内容
[root@localhost yum.repos.d]# sed -i 's/mirrorlist/#mirrorlist/g' /etc/yum.repos.d/CentOS-*
[root@localhost yum.repos.d]# sed -i 's|#baseurl=http://mirror.centos.org|baseurl=http://vault.centos.org|g' /etc/yum.repos.d/CentOS-*
第三步,生成缓存
[root@localhost yum.repos.d]# yum makecache
CentOS Linux 8 - AppStream 2.8 MB/s | 8.4 MB 00:03
CentOS Linux 8 - BaseOS 2.3 MB/s | 4.6 MB 00:01
CentOS Linux 8 - Extras 8.1 kB/s | 10 kB 00:01
Metadata cache created.
第四步,重新安装
[root@localhost yum.repos.d]# yum update -y
[root@localhost yum.repos.d]# yum install -y tree
Last metadata expiration check: 0:04:41 ago on Mon 08 Apr 2024 02:03:04 PM CST.
Package tree-1.7.0-15.el8.x86_64 is already installed.
Dependencies resolved.
Nothing to do.
Complete!