PostgreSQL 12 起動時にエラー「FATAL: data directory “/xxx” has invalid permissions」が発生した場合の対処法

PostgreSQL 12 起動時にエラー「FATAL:  data directory “/xxx” has invalid permissions」が発生した場合の対処法

突然、PostgreSQL 12が起動できなくなったので、その際に行った原因調査と対処法を記載しておきます。

環境

  • CentOS Linux release 7.7.1908 (Core)
  • PostgreSQL 12.2

エラー全文

-- Unit postgresql-12.service has begun starting up.
[2704] FATAL:  data directory "/xxx" has invalid permissions
[2704] DETAIL:  Permissions should be u=rwx (0700) or u=rwx,g=rx (0750).
 systemd[1]: postgresql-12.service: main process exited, code=exited, status=1/FAILURE
 systemd[1]: Failed to start PostgreSQL 12 database server.
-- Subject: Unit postgresql-12.service has failed
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
-- 
-- Unit postgresql-12.service has failed.
-- 
-- The result is failed.
 systemd[1]: Unit postgresql-12.service entered failed state.
 systemd[1]: postgresql-12.service failed.
 polkitd[1038]: Unregistered Authentication Agent for unix-process:2689:32193 (system bus name :1.63, object path /org/freedesktop/PolicyKit1/Authent

エラー原因

データベースクラスタに指定したディレクトリのパーミッションが変更されていたため発生

対処法

対象のディレクトリのパーミッションをとりあえず、700に変更したところ改善

chmod -R 700 /xxx