👻

[CentOS8.0以降]yum/dnf 実行時のエラー対策

2024/06/06に公開

概要

yum update / dnf update

実行時にエラーとなりリポジトリを更新することができない場合の対処について

きっかけ

digコマンドをいろいろ試すため、

#yum update bind-utils

を実行した際に失敗したため、エラー解消した際の対応をメモ

準備

digコマンドを使えるようにするため

# yum install bind-utils

を実行する。

ところが自分のCentOS 8.0ver以降の環境の場合、以下でひっかかった。

✕エラー内容:

[root@localhost yum.repos.d]# yum update
CentOS Stream 8 - AppStream                     0.0  B/s |   0  B     00:00
Errors during downloading metadata for repository 'appstream':
  - Curl error (6): Couldn't resolve host name for http://mirror.vault.org/centos/8-stream/AppStream/x86_64/os/repodata/repomd.xml [Could not resolve host: mirror.vault.org]
エラー: repo 'appstream' のメタデータのダウンロードに失敗しました : Cannot download repomd.xml: Cannot download repodata/repomd.xml: All mirrors were tried
[root@localhost yum.repos.d]# yum update
CentOS Stream 8 - AppStream                      18 MB/s |  29 MB     00:01
CentOS Stream 8 - BaseOS                         67  B/s |  38  B     00:00
エラー: repo 'baseos' のメタデータのダウンロードに失敗しました : Cannot prepare internal mirrorlist: No URLs in mirrorlist
[root@localhost yum.repos.d]# yum update
CentOS Stream 8 - BaseOS                        4.1 MB/s |  10 MB     00:02
CentOS Stream 8 - Extras                         97  B/s |  38  B     00:00
エラー: repo 'extras' のメタデータのダウンロードに失敗しました : Cannot prepare internal mirrorlist: No URLs in mirrorlist

以下を確認
・/etc/yum.repos.d/*.repo

[root@localhost yum.repos.d]# ll
合計 56
-rw-r--r--. 1 root root  748  6月  4 11:41 CentOS-Stream-AppStream.repo
-rw-r--r--. 1 root root  698  3月 28  2022 CentOS-Stream-BaseOS.repo
-rw-r--r--. 1 root root  316  3月 28  2022 CentOS-Stream-Debuginfo.repo
-rw-r--r--. 1 root root  744  3月 28  2022 CentOS-Stream-Extras-common.repo
-rw-r--r--. 1 root root  700  3月 28  2022 CentOS-Stream-Extras.repo
-rw-r--r--. 1 root root  734  3月 28  2022 CentOS-Stream-HighAvailability.repo
-rw-r--r--. 1 root root  696  3月 28  2022 CentOS-Stream-Media.repo
-rw-r--r--. 1 root root  683  3月 28  2022 CentOS-Stream-NFV.repo
-rw-r--r--. 1 root root  718  3月 28  2022 CentOS-Stream-PowerTools.repo
-rw-r--r--. 1 root root  690  3月 28  2022 CentOS-Stream-RealTime.repo
-rw-r--r--. 1 root root  748  3月 28  2022 CentOS-Stream-ResilientStorage.repo
-rw-r--r--. 1 root root 1771  3月 28  2022 CentOS-Stream-Sources.repo
-rw-r--r--. 1 root root 1036 10月 16  2015 mysql-community-source.repo
-rw-r--r--. 1 root root 1033  5月 27 15:09 mysql-community.repo

修正すべきrepoファイルは、yum updateを実行した際のログエラーメッセージで確認

自分の場合は

  • AppStream
  • BaseOS
  • Extras
    の3つ分の「CentOS-Stream-*.repo」ファイルを修正しました。
    すなはち、

CentOS-Stream-AppStream.repo
CentOS-Stream-BaseOS.repo
CentOS-Stream-Extras.repo

修正箇所の詳細はそれぞれ共通のため次の項目でメモ

修正内容

  1. 修正対象ファイルをエディタで修正(*例として「AppStream.repo」)

修正前

# CentOS-Stream-AppStream.repo
#
# The mirrorlist system uses the connecting IP address of the client and the
# update status of each mirror to pick current mirrors that are 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, you can try the commented out
# baseurl line instead.

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

修正後

# CentOS-Stream-AppStream.repo
#
# The mirrorlist system uses the connecting IP address of the client and the
# update status of each mirror to pick current mirrors that are 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, you can try the commented out
# baseurl line instead.

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

修正詳細

  1. ベースURLのコメントアウトをなくしURLを修正&ミラーサイトURLをコメントアウト
    ⭐︎mirrorlist部分をコメントアウト

⭐︎baseurlは"mirror"を"vault"へ修正

リポジトリ更新成功

[root@localhost yum.repos.d]# yum update
CentOS Stream 8 - Extras                         48 kB/s |  18 kB     00:00
CentOS Stream 8 - Extras common packages         60 kB/s | 8.0 kB     00:00
MySQL Connectors Community                      9.4 kB/s | 2.6 kB     00:00
MySQL Tools Community                            52 kB/s | 2.6 kB     00:00
MySQL 5.7 Community Server                       74 kB/s | 2.6 kB     00:00
依存関係が解決しました。
================================================================================
 パッケージ               Arch   バージョン                     Repo      サイズ
================================================================================
インストール:
 kernel                   x86_64 4.18.0-553.6.1.el8             baseos     10 M
アップグレード:

yum install bind-utils 実行

#yum install bind-utils

Discussion