AlmaLinux 8.4 に Postgres13をインストールする

Alma Linux や Rocky LinuxなどCentOSの次世代闘争。

いろいろと台頭してきていますね^^

そんな中、Alma LinuxにPostgres13をインスコしたので参考までに。手順をメモしておきます。

時代の流れで(笑)yumじゃなくて、dnfを使っていきます。

sudo dnf list | grep postgresql

collectd-postgresql.x86_64                                        5.9.0-5.el8                                            epel            
freeradius-postgresql.x86_64                                      3.0.20-9.module_el8.5.0+2580+998f1584                  appstream       
opendbx-postgresql.x86_64                                         1.4.6-21.el8                                           epel            
pcp-pmda-postgresql.x86_64                                        5.3.1-5.el8                                            appstream       
pdns-backend-postgresql.x86_64                                    4.5.1-1.el8                                            epel            
perl-RDF-Trine-postgresql.noarch                                  1.019-8.el8                                            epel            
postgresql.x86_64                                                 10.17-2.module_el8.5.0+2551+8dca950a                   appstream       
postgresql-contrib.x86_64                                         10.17-2.module_el8.5.0+2551+8dca950a                   appstream       
postgresql-docs.x86_64                                            10.17-2.module_el8.5.0+2551+8dca950a                   appstream       
postgresql-jdbc.noarch                                            42.2.3-3.el8_2                                         appstream       
postgresql-jdbc-javadoc.noarch                                    42.2.3-3.el8_2                                         appstream       
postgresql-odbc.x86_64                                            10.03.0000-2.el8                                       appstream       
postgresql-odbc-tests.x86_64                                      10.03.0000-2.el8                                       appstream       
postgresql-plperl.x86_64                                          10.17-2.module_el8.5.0+2551+8dca950a                   appstream       
postgresql-plpython3.x86_64                                       10.17-2.module_el8.5.0+2551+8dca950a                   appstream       
postgresql-pltcl.x86_64                                           10.17-2.module_el8.5.0+2551+8dca950a                   appstream       
postgresql-server.x86_64                                          10.17-2.module_el8.5.0+2551+8dca950a                   appstream       
postgresql-server-devel.x86_64                                    10.17-2.module_el8.5.0+2551+8dca950a                   appstream       
postgresql-static.x86_64                                          10.17-2.module_el8.5.0+2551+8dca950a                   appstream       
postgresql-test.x86_64                                            10.17-2.module_el8.5.0+2551+8dca950a                   appstream       
postgresql-test-rpm-macros.x86_64                                 10.17-2.module_el8.5.0+2551+8dca950a                   appstream       
postgresql-upgrade.x86_64                                         10.17-2.module_el8.5.0+2551+8dca950a                   appstream       
postgresql-upgrade-devel.x86_64                                   10.17-2.module_el8.5.0+2551+8dca950a                   appstream       
postgresqltuner.noarch                                            1.0.1-4.el8                                            epel            
proftpd-postgresql.x86_64                                         1.3.6e-4.el8                                           epel            
python3-testing.postgresql.noarch                                 1.1.0-16.el8                                           epel            
qt5-qtbase-postgresql.i686                                        5.15.2-3.el8                                           appstream       
qt5-qtbase-postgresql.x86_64                                      5.15.2-3.el8                                           appstream       
soci-postgresql.x86_64                                            4.0.0-2.el8                                            epel            
soci-postgresql-devel.x86_64                                      4.0.0-2.el8                                            epel    

デフォルトだと10がインスコされるっぽいですね。

sudo dnf module list postgresql

AlmaLinux 8 - AppStream
Name                                  Stream                            Profiles                                     Summary                                                      
postgresql                            9.6                               client, server [d]                           PostgreSQL server and client module                          
postgresql                            10 [d]                            client, server [d]                           PostgreSQL server and client module                          
postgresql                            12                                client, server [d]                           PostgreSQL server and client module                          
postgresql                            13                                client, server [d]                           PostgreSQL server and client module         

Almaの公式リポジトリでは13までリリースされているみたいです。

公式リポジトリを追加

sudo dnf -y install https://download.postgresql.org/pub/repos/yum/reporpms/EL-8-x86_64/pgdg-redhat-repo-latest.noarch.rpm

これで追加しました。

13をインストールする前に

sudo dnf -qy module disable postgresql

どうも先に、dnfでデフォルトで指定されているpostgresqlを停止しないと行けないっぽいです。この手順を行わずに、普通にインストールに移ったところ、

sudo dnf -y install postgresql13 postgresql13-server

All matches were filtered out by modular filtering for argument: postgresql13
All matches were filtered out by modular filtering for argument: postgresql13-server
Error: Unable to find a match: postgresql13 postgresql13-server

と、エラーで弾かれました。CentOS8のdnfからの仕様みたいですね。CentOS8のyumを使ってもdnfが使われるみたいなのでこの手順、今後は必用になってきますね。

改めてインストール

sudo dnf -y install postgresql13 postgresql13-server

....

Installed:
  postgresql13-13.5-1PGDG.rhel8.x86_64                   postgresql13-libs-13.5-1PGDG.rhel8.x86_64                   postgresql13-server-13.5-1PGDG.rhel8.x86_64                  

Complete!

今度は無事インストールされました。

initdbで初期化

sudo /usr/pgsql-13/bin/postgresql-13-setup initdb

Ubuntu版では必用なかったのですが、CentOSでは変わらず必用。

自動起動を確認

systemctl list-unit-files -t service | grep postgres

postgresql-13.service                      disabled

動いてないので

sudo systemctl enable postgresql-13

これで自動起動をONに。

立ち上げます

sudo systemctl start postgresql-13
sudo systemctl status postgresql-13.service

● postgresql-13.service - PostgreSQL 13 database server
   Loaded: loaded (/usr/lib/systemd/system/postgresql-13.service; enabled; vendor preset: disabled)
   Active: active (running) since Tue 2021-11-16 12:18:53 JST; 1min 6s ago
     Docs: https://www.postgresql.org/docs/13/static/
  Process: 1492208 ExecStartPre=/usr/pgsql-13/bin/postgresql-13-check-db-dir ${PGDATA} (code=exited, status=0/SUCCESS)
 Main PID: 1492214 (postmaster)
    Tasks: 8 (limit: 24328)

起動しました。

設定ファイル周りは

/var/lib/pgsql/13/data

ここに格納されていました。