Перейти к содержанию
На чтение 1 мин Просмотров 3.6к. Опубликовано 3 марта, 2022 Обновлено 3 марта, 2022
При попытке стандартным методом обновить операционную систему Centos 8 получаем следующую фигню:
[root@mail ~]# yum update
CentOS Linux 8 - AppStream 116 B/s | 38 B 00:00
Ошибка: Не удалось загрузить метаданные для репозитория «appstream»: Cannot prep are internal mirrorlist: No URLs in mirrorlist
Ну что, поздравляю. Centos 8 официально умер 31.12.2021 года.
Чтоб решить проблему с скачиванием нужных пакетов из официальных репозиториев, нужно перенаправить свои репозитории /etc/yum.repos.d/ на http://vault.centos.org вместо http://mirror.centos.org. Делается это следующим образом:
sed -i 's/mirrorlist/#mirrorlist/g' /etc/yum.repos.d/CentOS-Linux-*
sed -i 's|#baseurl=http://mirror.centos.org|baseurl=http://vault.centos.org|g' /etc/yum.repos.d/CentOS-Linux-*
Проверяем:
yum update
Заработало.
Но!!! Обновление безопасности вы получать не будете. Но вы можете перейти на SentOS Stream, выполнив команды:
dnf --disablerepo '*' --enablerepo extras swap centos-linux-repos centos-stream-repos
dnf distro-sync
После чего выполните перезагрузку
( 7 оценок, среднее 4.43 из 5 )
On my CentOS 8 server, many dnf
and yum
commands fail with this error:
Failed to download metadata for repo
This seems to apply only to repositories involving https connections, e.g.:
/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
...
I have used wget
to test connectivity to these sites and it is successful, e.g. wget https://mirrors.fedoraproject.org
succeeds.
However, various dnf
or yum
commands fail:
$ 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'
How do I resolve this problem?
asked Jan 30, 2020 at 20:00
2
I was getting the same error with the Centos8 build inside of a docker container. Fixed by running the below:
# Do on build
RUN dnf clean all && rm -r /var/cache/dnf && dnf upgrade -y && dnf update -y
Error before (i was running yum update and not 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'
Success after:
---> 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
answered Mar 8, 2020 at 8:16
2
I just faced this problem so I thought I’d add what fixed it for me since the resolution was pretty simple. For me, I was overlooking the fact that whenever I changed my hostname, it was wiping out everything in /etc/resolv.conf so I:
nano -w /etc/resolv.conf
**-
added the following lines:
nameserver 8.8.8.8 nameserver 8.8.4.4
- Test it (e.g.
yum update -y
)
**note: I used nano in example, simply swap the nano
portion for your own text editor of choice
answered Apr 29, 2020 at 22:41
If it does not work, check your Internet connection. This error appeared on my CentOS 8 installation, and the problem was that the Internet connection wasn’t correctly configured.
answered Feb 10, 2020 at 13:14
david.t_92david.t_92
1,9311 gold badge11 silver badges15 bronze badges
1
Just add the following (DNS server) to /etc/resolv.conf file:
nameserver 9.9.9.9
Will fix the issue
halfer
19.8k17 gold badges98 silver badges185 bronze badges
answered Apr 4, 2020 at 12:21
3
You may not realize it, but yum
and dnf
require SSL certificates when communicating via secure HTTP (aka HTTPS). Have you checked the certificates under /etc/pki/tls/certs
? There should be at least two, for example:
/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
If these links are missing you may be able to simply restore them. Otherwise, the files are part of the ca-certificates
package. You can obtain them from another server running your operating system via yumdownloader then restore your certificates from the resulting RPM file using yum --nogpgcheck localinstall <RPM file>
.
halfer
19.8k17 gold badges98 silver badges185 bronze badges
answered Jan 30, 2020 at 20:00
CODE-REaDCODE-REaD
2,7393 gold badges32 silver badges60 bronze badges
1
I was facing this issue when I tried to run
yum update -y
from a docker container. I changed the version from centos:8 to centos:7 and it solved the issue for me.
answered Mar 5, 2020 at 6:52
1
I had the same error after I was messing around with SD adapter to microSD card. Edit /etc/fstab
to remove SD line solved the issue for me.
answered Mar 27, 2020 at 10:47
I will confirm I recently had this issue and what fixed it for me was a change in the DNS servers. I had a static IP set but DNS was automatic, I had to reconfigure DNS to use my gateway and dc. This is working now.
answered Apr 23, 2020 at 14:15
My issue was that the interface wasn’t up after a fresh vm install.
Ran ifconfig
to find my interface name and then ifup eXXX
to get a dhcp ip address.
Also don’t forget to change ONBOOT=no
to ONBOOT=yes
in /etc/sysconfig/network-scripts/ifcfg-eXXX
so it comes up during next boot.
Mickael B.
4,6884 gold badges24 silver badges47 bronze badges
answered May 1, 2020 at 23:51
1
Having great difficulty tracking down what is causing the below error when attempting to update any package from any repo. I have tested multiple repos by setting all others to disabled. I have cleaned all cache and removed any dnf yum cache files.
# dnf -v update
Loaded plugins: builddep, changelog, config-manager, copr, debug, debuginfo-install, download, generate_completion_cache, needs-restarting, playground, repoclosure, repodiff, repograph, repomanage, reposync
DNF version: 4.2.7
cachedir: /var/cache/dnf
repo: downloading from remote: AppStream
error: Curl error (28): Timeout was reached for http://mirrorlist.centos.org/?release=8&arch=x86_64&repo=AppStream&infra=stock [Resolving timed out after 30000 milliseconds] (http://mirrorlist.centos.org/?release=8&arch=x86_64&repo=AppStream&infra=stock).
CentOS-8 - AppStream 0.0 B/s | 0 B 00:30
Cannot download 'http://mirrorlist.centos.org/?release=8&arch=x86_64&repo=AppStream&infra=stock': Cannot prepare internal mirrorlist: Curl error (28): Timeout was reached for http://mirrorlist.centos.org/?release=8&arch=x86_64&repo=AppStream&infra=stock [Resolving timed out after 30000 milliseconds].
Failed to download metadata for repo 'AppStream'
Error: Failed to download metadata for repo 'AppStream'
Each time I attempt a dnf update, load average on the server goes thru the roof, up to 40x
curl can access the mirror site.
curl 'http://mirrorlist.centos.org/?release=8&arch=x86_64&repo=AppStream&infra=stock'
http://ftp.tc.edu.tw/Linux/CentOS/8.2.2004/AppStream/x86_64/os/
http://mirror.horizon.vn/centos/8.2.2004/AppStream/x86_64/os/
http://ftp.jaist.ac.jp/pub/Linux/CentOS/8.2.2004/AppStream/x86_64/os/
http://centosg9.centos.org/centos/8.2.2004/AppStream/x86_64/os/
http://packet01.centos.org/centos/8.2.2004/AppStream/x86_64/os/
http://mirror.s8.centos.org/centos/8.2.2004/AppStream/x86_64/os/
http://centoso7.centos.org/centos/8.2.2004/AppStream/x86_64/os/
http://centosh9.centos.org/centos/8.2.2004/AppStream/x86_64/os/
http://centosc8.centos.org/centos/8.2.2004/AppStream/x86_64/os/
http://centosg7.centos.org/centos/8.2.2004/AppStream/x86_64/os/
I have also tried using baserurl in .repo, same error
I have also replaced the baseurl with one of the url’s returned by curl, same error
I have tried many suggestions such as yum/dnf error: Failed to download metadata for repo
and similar, none work for me.
Some articles point to bugs in the env vars for $releaseserver etc. I have also tried replacing with actual values. same error.
Internet connection obviously OK due to curl result.
No proxy used.
DNS OK
cat /etc/redhat-release
CentOS Linux release 8.1.1911 (Core)
uname -a
Linux xxxx 4.18.0-147.5.1.el8_1.x86_64 #1 SMP Wed Feb 5 02:00:39 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux
Any suggestions would be greatly appreciated.
При попытке обновить или установить пакеты из репозиториев CentOS 8 выдается следующая ошибка: «Ошибка: Не удалось загрузить метаданные для репозитория ?appstream?: Cannot prepare internal mirrorlist: No URLs in mirrorlist«.
На самом деле об этом предупреждали заранее разработчики CentOS, конкретнее от отказа разработки версий ОС и переход на Stream версию, подробнее об этом можно прочитать тут.
Чтоб решить проблему с скачиванием нужных пакетов из официальных репозиториев, нужно перенаправить свои репозитории /etc/yum.repos.d/ на http://vault.centos.org вместо http://mirror.centos.org. Делается это следующим образом:
sed -i 's/mirrorlist/#mirrorlist/g' /etc/yum.repos.d/CentOS-Linux-*
sed -i 's|#baseurl=http://mirror.centos.org|baseurl=http://vault.centos.org|g' /etc/yum.repos.d/CentOS-Linux-*
После чего репозитории будут доступны, но вы не будете получать обновления безопасности, т.к. CentOS 8 официально умерла 31.12.21. Но вы можете перейти на SentOS Stream, выполнив следующие команды:
dnf --disablerepo '*' --enablerepo extras swap centos-linux-repos centos-stream-repos
dnf distro-sync
После чего возможно потребуется перезагрузка. Более подробную информацию о переходе на centos strem можно получить тут.
If you, for one reason or the other, are still actively using CentOS 8, you might probably have encountered the following error when trying to update your system or simply install a package.
“Error: Failed to download metadata for repo ‘appstream’: Cannot prepare internal mirrorlist: No URLs in mirrorlist”
For example, in the screenshot that follows, I was trying to install the fio package and run into it.
На самом деле об этом предупреждали заранее разработчики CentOS, конкретнее от отказа разработки версий ОС и переход на Stream версию, подробнее об этом можно прочитать тут.
Чтоб решить проблему с скачиванием нужных пакетов из официальных репозиториев, нужно перенаправить свои репозитории /etc/yum.repos.d/ на http://vault.centos.org вместо http://mirror.centos.org. Делается это следующим образом:
sed -i 's/mirrorlist/#mirrorlist/g' /etc/yum.repos.d/CentOS-Linux-*
sed -i 's|#baseurl=http://mirror.centos.org|baseurl=http://vault.centos.org|g' /etc/yum.repos.d/CentOS-Linux-*
После чего репозитории будут доступны, но вы не будете получать обновления безопасности, т.к. CentOS 8 официально умерла 31.12.21. Но вы можете перейти на SentOS Stream, выполнив следующие команды:
dnf --disablerepo '*' --enablerepo extras swap centos-linux-repos centos-stream-repos
dnf distro-sync
После чего возможно потребуется перезагрузка. Более подробную информацию о переходе на centos strem можно получить тут.
If you, for one reason or the other, are still actively using CentOS 8, you might probably have encountered the following error when trying to update your system or simply install a package.
“Error: Failed to download metadata for repo ‘appstream’: Cannot prepare internal mirrorlist: No URLs in mirrorlist”
For example, in the screenshot that follows, I was trying to install the fio package and run into it.
What is the Cause of This Error?
You may well be aware that CentOS Linux 8 died a premature death, it reached the End Of Life (EOL) on December 31st, 2021, thus it no longer receives development resources from the official CentOS project.
This means that after Dec 31st, 2021, to update your CentOS installation, you are required to change the mirrors to CentOS Vault Mirror, where they will be archived permanently.
Fix Error: Failed to Download Metadata for Repo ‘AppStream’
To fix the above error, open your terminal or login via ssh, and run the following commands to change the repo URL to point to vault.centos.org, from the official CentOS repos.
Here we use the sed command to edit the required directives or parameters in the repo configuration files:
# sed -i 's/mirrorlist/#mirrorlist/g' /etc/yum.repos.d/CentOS-* # sed -i 's|#baseurl=http://mirror.centos.org|baseurl=http://vault.centos.org|g' /etc/yum.repos.d/CentOS-*
Alternatively, you can also point to the Cloudflare-based vault repository, by running the following commands:
# sed -i 's/mirrorlist/#mirrorlist/g' /etc/yum.repos.d/CentOS-Linux-* # sed -i 's|#baseurl=http://mirror.centos.org|baseurl=http://vault.epel.cloud|g' /etc/yum.repos.d/CentOS-Linux-*
Now you should be able to update CentOS or install packages without any error:
If you wish to migrate from CentOS 8 to Rock Linux 8 or AlamLinux 8, check these guides:
- How to Migrate from CentOS 8 to Rocky Linux 8
- How to Migrate from CentOS 8 to AlmaLinux 8.5
That’s all! We hope that this guide helped you fix the above-aforementioned error. Use the comment form below to share feedback with us, you can ask questions as well.
If you read this far, tweet to the author to show them you care. Tweet a thanks
Aaron Kili is a Linux and F.O.S.S enthusiast, an upcoming Linux SysAdmin, web developer, and currently a content creator for TecMint who loves working with computers and strongly believes in sharing knowledge.
Each tutorial at TecMint is created by a team of experienced Linux system administrators so that it meets our high-quality standards.