[CentOS7] PostgreSQL9.6のYumリポジトリインストールでエラー(pgdg-centos96-9.6-3.noarch.rpmが消えた)

事象

CentOS7にPostgreSQL9.6を久しぶりにインストールしようとしたところ、Yumリポジトリのインストールでエラーが発生しました。
どうやらつい最近 pgdg-centos96-9.6-3.noarch.rpm が消えたようです。

# yum install https://download.postgresql.org/pub/repos/yum/9.6/redhat/rhel-7-x86_64/pgdg-centos96-9.6-3.noarch.rpm
Loaded plugins: fastestmirror, ovl
Cannot open: https://download.postgresql.org/pub/repos/yum/9.6/redhat/rhel-7-x86_64/pgdg-centos96-9.6-3.noarch.rpm. Skipping.
Error: Nothing to do

対策

PostgreSQL: Linux downloads (Red Hat family)で確認できるURLでインストールできます。
CentOS7にPostgreSQL9.6をインストールする場合は https://download.postgresql.org/pub/repos/yum/reporpms/EL-7-x86_64/pgdg-redhat-repo-latest.noarch.rpm です。

# yum install https://download.postgresql.org/pub/repos/yum/reporpms/EL-7-x86_64/pgdg-redhat-repo-latest.noarch.rpm
... 

Installed:
  pgdg-redhat-repo.noarch 0:42.0-11                                                                                                                                                   

Complete!

これで無事インストールできました。

# yum install postgresql96-server
...
Installed:
  postgresql96-server.x86_64 0:9.6.18-1PGDG.rhel7                                                                                                                                     

Dependency Installed:
  postgresql96.x86_64 0:9.6.18-1PGDG.rhel7                    postgresql96-libs.x86_64 0:9.6.18-1PGDG.rhel7                    systemd-sysv.x86_64 0:219-73.el7_8.8                   

Dependency Updated:
  systemd.x86_64 0:219-73.el7_8.8                                                         systemd-libs.x86_64 0:219-73.el7_8.8                                                        

Complete!

追記(2022/5/12)

9.6はEOLを迎えたため、現在では以下の手順でインストールする必要があります。

Repo RPMs - PostgreSQL YUM Repository

# cat << EOF > /etc/yum.repos.d/pgdg-96.repo
[pgdg96]
name=PostgreSQL 9.6 RPMs for RHEL/CentOS 7
baseurl=https://yum-archive.postgresql.org/9.6/redhat/rhel-7-x86_64
enabled=1
gpgcheck=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-PGDG
EOF

# yum install postgresql96-server