CentOS 8にPostgreSQL 10をインストール（AppStream）

# はじめに

Application Stream(AppStream)を利用してCentOS8にPostgreSQL 10をインストール
親記事：そのうち作成予定
参考：[RHEL8のパッケージ構成 - BaseOSとApplication Stream - 赤帽エンジニアブログ]( https://rheb.hatenablog.com/entry/rhel8_baseos_and_appstream)

## サポート

本手法で導入した場合、[Red Hat Enterprise Linux 8 Application Streams Life Cycle - Red Hat Customer Portal](https://access.redhat.com/node/4079021)より、2024-05がEOLだと思われる。
それ以降に報告された脆弱性や不具合への対応は実施されない可能性がある。

## LOG

### インストール

```shell-session
# cat /etc/redhat-release
CentOS Linux release 8.0.1905 (Core)

# yum install -y @postgresql:10
... 略

# /usr/bin/postgresql-setup --initdb
... 略
```

### postgresql起動/停止

```shell-session
# systemctl start postgresql
# systemctl status postgresql
● postgresql.service - PostgreSQL database server
   Loaded: loaded (/usr/lib/systemd/system/postgresql.service; disabled; vendor preset: disabled)
   Active: active (running) since Thu 2019-09-26 09:42:01 EDT; 1min 35s ago
  Process: 20736 ExecStartPre=/usr/libexec/postgresql-check-db-dir postgresql (code=exited, status=0/SUCCESS)
 Main PID: 20739 (postmaster)
    Tasks: 8 (limit: 11121)
   Memory: 16.4M
   CGroup: /system.slice/postgresql.service
           tq20739 /usr/bin/postmaster -D /var/lib/pgsql/data
           tq20740 postgres: logger process
           tq20742 postgres: checkpointer process
           tq20743 postgres: writer process
           tq20744 postgres: wal writer process
           tq20745 postgres: autovacuum launcher process
           tq20746 postgres: stats collector process
           mq20747 postgres: bgworker: logical replication launcher

Sep 26 09:42:01 localhost.localdomain systemd[1]: Starting PostgreSQL database server...
Sep 26 09:42:01 localhost.localdomain postmaster[20739]: 2019-09-26 09:42:01.657 EDT [20739] LOG:  listening on IPv6 address "::1", port 5432
Sep 26 09:42:01 localhost.localdomain postmaster[20739]: 2019-09-26 09:42:01.657 EDT [20739] LOG:  listening on IPv4 address "127.0.0.1", port 5432
Sep 26 09:42:01 localhost.localdomain postmaster[20739]: 2019-09-26 09:42:01.663 EDT [20739] LOG:  listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
Sep 26 09:42:01 localhost.localdomain postmaster[20739]: 2019-09-26 09:42:01.674 EDT [20739] LOG:  listening on Unix socket "/tmp/.s.PGSQL.5432"
Sep 26 09:42:01 localhost.localdomain postmaster[20739]: 2019-09-26 09:42:01.696 EDT [20739] LOG:  redirecting log output to logging collector process
Sep 26 09:42:01 localhost.localdomain postmaster[20739]: 2019-09-26 09:42:01.696 EDT [20739] HINT:  Future log output will appear in directory "log".
Sep 26 09:42:01 localhost.localdomain systemd[1]: Started PostgreSQL database server.
```

```shell-session
# systemctl stop postgresql
# systemctl status postgresql
● postgresql.service - PostgreSQL database server
   Loaded: loaded (/usr/lib/systemd/system/postgresql.service; disabled; vendor preset: disabled)
   Active: inactive (dead)

Sep 26 09:42:01 localhost.localdomain postmaster[20739]: 2019-09-26 09:42:01.657 EDT [20739] LOG:  listening on IPv6 address "::1", port 5432
Sep 26 09:42:01 localhost.localdomain postmaster[20739]: 2019-09-26 09:42:01.657 EDT [20739] LOG:  listening on IPv4 address "127.0.0.1", port 5432
Sep 26 09:42:01 localhost.localdomain postmaster[20739]: 2019-09-26 09:42:01.663 EDT [20739] LOG:  listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
Sep 26 09:42:01 localhost.localdomain postmaster[20739]: 2019-09-26 09:42:01.674 EDT [20739] LOG:  listening on Unix socket "/tmp/.s.PGSQL.5432"
Sep 26 09:42:01 localhost.localdomain postmaster[20739]: 2019-09-26 09:42:01.696 EDT [20739] LOG:  redirecting log output to logging collector process
Sep 26 09:42:01 localhost.localdomain postmaster[20739]: 2019-09-26 09:42:01.696 EDT [20739] HINT:  Future log output will appear in directory "log".
Sep 26 09:42:01 localhost.localdomain systemd[1]: Started PostgreSQL database server.
Sep 26 09:44:22 localhost.localdomain systemd[1]: Stopping PostgreSQL database server...
Sep 26 09:44:22 localhost.localdomain systemd[1]: postgresql.service: Killing process 20740 (postmaster) with signal SIGKILL.
Sep 26 09:44:22 localhost.localdomain systemd[1]: Stopped PostgreSQL database server.
```

### postgresql自動起動設定/設定解除

```shell-session
# systemctl enable postgresql
Created symlink /etc/systemd/system/multi-user.target.wants/postgresql.service → /usr/lib/systemd/system/postgresql.service.

# systemctl list-unit-files --type=service |grep postgresql
postgresql.service                          enabled
postgresql@.service                         disabled
```

```shell-session
# systemctl disable postgresql
Removed /etc/systemd/system/multi-user.target.wants/postgresql.service.

# systemctl list-unit-files --type=service |grep postgresql
postgresql.service                          disabled
postgresql@.service                         disabled
```

### 各種確認

```shell-session
# which postgres
/usr/bin/postgres

# which psql
/usr/bin/psql

# psql --version
psql (PostgreSQL) 10.6
```