0
0

CentOS構築後yum,dnfコマンドエラーによりパッケージのDLが出来ない問題の対処備忘録

Posted at

前置き

CentOSを構築完了後dnfやyumコマンドを使ってパッケージをDLしようとしたら下記のようなエラーが発生しました。

[taki@localhost ~]$ sudo yum upgrade
CentOS Linux 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://mirrorlist.centos.org/?release=8&arch=x86_64&repo=AppStream&infra=stock [Could not resolve host: mirrorlist.centos.org]
Error: Failed to download metadata for repo 'appstream': Cannot prepare internal mirrorlist: Curl error (6): Couldn't resolve host name for http://mirrorlist.centos.org/?release=8&arch=x86_64&repo=AppStream&infra=stock [Could not resolve host: mirrorlist.centos.org]
[taki@localhost ~]$
[taki@localhost ~]$ sudo dnf install glibc-langpack-ja

CentOS Linux 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://mirrorlist.centos.org/?release=8&arch=x86_64&repo=AppStream&infra=stock [Could not resolve host: mirrorlist.centos.org]
Error: Failed to download metadata for repo 'appstream': Cannot prepare internal mirrorlist: Curl error (6): Couldn't resolve host name for http://mirrorlist.centos.org/?release=8&arch=x86_64&repo=AppStream&infra=stock [Could not resolve host: mirrorlist.centos.org]
[taki@localhost ~]$ 

原因
どうやらCentOSのサポート終了に伴い、Yum リポジトリの設定で、[base] に書かれたデータ取得先 URL がおかしいと言われているようです。

コマンドを正常に使用できるよう、リポジトリの記載内容を変更して対処します。

対処

Yum リポジトリの設定は、/etc/yum.repos.d/ 以下にあります。

[base] の URL は CentOS-Base.repo というファイルに記述されています。
元の URL を # でコメントアウトし、適切な URL を追記します。

sudo nano /etc/yum.repos.d/CentOS-Linux-BaseOS.repo 

<リポジトリのリスト>
image.png

<修正前>
image.png

下記コードを追加しmirrorlistをコメントアウトする

baseurl=http://vault.centos.org/$contentdir/$releasever/BaseOS/$basearch/os/

<修正後>
image.png

上記の要領で下記それぞれのファイルにも実施していきます。

[taki@localhost ~]$ sudo nano /etc/yum.repos.d/CentOS-Linux-AppStream.repo 
[taki@localhost ~]$ 
[taki@localhost ~]$ sudo nano /etc/yum.repos.d/CentOS-Linux-BaseOS.repo 
[taki@localhost ~]$ 
[taki@localhost ~]$ sudo nano /etc/yum.repos.d/CentOS-Linux-Extras.repo 

ファイルの修正が終わった後、パッケージのDLが出来るか確認してください。

以上で設定は終了です。お疲れ様でした。

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