PostgreSQLを9.6にVerUPするためにPostgreSQL9.6一式をインストールしpsqlですでにインストールされているPsogreSQL9.3に接続したところ標記のメッセージが出ました。
[環境]
CentOS6
すでにインストールされているPotgreSQLのVer : 9.3.15
インストールしたPostgreSQLのVer : 9.6.1
[実施事項]
# yum -y localinstall https://yum.postgresql.org/9.6/redhat/rhel-6.7-x86_64/pgdg-centos96-9.6-3.noarch.rpm
# yum install postgresql96*
$ psql
psql: サーバに接続できませんでした: そのようなファイルやディレクトリはありません
ローカルにサーバが稼動していますか?
Unixドメインソケット"/var/run/postgresql/.s.PGSQL.5432"で通信を受け付けていますか?
$ netstat -antu
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address Foreign Address State
---略---
tcp 0 0 0.0.0.0:5432 0.0.0.0:* LISTEN
---略---
[解決方法]
psqlに -h /tmpとオプションをつけて実行
$ psql -h /tmp
psql (9.6.1, サーバー 9.3.15)
"help" でヘルプを表示します.
ap2=#
[切り分け]
/var/run/postgresql/.s.PGSQL.5432
というファイルの存在を確認したところありませんでした。
.s.PGSQL.5432がどこにあるかを確認したところ/tmpにありました。
$ ls -l /tmp/.s.PGSQL.5432
srwxrwxrwx 1 postgres postgres 0 11月 18 21:38 2016 /tmp/.s.PGSQL.5432
psql は-hで、Unixドメインソケット用のディレクトリを指定できるので、-h /tmpとオプションをつけたところ接続できるようになりました。
今までは/tmpにあるUnixドメインソケットを探しに行っていたと思うのですが、どうして/var/run/postgresql/を探しにいくようになったのかが分からないです。
9.6のpostgresql.confのunix_socket_directoriesの値を見ると
#unix_socket_directories = '/var/run/postgresql, /tmp' # comma-separated list of directories
となっています。
一方、9.3のpostgresql.confのunix_socket_directoriesの値を見ると
#unix_socket_directories = '/tmp' # comma-separated list of directories
となっています。
postgresql-9.6を起動してpsqlで接続したところ-h /tmpのオプションをつけずに接続できました。
UNIXドメインソケットは/var/run/postgresqlにできていました。
$ ls -l /var/run/postgresql/.s.PGSQL.5434
srwxrwxrwx 1 postgres postgres 0 11月 18 22:23 2016 /var/run/postgresql/.s.PGSQL.5434
postgresqlはデフォルトの設定では、UNIXドメインソケットを/tmpに置かず/var/run/postgresqlに置くように変更され)、その結果psqlも/var/run/postgresqlを見に行くようにになったということかなと思いました。
[環境]
CentOS6
すでにインストールされているPotgreSQLのVer : 9.3.15
インストールしたPostgreSQLのVer : 9.6.1
[実施事項]
# yum -y localinstall https://yum.postgresql.org/9.6/redhat/rhel-6.7-x86_64/pgdg-centos96-9.6-3.noarch.rpm
# yum install postgresql96*
$ psql
psql: サーバに接続できませんでした: そのようなファイルやディレクトリはありません
ローカルにサーバが稼動していますか?
Unixドメインソケット"/var/run/postgresql/.s.PGSQL.5432"で通信を受け付けていますか?
$ netstat -antu
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address Foreign Address State
---略---
tcp 0 0 0.0.0.0:5432 0.0.0.0:* LISTEN
---略---
[解決方法]
psqlに -h /tmpとオプションをつけて実行
$ psql -h /tmp
psql (9.6.1, サーバー 9.3.15)
"help" でヘルプを表示します.
ap2=#
[切り分け]
/var/run/postgresql/.s.PGSQL.5432
というファイルの存在を確認したところありませんでした。
.s.PGSQL.5432がどこにあるかを確認したところ/tmpにありました。
$ ls -l /tmp/.s.PGSQL.5432
srwxrwxrwx 1 postgres postgres 0 11月 18 21:38 2016 /tmp/.s.PGSQL.5432
psql は-hで、Unixドメインソケット用のディレクトリを指定できるので、-h /tmpとオプションをつけたところ接続できるようになりました。
今までは/tmpにあるUnixドメインソケットを探しに行っていたと思うのですが、どうして/var/run/postgresql/を探しにいくようになったのかが分からないです。
9.6のpostgresql.confのunix_socket_directoriesの値を見ると
#unix_socket_directories = '/var/run/postgresql, /tmp' # comma-separated list of directories
となっています。
一方、9.3のpostgresql.confのunix_socket_directoriesの値を見ると
#unix_socket_directories = '/tmp' # comma-separated list of directories
となっています。
postgresql-9.6を起動してpsqlで接続したところ-h /tmpのオプションをつけずに接続できました。
UNIXドメインソケットは/var/run/postgresqlにできていました。
$ ls -l /var/run/postgresql/.s.PGSQL.5434
srwxrwxrwx 1 postgres postgres 0 11月 18 22:23 2016 /var/run/postgresql/.s.PGSQL.5434
postgresqlはデフォルトの設定では、UNIXドメインソケットを/tmpに置かず/var/run/postgresqlに置くように変更され)、その結果psqlも/var/run/postgresqlを見に行くようにになったということかなと思いました。