13
5

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

CentOS8でdnfコマンドを実行して「エラー: repo 'AppStream' のメタデータのダウンロードに失敗しました : Cannot prepare internal mirrorlist: No URLs in mirrorlist」が発生した場合の対処法

Last updated at Posted at 2022-03-23

1. 前書き

CentOS8でdnf check-updateコマンドを実行したところ、以下のエラーが発生しました。

[root@centos8 ~]# dnf check-update
CentOS-8 - AppStream                             67  B/s |  38  B     00:00
エラー: repo 'AppStream' のメタデータのダウンロードに失敗しました : Cannot prepare internal mirrorlist: No URLs in mirrorlist
[root@centos8 ~]#

この時の対処法をメモとして残します。

2. 原因

原因はCentOS8はEOLを迎えており、リポジトリのミラーリストhttp://mirror.centos.orgが使えなくなったためかと思われます。
 
/etc/yum.repos.d配下を見てみます。

実行結果
[root@centos8 ~]# cd /etc/yum.repos.d
[root@centos8 yum.repos.d]# ls
CentOS-AppStream.repo  CentOS-Extras.repo      CentOS-Vault.repo
CentOS-Base.repo       CentOS-HA.repo          CentOS-centosplus.repo
CentOS-CR.repo         CentOS-Media.repo       CentOS-fasttrack.repo
CentOS-Debuginfo.repo  CentOS-PowerTools.repo  mysql-community-source.repo
CentOS-Devel.repo      CentOS-Sources.repo     mysql-community.repo
[root@centos8 yum.repos.d]#

 
さらに、CentOS-AppStream.repoを参照しています。

実行結果
[root@centos8 yum.repos.d]# cat CentOS-AppStream.repo
# CentOS-AppStream.repo
#
# The mirror system uses the connecting IP address of the client and the
# update status of each mirror to pick mirrors that are updated to and
# geographically close to the client.  You should use this for CentOS updates
# unless you are manually picking other mirrors.
#
# If the mirrorlist= does not work for you, as a fall back you can try the
# remarked out baseurl= line instead.
#
#

[AppStream]
name=CentOS-$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/
gpgcheck=1
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial

[root@centos8 yum.repos.d]#

「mirrorlist=http://mirrorlist.centos.org/~~」をコメント化し、「#baseurl=http://mirror.centos.org/~~」のコメントを外し、「http://mirror.centos.org/」を「http://vault.centos.org/」に変更するとよさそうです。

3. 解決方法

/etc/yum.repos.d配下について、以下のsedコマンドで置換します。

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-*

 

この後に、dnf check-updateコマンドを実行すると、正常に動作しました。

[root@centos8 yum.repos.d]# dnf check-update
CentOS-8 - AppStream     [===                 ] ---  B/s |   0  B     --:-- ETACentOS-8 - AppStream 46% [=========           ]  13 MB/s | 3.9 MB     00:00 ETACentOS-8 - AppStream                             25 MB/s | 8.4 MB     00:00    
CentOS-8 - Base          [===                 ] ---  B/s |   0  B     --:-- ETACentOS-8 - Base                                  17 MB/s | 4.6 MB     00:00    
CentOS-8 - Extras        [   ===              ] ---  B/s |   0  B     --:-- ETACentOS-8 - Extras                                52 kB/s |  10 kB     00:00    
MySQL 8.0 Community      [      ===           ] ---  B/s |   0  B     --:-- ETAMySQL 8.0 Community Server                       10 MB/s | 2.3 MB     00:00    
MySQL Connectors Com     [         ===        ] ---  B/s |   0  B     --:-- ETAMySQL Connectors Community                      637 kB/s |  80 kB     00:00    
MySQL Tools Communit     [            ===     ] ---  B/s |   0  B     --:-- ETAMySQL Tools Community                           2.6 MB/s | 432 kB     00:00    

ModemManager.x86_64                    1.10.8-4.el8                    BaseOS   
ModemManager-glib.x86_64               1.10.8-4.el8                    BaseOS   
~~~
~~~
webkit2gtk3.x86_64                     2.32.3-2.el8                    AppStream
    webkit2gtk3.x86_64                 2.24.4-2.el8_1                  @AppStream
webkit2gtk3.x86_64                     2.32.3-2.el8                    AppStream
    webkit2gtk3-plugin-process-gtk2.x86_64
                                       2.24.4-2.el8_1                  @AppStream
[root@centos8 yum.repos.d]#

以上

13
5
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
13
5

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?