CentOS 8にPostgreSQL 9.6をインストール（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)より、2021-11がEOLだと思われる。
それ以降に報告された脆弱性や不具合への対応は実施されない可能性がある。

## LOG

### インストール

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

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

# /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:52:50 EDT; 3s ago
  Process: 22342 ExecStartPre=/usr/libexec/postgresql-check-db-dir postgresql (code=exited, status=0/SUCCESS)
 Main PID: 22345 (postmaster)
    Tasks: 7 (limit: 11121)
   Memory: 15.3M
   CGroup: /system.slice/postgresql.service
           tq22345 /usr/bin/postmaster -D /var/lib/pgsql/data
           tq22346 postgres: logger process
           tq22348 postgres: checkpointer process
           tq22349 postgres: writer process
           tq22350 postgres: wal writer process
           tq22351 postgres: autovacuum launcher process
           mq22352 postgres: stats collector process

Sep 26 09:52:50 localhost.localdomain systemd[1]: Starting PostgreSQL database server...
Sep 26 09:52:50 localhost.localdomain postmaster[22345]: LOG:  redirecting log output to logging collector process
Sep 26 09:52:50 localhost.localdomain postmaster[22345]: HINT:  Future log output will appear in directory "pg_log".
Sep 26 09:52:50 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: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.
Sep 26 09:52:50 localhost.localdomain systemd[1]: Starting PostgreSQL database server...
Sep 26 09:52:50 localhost.localdomain postmaster[22345]: LOG:  redirecting log output to logging collector process
Sep 26 09:52:50 localhost.localdomain postmaster[22345]: HINT:  Future log output will appear in directory "pg_log".
Sep 26 09:52:50 localhost.localdomain systemd[1]: Started PostgreSQL database server.
Sep 26 09:53:31 localhost.localdomain systemd[1]: Stopping PostgreSQL database server...
Sep 26 09:53:31 localhost.localdomain systemd[1]: postgresql.service: Killing process 22346 (postmaster) with signal SIGKILL.
Sep 26 09:53:31 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) 9.6.10
```