PostgreSQL 11 起動時にエラー「”/var/lib/pgsql/11/data/” is missing or empty.」が発生した場合の対処法

PostgreSQL 11 起動時にエラー「”/var/lib/pgsql/11/data/” is missing or empty.」が発生した場合の対処法

PostgreSQL 11がエラー「”/var/lib/pgsql/11/data/” is missing or empty.」で起動できなかったので、その際の対処法を記述。

環境

  • CentOS Linux release 7.7.1908 (Core)
  • PostgreSQL 11.7

エラー全文

-- Unit postgresql-11.service has begun starting up.
 postgresql-11-check-db-dir[4111]: "/var/lib/pgsql/11/data/" is missing or empty.
 postgresql-11-check-db-dir[4111]: Use "/usr/pgsql-11/bin/postgresql-11-setup initdb" to initialize the database cluster.
 postgresql-11-check-db-dir[4111]: See /usr/share/doc/postgresql11-11.7/README.rpm-dist for more information.
 systemd[1]: postgresql-11.service: control process exited, code=exited status=1
 systemd[1]: Failed to start PostgreSQL 11 database server.
-- Subject: Unit postgresql-11.service has failed
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
-- 
-- Unit postgresql-11.service has failed.
-- 
-- The result is failed.
 systemd[1]: Unit postgresql-11.service entered failed state.
 systemd[1]: postgresql-11.service failed.
 polkitd[1038]: Unregistered Authentication Agent for unix-process:4105:446605 (system bus name :1.96, object path /org/freedesktop/PolicyKit1/Authen

対処方法

エラー内容に記載してあるとおり、下記のコマンドで初期化後に、実行すれば改善した
※運用中のデータがある場合は、初期化されるので注意

/usr/pgsql-11/bin/postgresql-11-setup initdb

<出力結果>
Initializing database ... OK