CentOS Linux 8的yum源失效解决

问题描述

CentOS Linux 8 yum源下载软件失败:
在这里插入图片描述

yum update
CentOS Linux 8 - AppStream                                                                                          14  B/s |  38  B     00:02
Error: Failed to download metadata for repo 'appstream': Cannot prepare internal mirrorlist: No URLs in mirrorlist

问题原因

CentOS Linux 8在2022年12月31日来到生命周期终点(End of Life,EoL)。即CentOS Linux 8操作系统版本结束了生命周期(EOL),Linux社区已不再维护该操作系统版本。所以原来的CentOS Linux 8的yum源也都失效了!最终导致此问题的产生。

问题解决方法

更换CentOS Linux 8的yum源

1、切换到源目录,备份原来的源

[root@localhost data]# cd /etc/yum.repos.d/
[root@localhost yum.repos.d]# mkdir bak
[root@localhost yum.repos.d]# mv CentOS-Linux-* bak
[root@localhost yum.repos.d]# ls
bak

2、下载新的源文件,并用命令yum makecache建立新的元数据缓存

下载源文件命令:

wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-vault-8.5.2111.repo
[root@localhost yum.repos.d]# wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-vault-8.5.2111.repo
--2022-11-05 08:53:51--  https://mirrors.aliyun.com/repo/Centos-vault-8.5.2111.repo
Resolving mirrors.aliyun.com (mirrors.aliyun.com)... 117.161.156.242, 117.161.156.239, 117.161.156.243, ...
Connecting to mirrors.aliyun.com (mirrors.aliyun.com)|117.161.156.242|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 2495 (2.4K) [application/octet-stream]
Saving to: ‘/etc/yum.repos.d/CentOS-Base.repo’

/etc/yum.repos.d/CentOS-Base.repo    100%[=====================================================================>]   2.44K  --.-KB/s    in 0.02s

2022-11-05 08:53:53 (133 KB/s) - ‘/etc/yum.repos.d/CentOS-Base.repo’ saved [2495/2495]

[root@localhost yum.repos.d]# ls
bak  CentOS-Base.repo
[root@localhost yum.repos.d]# vim CentOS-Base.repo
[root@localhost yum.repos.d]# yum makecache
CentOS-8.5.2111 - Base - mirrors.aliyun.com                                                                        171 kB/s | 4.6 MB     00:27
CentOS-8.5.2111 - Extras - mirrors.aliyun.com                                                                       35 kB/s |  10 kB     00:00
CentOS-8.5.2111 - AppStream - mirrors.aliyun.com                                                                   139 kB/s | 8.4 MB     01:02
Metadata cache created.
[root@localhost yum.repos.d]#

3、测试源(用yum命令装个软件试试)

[root@localhost yum.repos.d]# yum install -y yum-utils
Last metadata expiration check: 0:08:11 ago on Sat 05 Nov 2022 08:55:50 AM CST.
Dependencies resolved.
===================================================================================================================================================
 Package                             Architecture                     Version                                 Repository                      Size
===================================================================================================================================================
Installing:
 yum-utils                           noarch                           4.0.21-3.el8                            base                            73 k

Transaction Summary
===================================================================================================================================================
Install  1 Package

Total download size: 73 k
Installed size: 22 k
Downloading Packages:
yum-utils-4.0.21-3.el8.noarch.rpm                                                                                   15 kB/s |  73 kB     00:04
---------------------------------------------------------------------------------------------------------------------------------------------------
Total                                                                                                               15 kB/s |  73 kB     00:04
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Preparing        :                                                                                                                           1/1
  Installing       : yum-utils-4.0.21-3.el8.noarch                                                                                             1/1
  Running scriptlet: yum-utils-4.0.21-3.el8.noarch                                                                                             1/1
  Verifying        : yum-utils-4.0.21-3.el8.noarch                                                                                             1/1

Installed:
  yum-utils-4.0.21-3.el8.noarch

Complete!
[root@localhost yum.repos.d]#

你可能感兴趣的:(centos)