Ubuntu 16.04でpostgres sqlを使用する問題

Ubuntu 16.04でpostgres sqlを使用する問題

私はUbuntu 16.04 OSを実行しており、最近提供された指示を使用してpostgresをインストールしました。https://www.digitalocean.com/community/tutorials/how-to-install-and-use-postgresql-on-ubuntu-16-04

しかし、Postgresを使用しようとすると

snowbell@snowbell-Aspire-4738Z:/var/www$ sudo -i -u postgres
postgres@snowbell-Aspire-4738Z:~$ psql

次のエラーメッセージが表示されます。

psql: could not connect to server: No such file or directory
Is the server running locally and accepting
connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"?
postgres@snowbell-Aspire-4738Z:~$ sudo -u postgres psql
postgres is not in the sudoers file.  This incident will be reported.

このエラーを取り除くために、次のように試しました。

snowbell@snowbell-Aspire-4738Z:~$ sudo -u postgres psql -p 5432 -h 127.0.0.1

その結果、次のエラーが発生します。

psql: could not connect to server: Connection refused
Is the server running on host "127.0.0.1" and accepting
TCP/IP connections on port 5432?

どんな手がかりがありますか?

出力は次のとおりです ここに画像の説明を入力してください。

これは Sample_error ファイル blissini です。

ここに画像の説明を入力してください。

ベストアンサー1

コメントで提案された内容をすべて使用した場合、エラー自体はpostgresqlサーバーが起動する前に競合を引き起こす誤った構成に関連している可能性があります。

次のガイドラインに従ってください。

  1. postgresqlサービスが実行されていることを確認するには、次を使用します。sudo service postgresql start

  2. pg_lsclusters端末で実行

  3. 実行中のクラスタを確認したら、出力は次のようになります。

バージョン - クラスタポートステータス所有者データディレクトリ

9.6 ------- main -- 5432 online postgres /var/lib/postgresql/9.6/main
  1. バージョンとクラスタから情報をコピーして、次のように使用します。 pg_ctlcluster <version> <cluster> start例:pg_ctlcluster 9.6 main start

  2. 問題が発生するとpostgresql、からアクセスできるログが生成されます/var/log/postgresql/postgresql-<version>-main.log。例:

2017-07-13 16:53:04 BRT [32176-1] LOG: invalid authentication method "all" 
2017-07-13 16:53:04 BRT [32176-2] CONTEXT: line 90 of configuration file "/etc/postgresql/9.5/main/pg_hba.conf" 
2017-07-13 16:53:04 BRT [32176-3] FATAL: could not load pg_hba.conf

ログに表示されるエラーが何であれ、修正して次のようにしてpostgresqlサービスを再起動してください。

sudo service postgresql restart

おすすめ記事