PostgreSQL:无法连接到服务器:域套接字“ /var/run/postgresql/.s.PGSQL.5432”

时间:2020-01-23 10:26:35

标签: linux postgresql sockets

Linux Mint。 PostgreSQL 11。

我正在尝试:psql -U postgres

并收到:

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"

在postgresql.conf中:

   listen_addresses = '*'
   unix_socket_directories = '/var/run/postgresql'
   unix_socket_permissions = 0777

在ps axf之后| grep postgres:

6575 ?        Sl     0:01          |       |   \_ xed /etc/postgresql/11/main/postgresql.conf

4906 pts/0    S      0:00          \_ sudo su postgres
4907 pts/0    S      0:00              \_ su postgres
6586 pts/0    S+     0:00                                      \_ grep --color=auto postgres

但是

  root@andrej-HP-290-G1-SFF-Business-PC:/etc/postgresql/11/main# netstat -nltp | grep 5432
  root@andrej-HP-290-G1-SFF-Business-PC:/etc/postgresql/11/main# 

我如何尝试解决此问题:

  1. ln -s /tmp/.s.PGSQL.5432 /var/run/postgresql/.s.PGSQL.5432

  2. sudo find / tmp / -name .s.PGSQL.5432

    结果:/tmp/.s.PGSQL.5432。并在su下尝试:psql -U postgres

运行“ pg_lsclusters”,我看到了:

11  main    5432 down   postgres /var/lib/postgresql/11/main /var/log/postgresql/postgresql-11-main.log

因此,状态为关闭。但是当我尝试“ pg_ctlcluster 11 main start”时,我收到:

Job for postgresql@11-main.service failed because the service did not 
take the steps required by its unit configuration.
See "systemctl status postgresql@11-main.service" and "journalctl -xe" 
for details.

执行“ journalctl -xe”:

 failed to create Unix-сокет in "/tmp
 system bd is switched-off
 failde to start server
  Can't open PID file /run/postgresql/11-main.pid (yet?) after start: 
  No such file or dir
  Failed with result 'protocol'.
  Failed to start PostgreSQL Cluster 11-main.

1 个答案:

答案 0 :(得分:0)

问题已解决。 我重新安装了postgresql,并在安装过程中运行“ pg_ctlcluster 11 main start”