COD*_*EaD 17 centos repository yum dnf
在我的CentOS 8服务器,许多dnf
和yum
命令失败,此错误:
无法为 repo 下载元数据
这似乎仅适用于涉及 https 连接的存储库,例如:
/etc/yum.repos.d $ cat epel-modular.repo
[epel-modular]
name=Extra Packages for Enterprise Linux Modular $releasever - $basearch/pub/epel/$releasever/Modular/$basearch
metalink=https://mirrors.fedoraproject.org/metalink?repo=epel-modular-$releasever&arch=$basearch&infra=$infra&content=$contentdir
...
Run Code Online (Sandbox Code Playgroud)
我曾经wget
测试过与这些站点的连接并且它是成功的,例如wget https://mirrors.fedoraproject.org
成功。
但是,各种dnf
或yum
命令失败:
$ dnf provides /bin/ls
Extra Packages for Enterprise Linux Modular 8 - x86_64 0.0 B/s | 0 B 00:00
Failed to download metadata for repo 'epel-modular'
Error: Failed to download metadata for repo 'epel-modular'
# dnf update --refresh
CentOS-8 - AppStream 20 kB/s | 4.3 kB 00:00
CentOS-8 - Base 19 kB/s | 3.8 kB 00:00
CentOS-8 - Extras 7.4 kB/s | 1.5 kB 00:00
CentOS-8 - PowerTools 20 kB/s | 4.3 kB 00:00
Remi's Modular repository for Enterprise Linux 8 - x86_64 4.1 kB/s | 3.5 kB 00:00
Safe Remi's RPM repository for Enterprise Linux 8 - x86_64 3.6 kB/s | 3.0 kB 00:00
Wazuh repository 0.0 B/s | 0 B 00:00
Failed to download metadata for repo 'wazuh_repo'
Error: Failed to download metadata for repo 'wazuh_repo'
Run Code Online (Sandbox Code Playgroud)
我该如何解决这个问题?
nep*_*unk 16
就我而言
sudo rm -r /var/cache/dnf
Run Code Online (Sandbox Code Playgroud)
解决了我的问题。
来源:https : //access.redhat.com/discussions/4222851
小智 7
我在 docker 容器中构建 Centos8 时遇到了同样的错误。通过运行以下命令修复:
# Do on build
RUN dnf clean all && rm -r /var/cache/dnf && dnf upgrade -y && dnf update -y
Run Code Online (Sandbox Code Playgroud)
之前的错误(我正在运行 yum update 而不是 dnf):
Step 4/5 : RUN yum clean all && yum update -y && echo hostname -a
---> Running in 10d319da361d
0 files removed
CentOS-8 - AppStream 0.0 B/s | 0 B 00:05
Failed to download metadata for repo 'AppStream'
Error: Failed to download metadata for repo 'AppStream'
Run Code Online (Sandbox Code Playgroud)
成功后:
---> 0b96049ee5eb
Step 4/5 : RUN dnf clean all && rm -r /var/cache/dnf && dnf upgrade -y && dnf update -y & echo hostname
---> Running in f928c6da6cb0
hostname
Removing intermediate
Run Code Online (Sandbox Code Playgroud)
小智 6
我刚刚遇到了这个问题,所以我想我会为我添加修复它的内容,因为解决方案非常简单。对我来说,我忽略了这样一个事实:每当我更改主机名时,它都会清除 /etc/resolv.conf 中的所有内容,所以我:
nano -w /etc/resolv.conf
**添加了以下几行:
nameserver 8.8.8.8
nameserver 8.8.4.4
Run Code Online (Sandbox Code Playgroud)yum update -y
)**注意:我在示例中使用了 nano,只需将nano
部分替换为您自己选择的文本编辑器
您可能没有意识到,通过安全 HTTP (又名HTTPS )进行通信时yum
需要dnf
SSL 证书。您检查过下面的证书吗?至少应该有两个,例如:/etc/pki/tls/certs
/etc/pki/tls/certs# ls -l
total 4
lrwxrwxrwx 1 root root 49 Jan 30 12:48 ca-bundle.crt -> /etc/pki/ca-trust/extracted/pem/tls-ca-bundle.pem
lrwxrwxrwx 1 root root 55 Dec 11 13:19 ca-bundle.trust.crt -> /etc/pki/ca-trust/extracted/openssl/ca-bundle.trust.crt
Run Code Online (Sandbox Code Playgroud)
如果这些链接丢失,您也许可以简单地恢复它们。否则,这些文件是ca-certificates
包的一部分。您可以通过yumdownloader从运行您的操作系统的另一台服务器获取它们,然后使用 .restore 从生成的 RPM 文件中恢复您的证书yum --nogpgcheck localinstall <RPM file>
。
归档时间: |
|
查看次数: |
101283 次 |
最近记录: |