【问题标题】:PostgreSQL: could not connect to server: domain socket "/var/run/postgresql/.s.PGSQL.5432"PostgreSQL:无法连接到服务器:域套接字“/var/run/postgresql/.s.PGSQL.5432”
【发布时间】:2020-01-23 19:37:24
【问题描述】:

Linux 薄荷。 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.

【问题讨论】:

标签: linux postgresql sockets


【解决方案1】:

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

【讨论】:

    猜你喜欢
    • 2014-05-10
    • 1970-01-01
    • 1970-01-01
    • 2021-02-21
    • 2021-08-31
    • 2015-08-13
    • 1970-01-01
    • 2015-05-09
    相关资源
    最近更新 更多