posgtresqlを起動できません。理由は不明です。

posgtresqlを起動できません。理由は不明です。

pacmanを介してpostgresqlをインストールしました。今実行しようとしています。

    $ sudo systemctl start postgresql
    Job for postgresql.service failed because the control process exited with error code.
    See "systemctl status postgresql.service" and "journalctl -xe" for details.

それから:

    $ sudo systemctl status postgresql
    ● postgresql.service - PostgreSQL database server
       Loaded: loaded (/usr/lib/systemd/system/postgresql.service; disabled; vendor preset: disabled)
       Active: failed (Result: exit-code) since Sun 2016-07-10 15:30:47 UTC; 17s ago
      Process: 19468 ExecStartPre=/usr/bin/postgresql-check-db-dir ${PGROOT}/data (code=exited, status=1/FAILURE)

    Jul 10 15:30:47 my_comp systemd[1]: Starting PostgreSQL database server...
    Jul 10 15:30:47 my_comp systemd[1]: postgresql.service: Control process exited, code=exited status=1
    Jul 10 15:30:47 my_comp systemd[1]: Failed to start PostgreSQL database server.
    Jul 10 15:30:47 my_comp systemd[1]: postgresql.service: Unit entered failed state.
    Jul 10 15:30:47 my_comp systemd[1]: postgresql.service: Failed with result 'exit-code'.

何の問題がありますか?

ベストアンサー1

次の手順に従って問題を解決してください。

ステップ1:データディレクトリを作成する(以前に設定ファイルに設定されたPGROOT変数に基づく)

sudo mkdir /var/lib/postgres/data

ステップ2:/var/lib/postgres/dataの所有権をユーザー「postgres」に設定する

chown postgres /var/lib/postgres/data

ステップ3:「postgres」ユーザーとしてデータベースを起動します。

sudo -i -u postgres
initdb  -D '/var/lib/postgres/data'

ステップ4:rootでサービスを開始する

おすすめ記事