首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >无法连接到服务器: PostgreSQL中没有这样的文件或目录

无法连接到服务器: PostgreSQL中没有这样的文件或目录
EN

Ask Ubuntu用户
提问于 2018-10-30 14:02:24
回答 2查看 11.6K关注 0票数 1

我有一个带有Ubuntu14.04.5LTS(GNU/Linux2.6.32-042stat127.2 x86_64)的VPS,还安装了Postgresql。我在rails应用程序中使用Postgresql。我的应用程序突然停止工作,抛出错误。

无法连接到服务器:没有这样的文件或目录是服务器在本地运行并接受Unix域套接字上的连接"/var/run/postgresql/.s.PGSQL.5432“吗?

代码语言:javascript
复制
    $psql -V 
     psql (PostgreSQL) 11.0 (Ubuntu 11.0-1.pgdg14.04+2)

    $pg_config --version
      PostgreSQL 11.0 (Ubuntu 11.0-1.pgdg14.04+2)

    $postgres -V
     The program 'postgres' is currently not installed. You can install it by typing:
     apt-get install postgres-xc

   $locate bin/postgres
    /usr/lib/postgresql/11/bin/postgres
    /usr/lib/postgresql/9.3/bin/postgres
    /usr/lib/postgresql/9.4/bin/postgres
    /usr/lib/postgresql/9.5/bin/postgres

  $/usr/lib/postgresql/11/bin/postgres -V
    postgres (PostgreSQL) 11.0 (Ubuntu 11.0-1.pgdg14.04+2)

  $pg_lsclusters
  9.3 main    5432 down   postgres /var/lib/postgresql/9.3/main /var/log/postgresql/postgresql-9.3-main.log
  11  main    5433 down   postgres /var/lib/postgresql/11/main  /var/log/postgresql/postgresql-11-main.log

postgres状态下降

代码语言:javascript
复制
 $service postgresql status
 9.3/main (port 5432): down
 11/main (port 5433): down

 $systemctl status postgresql.service

  postgresql.service
  Loaded: error (Reason: No such file or directory)
 Active: inactive (dead)

 $systemctl status postgresql@9.3-main.service

   postgresql@9.3-main.service
   Loaded: error (Reason: No such file or directory)
   Active: inactive (dead)

$grep -H '^port‘/etc/postgresql/*/main/postgresql.conf /etc/postgresql/11/main/postgresql.conf:port = 5433 /etc/postgresql/9.3/main/postgresql.conf:port = 5432

我正在尝试用PostgreSQL9.3启动

代码语言:javascript
复制
 $service postgresql start 9.3
    * Starting PostgreSQL 9.3 database server                                                                                          
    * Failed to issue method call: Unit postgresql@9.3-main.service failed 
     to load: No such file or directory. See system logs and 'systemctl 
     status postgresql@9.3-main.service' for details.


  $sudo systemctl start postgresql
   Failed to issue method call: Unit postgresql.service failed to load: No 
   such file or directory. See system logs and 'systemctl status 
    postgresql.service' for details.


   $/etc/init.d# /etc/init.d/postgresql start
    * Starting PostgreSQL 11 database server                                                                                           
    * Failed to issue method call: Unit postgresql@11-main.service failed to 
    load: No such file or directory. See system logs and 'systemctl status 
    postgresql@11-main.service' for details.

    [fail]
   * Starting PostgreSQL 9.3 database server                                                                                          
   * Failed to issue method call: Unit postgresql@9.3-main.service failed to 
    load: No such file or directory. See system logs and 'systemctl status 
    postgresql@9.3-main.service' for details.
    [fail]

我无法启动PostgreSQL.I。我不明白为什么它突然下降了,直到昨天它才恢复正常。

EN

回答 2

Ask Ubuntu用户

回答已采纳

发布于 2018-11-01 12:33:29

根据pg_lsclusters,您的PostgreSQL实例9.3/main11/main没有启动。这解释了“无法连接到服务器”错误。

postgresql.servicepostgresql@9.3-main.servicesystemd单元文件,您的问题似乎是,当systemctl需要它们时,它们就丢失了。注意,在Ubuntu14.04上默认不会安装systemctl,因为它是最后一个不使用systemd的版本(参见Ubuntu14.04是否使用系统?)。但是不知怎么的,systemd被安装在你的系统上了。

使用systemd,通常postgres服务文件应该由/lib/systemd/system-generators/postgresql-generator自动创建,由postgresql-common包提供,并以/lib/systemd/system/中的*.service单元文件结束。

我猜不出为什么那个部分在你的系统上不起作用或者停止工作。

如何手动启动PostgreSQL

pg_ctlcluster命令独立于systemd或upstart工作。您应该能够以以下方式启动PostgreSQL实例:

代码语言:javascript
复制
$ sudo pg_ctlcluster 9.3 main start
$ sudo pg_ctlcluster 11 main start
票数 4
EN

Ask Ubuntu用户

发布于 2019-10-31 11:59:40

在我的例子中,systemd在Ubuntu14.04上运行,但这最早是从16.04开始支持的。因此,我运行supported,我的case systemd运行在Ubuntu14.04上,但这最早是从16.04开始支持的。所以我跑了

代码语言:javascript
复制
sudo apt-get remove systemd

之后,postgresql服务已成功运行。

票数 0
EN
页面原文内容由Ask Ubuntu提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://askubuntu.com/questions/1088590

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档