thumb

中山テック 代表の中山です。

さて、勉強用にCentOSを使ってますが各種ソフトウェアがインストールできない状態に。

2024年6月30日にサポートも終了し、別OSを検討している方も多い中ですがタイトルのエラーの解消法をメモとして残したいと思います。



Nginxをyumインストールしようとした所、下記のエラーが発生。

# yum -y install nginx

読み込んだプラグイン:fastestmirror, langpacks
Loading mirror speeds from cached hostfile
Could not retrieve mirrorlist http://mirrorlist.centos.org/?release=7&arch=x86_64&repo=os&infra=stock error was
14: curl#6 - "Could not resolve host: mirrorlist.centos.org; 不明なエラー"


 One of the configured repositories failed (不明),
 and yum doesn't have enough cached data to continue. At this point the only
 safe thing yum can do is fail. There are a few ways to work "fix" this:

     1. Contact the upstream for the repository and get them to fix the problem.

     2. Reconfigure the baseurl/etc. for the repository, to point to a working
        upstream. This is most often useful if you are using a newer
        distribution release than is supported by the repository (and the
        packages for the previous distribution release still work).

     3. Run the command with the repository temporarily disabled
            yum --disablerepo=<repoid> ...

     4. Disable the repository permanently, so yum won't use it by default. Yum
        will then just ignore the repository until you permanently enable it
        again or use --enablerepo for temporary usage:

            yum-config-manager --disable <repoid>
        or
            subscription-manager repos --disable=<repoid>

     5. Configure the failing repository to be skipped, if it is unavailable.
        Note that yum will try to contact the repo. when it runs most commands,
        so will have to try and fail each time (and thus. yum will be be much
        slower). If it is a very temporary problem though, this is often a nice
        compromise:

            yum-config-manager --save --setopt=<repoid>.skip_if_unavailable=true

Cannot find a valid baseurl for repo: base/7/x86_64

ブラウザから当該URLにアクセスしてみましたが何も表示されない404が返却されていました。

リポジトリ修正

# cd /etc/yum.repos.d/

# ls -ltr
合計 40
-rw-r--r--. 1 root root  616 11月 24  2020 CentOS-x86_64-kernel.repo
-rw-r--r--. 1 root root  314 11月 24  2020 CentOS-fasttrack.repo
-rw-r--r--. 1 root root 8515 11月 24  2020 CentOS-Vault.repo
-rw-r--r--. 1 root root 1331 11月 24  2020 CentOS-Sources.repo
-rw-r--r--. 1 root root  630 11月 24  2020 CentOS-Media.repo
-rw-r--r--. 1 root root  649 11月 24  2020 CentOS-Debuginfo.repo
-rw-r--r--. 1 root root 1309 11月 24  2020 CentOS-CR.repo
-rw-r--r--. 1 root root 1664 11月 24  2020 CentOS-Base.repo

という訳でリポジトリの情報を修正します。

初期段階では8個のリポジトリが存在しております。

一旦変更するのは上記ピンクで塗られたリポジトリです。

CentOS-x86_64-kernel.repo

「mirrorlist=http://mirrorlist.centos.org/?~」とmirrorlistが定義してあるのでエラーとなっております。

mirrorlistをコメントアウトし、baseurlの「vault.centos.org」ドメインにアクセスします。

CentOS-fasttrack.repo

#CentOS-fasttrack.repo

[fasttrack]
name=CentOS-7 - fasttrack
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=fasttrack&infra=$infra
baseurl=http://vault.centos.org/centos/$releasever/fasttrack/$basearch/
gpgcheck=1
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

CentOS-Base.repo

# CentOS-Base.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.
#
#

[base]
name=CentOS-$releasever - Base
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os&infra=$infra
baseurl=http://vault.centos.org/centos/$releasever/os/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

#released updates
[updates]
name=CentOS-$releasever - Updates
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates&infra=$infra
baseurl=http://vault.centos.org/centos/$releasever/updates/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

#additional packages that may be useful
[extras]
name=CentOS-$releasever - Extras
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras&infra=$infra
baseurl=http://vault.centos.org/centos/$releasever/extras/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-$releasever - Plus
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=centosplus&infra=$infra
baseurl=http://vault.centos.org/centos/$releasever/centosplus/$basearch/
gpgcheck=1
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

インストール

例としてPostgreSQLをインストールしてみましょう

# yum -y install postgresql

