信息

执行命令 yum install nginx 出现报错:

yum install nginx
Repository epel is listed more than once in the configuration
CentOS Linux 8 - AppStream                                                                           96  B/s |  38  B     00:00    
Error: Failed to download metadata for repo 'appstream': Cannot prepare internal mirrorlist: No URLs in mirrorlist

原因

由于 CentOS 8 及之后版本官方将不再继续维护,在 2022 年 1 月 31 日 CentOS 已从官方镜像中移除 CentOS 8 的所有包。

虽然 CentOS 8 已于 2021 年 12 月 31 日停止维护用更新,但软件包仍在官方镜像上保留了一段时间。现在他们被转移到 https://vault.centos.org

方案​

如果在此情形下仍然继续运行 CentOS 8,用户可以在/etc/yum.repos 中更新 repos.d 使用 vault.centos.org 代替 mirror.centos.org。

切换到 repos 目录并编辑 baseOS.repo 文件;

cd /etc/yum.repos.d/
vi CentOS-Linux-BaseOS.repo
[baseos]
name=CentOS Linux $releasever - BaseOS
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=BaseOS&infra=$infra
#baseurl=http://mirror.centos.org/$contentdir/$releasever/BaseOS/$basearch/os/
baseurl=https://vault.centos.org/centos/$releasever/BaseOS/$basearch/os/
gpgcheck=1
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial

编辑 AppStream.repo 文件;

vi CentOS-Linux-AppStream.repo
[appstream]
name=CentOS Linux $releasever - AppStream
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=AppStream&infra=$infra
#baseurl=http://mirror.centos.org/$contentdir/$releasever/AppStream/$basearch/os/
baseurl=https://vault.centos.org/centos/$releasever/AppStream/$basearch/os/ 
gpgcheck=1
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial

成功安装 Nginx!

yum install nginx
Repository epel is listed more than once in the configuration
CentOS Linux 8 - AppStream      1.3 MB/s | 8.4 MB     00:06    
CentOS Linux 8 - BaseOS         1.2 MB/s | 4.6 MB     00:03    
CentOS Linux 8 - Extras                                                                             1.1 kB/s | 1.5 kB     00:01    
CentOS Linux 8 - Extras                                                                             4.1 kB/s |  11 kB     00:02    
Extra Packages for Enterprise Linux Modular 8 - x86_64                                              9.7 kB/s | 9.8 kB     00:01    
Extra Packages for Enterprise Linux Modular 8 - x86_64                                              558 kB/s | 979 kB     00:01    
nginx stable repo                                                                                   6.7 kB/s | 2.9 kB     00:00    
Remi's Modular repository for Enterprise Linux 8 - x86_64                                           220  B/s | 833  B     00:03    
Remi's Modular repository for Enterprise Linux 8 - x86_64                                            28 kB/s | 970 kB     00:34    
Safe Remi's RPM repository for Enterprise Linux 8 - x86_64                                          455  B/s | 833  B     00:01    
Safe Remi's RPM repository for Enterprise Linux 8 - x86_64                                           14 kB/s | 2.1 MB     02:28    
Package nginx-1:1.20.2-1.el8.ngx.x86_64 is already installed.
Dependencies resolved.
Nothing to do.
Complete!
分类: 系统运维

0 条评论

发表回复

Avatar placeholder

您的电子邮箱地址不会被公开。