ablog

不器用で落着きのない技術者のメモ

Amazon Linux 2 に yum で Pgpool-II をインストールしようとすると "rhel-2-x86_64/repodata/repomd.xml: [Errno 14] HTTPS Error 404 - Not Found" と怒られる

事象

  • Amazon Linux 2 に yum で Pgpool-II をインストールしようとすると "rhel-2-x86_64/repodata/repomd.xml: [Errno 14] HTTPS Error 404 - Not Found" と怒られる。
$ sudo yum install -y https://www.pgpool.net/yum/rpms/4.1/redhat/rhel-7-x86_64/pgpool-II-release-4.1-2.noarch.rpm
$ sudo yum -y install pgpool-II-pg11
Loaded plugins: extras_suggestions, langpacks, priorities, update-motd
amzn2-core                                                                                                                                            | 3.7 kB  00:00:00
amzn2extra-docker                                                                                                                                     | 3.0 kB  00:00:00
http://www.pgpool.net/yum/rpms/4.1/redhat/rhel-2-x86_64/repodata/repomd.xml: [Errno 14] HTTPS Error 404 - Not Found
Trying other mirror.


 One of the configured repositories failed (pgpool-II 4.1 2 - x86_64),
 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=pgpool41 ...

     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 pgpool41
        or
            subscription-manager repos --disable=pgpool41

     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=pgpool41.skip_if_unavailable=true

failure: repodata/repomd.xml from pgpool41: [Errno 256] No more mirrors to try.
http://www.pgpool.net/yum/rpms/4.1/redhat/rhel-2-x86_64/repodata/repomd.xml: [Errno 14] HTTPS Error 404 - Not Found

原因

/etc/yum.repos.d/pgpool-II-release-41.repo の以下の URL に

baseurl=http://www.pgpool.net/yum/rpms/4.1/redhat/rhel-$releasever-$basearch 

Yum 変数 $releasever-$basearch をセットした結果が

http://www.pgpool.net/yum/rpms/4.1/redhat/rhel-2-x86_64

となってしまっている。正しくは以下の通り。

http://www.pgpool.net/yum/rpms/4.1/redhat/rhel-7-x86_64

Yum 変数 $releasever は /etc/yum.conf の distroverpkg=system-release を参照、つまり、/etc/system-release から値を取得するが、中身が "Amazon Linux release 2 (Karoo)" のため rhel-2 となってしまっている(rhel-7としたい)。

解決策

  • /etc/yum.repos.d の $releasever を 7 に置換する。
$ cd /etc/yum.repos.d
$ sudo perl -i.org -pe 's/\$releasever/7/g' pgpool-II-release-41.repo
  • pgpool-II をインストール
$ sudo yum -y install pgpool-II-pg11

(中略)

Installed:
  pgpool-II-pg11.x86_64 0:4.1.3-1pgdg.rhel7

Dependency Installed:
  libmemcached.x86_64 0:1.0.16-5.amzn2.0.2                                            postgresql-libs.x86_64 0:9.2.24-1.amzn2.0.1

Complete!

参考

9.5.3. yum 変数の使用
yum コマンドおよびすべての yum 設定ファイル (つまり /etc/yum.conf および /etc/yum.repos.d/ ディレクトリー内のすべての .repo ファイル) 内で、以下の組み込み変数を使用および参照できます。

$releasever
この変数を使用すると、Red Hat Enterprise Linux のリリースバージョンを参照できます。yum は /etc/yum.conf 設定ファイルにある distroverpkg=value の行から $releasever の値を取得します。/etc/yum.conf にそのような行がない場合、yumredhat-release ファイルを提供する redhat-releaseproduct パッケージからバージョン番号を取得することで、正しい値を推測します。
$arch
この変数を使用して、Python の os.uname() 関数を呼び出す時に返り値としてシステムの CPU アーキテクチャーを参照できます。$arch の有効な値は、i586i686x86_64 です。

9.5. Yum と Yum リポジトリーの設定 Red Hat Enterprise Linux 7 | Red Hat Customer Portal

RHEL/CentOS 7.x

  • Pgpool-II 4.1
# yum install https://www.pgpool.net/yum/rpms/4.1/redhat/rhel-7-x86_64/pgpool-II-release-4.1-2.noarch.rpm
Yum Repository - pgpool Wiki

リポジトリファイルには変数 $releasever と $basearch があるが、AmazonLinux 2 では、 $releaserver は system-release のバージョン番号で、$basearch はアーキテクチャのようだ。確認したところ、 system-release は "release 2" なので $releaserver は "2" となる。$basearch はアーキテクチャで "x86_64" となる。

Amazon Linux 2 にPostgreSQL 11 をインストールする - Qiita