読み込んだプラグイン:fastestmirror, langpacks
Loading mirror speeds from cached hostfile
依存性の解決をしています
--> トランザクションの確認を実行しています。
---> パッケージ postgresql.x86_64 0:9.2.24-9.el7_9 を インストール
--> 依存性の処理をしています: postgresql-libs(x86-64) = 9.2.24-9.el7_9 のパッケージ: postgresql-9.2.24-9.el7_9.x86_64
--> 依存性の処理をしています: libpq.so.5()(64bit) のパッケージ: postgresql-9.2.24-9.el7_9.x86_64
--> トランザクションの確認を実行しています。
---> パッケージ postgresql-libs.x86_64 0:9.2.24-9.el7_9 を インストール
--> 依存性解決を終了しました。

~~~~~~~~中略~~~~~~~~~~

Running transaction
  インストール中          : postgresql-libs-9.2.24-9.el7_9.x86_64                                                                                                                        1/2
  インストール中          : postgresql-9.2.24-9.el7_9.x86_64                                                                                                                             2/2
  検証中                  : postgresql-9.2.24-9.el7_9.x86_64                                                                                                                             1/2
  検証中                  : postgresql-libs-9.2.24-9.el7_9.x86_64                                                                                                                        2/2

インストール:
  postgresql.x86_64 0:9.2.24-9.el7_9

依存性関連をインストールしました:
  postgresql-libs.x86_64 0:9.2.24-9.el7_9

完了しました!

OKです!

が、Ver9は古いのでこちらのページを参考にしリポジトリをインストールしましょう!

※もし他でエラーが出たらURLの変更等で解決してみてください

PostgreSQL15インストール時にエラー

「postgresql15-server.x86_64」インストール時にエラーが出たので下記の通りに修正します。

# vi CentOS-SCLo-scl-rh.repo

# CentOS-SCLo-rh.repo
#
# Please see http://wiki.centos.org/SpecialInterestGroup/SCLo for more
# information

[centos-sclo-rh]
name=CentOS-7 - SCLo rh
baseurl=http://vault.centos.org/centos/7/sclo/$basearch/rh/
#mirrorlist=http://vault.centos.org/centos/7/sclo?arch=$basearch&release=7&repo=sclo-rh
#baseurl=http://vault.centos.org/centos/$releasever/sclo/$basearch/rh/
gpgcheck=1
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-SIG-SCLo

[centos-sclo-rh-testing]
name=CentOS-7 - SCLo rh Testing
baseurl=http://buildlogs.centos.org/centos/7/sclo/$basearch/rh/
gpgcheck=0
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-SIG-SCLo

[centos-sclo-rh-source]
name=CentOS-7 - SCLo rh Sources
baseurl=http://vault.centos.org/centos/7/sclo/Source/rh/
gpgcheck=1
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-SIG-SCLo

[centos-sclo-rh-debuginfo]
name=CentOS-7 - SCLo rh Debuginfo
baseurl=http://debuginfo.centos.org/centos/7/sclo/$basearch/
gpgcheck=1
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-SIG-SCLo

2ファイル目も

# vi CentOS-SCLo-scl.repo

# CentOS-SCLo-sclo.repo
#
# Please see http://wiki.centos.org/SpecialInterestGroup/SCLo for more
# information

[centos-sclo-sclo]
name=CentOS-7 - SCLo sclo
baseurl=http://vault.centos.org/centos/7/sclo/$basearch/sclo/
#mirrorlist=http://mirrorlist.centos.org?arch=$basearch&release=7&repo=sclo-sclo
gpgcheck=1
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-SIG-SCLo

[centos-sclo-sclo-testing]
name=CentOS-7 - SCLo sclo Testing
baseurl=http://buildlogs.centos.org/centos/7/sclo/$basearch/sclo/
gpgcheck=0
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-SIG-SCLo

[centos-sclo-sclo-source]
name=CentOS-7 - SCLo sclo Sources
baseurl=http://vault.centos.org/centos/7/sclo/Source/sclo/
gpgcheck=1
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-SIG-SCLo

[centos-sclo-sclo-debuginfo]
name=CentOS-7 - SCLo sclo Debuginfo
baseurl=http://debuginfo.centos.org/centos/7/sclo/$basearch/
gpgcheck=1
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-SIG-SCLo


まとめ

サポートも切れてそろそろ新しいOS入れなきゃと思う方は微妙に使えないかもしれません。

が、勉強用に使う方や「リポジトリ」についての考え方が参考になったと思って頂けたら幸いです。

最後までご覧いただき、ありがとうございました。

おすすめの記事