CentOS8 にPostgreSQL 14をインストールする

環境

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
# cat /etc/redhat-release
CentOS Stream release 8
# cat /etc/redhat-release CentOS Stream release 8
# cat /etc/redhat-release
CentOS Stream release 8

操作方法
1.リポジトリを追加します

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
# sudo dnf install -y https://download.postgresql.org/pub/repos/yum/reporpms/EL-8-x86_64/pgdg-redhat-repo-latest.noarch.rpm
# sudo dnf install -y https://download.postgresql.org/pub/repos/yum/reporpms/EL-8-x86_64/pgdg-redhat-repo-latest.noarch.rpm
# sudo dnf install -y https://download.postgresql.org/pub/repos/yum/reporpms/EL-8-x86_64/pgdg-redhat-repo-latest.noarch.rpm

2.既存のモジュールを無効にします

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
# sudo dnf -qy module disable postgresql
# sudo dnf -qy module disable postgresql
# sudo dnf -qy module disable postgresql

3.「dnf」コマンドでPostgreSQL 14をインストールします

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
# sudo dnf install -y postgresql14-server
# sudo dnf install -y postgresql14-server
# sudo dnf install -y postgresql14-server

4.PostgreSQL 14初期化を行います

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
# sudo /usr/pgsql-14/bin/postgresql-14-setup initdb
Initializing database ... OK
# sudo /usr/pgsql-14/bin/postgresql-14-setup initdb Initializing database ... OK
# sudo /usr/pgsql-14/bin/postgresql-14-setup initdb
Initializing database ... OK

5.PostgreSQL起動設定と開始を行います

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
# sudo systemctl enable --now postgresql-14
Created symlink /etc/systemd/system/multi-user.target.wants/postgresql-14.service → /usr/lib/systemd/system/postgresql-14.service.
# sudo systemctl enable --now postgresql-14 Created symlink /etc/systemd/system/multi-user.target.wants/postgresql-14.service → /usr/lib/systemd/system/postgresql-14.service.
# sudo systemctl enable --now postgresql-14
Created symlink /etc/systemd/system/multi-user.target.wants/postgresql-14.service → /usr/lib/systemd/system/postgresql-14.service.

6.PostgreSQLを開始します
# sudo systemctl start postgresql-14

ステータスを確認します

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
# systemctl status postgresql-14
● postgresql-14.service - PostgreSQL 14 database server
Loaded: loaded (/usr/lib/systemd/system/postgresql-14.service; enabled; vend>
Active: active (running) since Fri 2022-11-11 18:48:53 EST; 45s ago
Docs: https://www.postgresql.org/docs/14/static/
# systemctl status postgresql-14 ● postgresql-14.service - PostgreSQL 14 database server Loaded: loaded (/usr/lib/systemd/system/postgresql-14.service; enabled; vend> Active: active (running) since Fri 2022-11-11 18:48:53 EST; 45s ago Docs: https://www.postgresql.org/docs/14/static/
#  systemctl status postgresql-14
● postgresql-14.service - PostgreSQL 14 database server
   Loaded: loaded (/usr/lib/systemd/system/postgresql-14.service; enabled; vend>
   Active: active (running) since Fri 2022-11-11 18:48:53 EST; 45s ago
     Docs: https://www.postgresql.org/docs/14/static/

 

CentOS Stream 8

Posted by arkgame