EPEL 的全称叫 Extra Packages for Enterprise Linux。EPEL 是由 Fedora 社区打造,为 RHEL 及衍生发行版如 CentOS、Scientific Linux 等提供高质量软件包的项目。装上了 EPEL 之后,就相当于添加了一个第三方源。所以恨过高质量的第三方工具都依赖这个EPEL源,但是在依照docs.fedoraproject.org官方发布的教程指引安装EPEL到RedHat(RHEL)/CentOS8后会出现StatusCode:404问题。因此本教程依照RHEL官网论坛的解决方法来修正这个问题,以便于以后的参考。
[如果您认为本文章帮助到了您,请在文章末尾“打赏”作者,感谢!]
展开索引
操作环境
RedHat 8.1
Azure VM B2m SKU
问题复现
1.根据Fedora官方文档安装Extra Packages for Enterprise Linux (EPEL) :
dnf install https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm
2. 尝试安装任何来自于EPEL源的工具包,比如ansible,会报告错误 :
Errors during downloading metadata for repository 'epel-modular': - Status code: 404 for https://mirrors.fedoraproject.org/metalink?repo=epel-modular-8.2&arch=x86_64&infra=$infra&content=$contentdir (IP: 38.145.60.21) - Status code: 404 for https://mirrors.fedoraproject.org/metalink?repo=epel-modular-8.2&arch=x86_64&infra=$infra&content=$contentdir (IP: 8.43.85.67) - Status code: 404 for https://mirrors.fedoraproject.org/metalink?repo=epel-modular-8.2&arch=x86_64&infra=$infra&content=$contentdir (IP: 38.145.60.20) Error: Failed to download metadata for repo 'epel-modular': Cannot prepare internal mirrorlist: Status code: 404 for https://mirrors.fedoraproject.org/metalink?repo=epel-modular-8.2&arch=x86_64&infra=$infra&content=$contentdir (IP: 38.145.60.21) Extra Packages for Enterprise Linux 8.2 - x86_64 93 kB/s | 67 kB 00:00 Errors during downloading metadata for repository 'epel': - Status code: 404 for https://mirrors.fedoraproject.org/metalink?repo=epel-8.2&arch=x86_64&infra=$infra&content=$contentdir (IP: 67.219.144.68) - Status code: 404 for https://mirrors.fedoraproject.org/metalink?repo=epel-8.2&arch=x86_64&infra=$infra&content=$contentdir (IP: 38.145.60.21) Error: Failed to download metadata for repo 'epel': Cannot prepare internal mirrorlist: Status code: 404 for https://mirrors.fedoraproject.org/metalink?repo=epel-8.2&arch=x86_64&infra=$infra&content=$contentdir (IP: 67.219.144.68) Red Hat Enterprise Linux 8 for x86_64 - BaseOS - Extended Update Support from RHUI (RP 17 MB/s | 21 MB 00:01 Red Hat Enterprise Linux 8 for x86_64 - AppStream - Extended Update Support from RHUI 15 MB/s | 19 MB 00:01 Microsoft Azure RPMs for RHEL8 Extended Update Support 6.8 kB/s | 1.5 kB 00:00 Ignoring repositories: epel-modular, epel Dependencies resolved. Nothing to do. Complete!
问题根源
EPEL的Repos源包含$releasever变量。默认值是8,但是如果系统通过/etc/yum/vars/releasever将release锁定到8以外的数值或者为空的时候,则会遇到404错误。
解决方法
1. 直接修改并替换所有epel*.repo中关键字$releasever为8 (推荐优先使用这个方法):
sed -i 's/$releasever/8/g' /etc/yum.repos.d/epel*.repo
2. 修改/etc/yum/vars/releasever为8(此方法仅作为备用方案,默认不推荐,因为会涉及到整个Repos请求的变更):
# 备份原始文件 cp -rp /etc/yum/vars/releasever /etc/yum/vars/releasever.bak # 复写文件内容为8 echo 8 > /etc/yum/vars/releasever
参考文献
- Extra Packages for Enterprise Linux (EPEL) :: Fedora Docs (fedoraproject.org)
- 404 error trying to install EPEL – Red Hat Customer Portal
(全文完)
文章撰写:AndyX,来自AndyX.Net。本文由AndyX收集整理发布。