AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / ubuntu / 问题 / 1088590
Accepted
current_user
current_user
Asked: 2018-10-31 06:02:24 +0800 CST2018-10-31 06:02:24 +0800 CST 2018-10-31 06:02:24 +0800 CST

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

  • 772

我有一个带有 Ubuntu 14.04.5 LTS (GNU/Linux 2.6.32-042stab127.2 x86_64) 的 VPS,并且还安装了 Postgresql。我在 ruby​​ on rails 应用程序中使用 Postgresql。突然我的应用程序停止工作并抛出错误

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

    $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 状态为 down

 $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 [email protected]

   [email protected]
   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

我正在尝试启动 Postgresql 9.3

 $service postgresql start 9.3
    * Starting PostgreSQL 9.3 database server                                                                                          
    * Failed to issue method call: Unit [email protected] failed 
     to load: No such file or directory. See system logs and 'systemctl 
     status [email protected]' 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 [email protected] failed to 
    load: No such file or directory. See system logs and 'systemctl status 
    [email protected]' for details.

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

我无法启动 PostgreSQL。我不明白它为什么突然宕机,直到昨天它工作正常。

debian postgresql 14.04
  • 2 2 个回答
  • 10998 Views

2 个回答

  • Voted
  1. Best Answer
    Daniel Vérité
    2018-11-02T04:33:29+08:002018-11-02T04:33:29+08:00

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

    postgresql.service并且[email protected]是systemd单元文件,您的问题似乎是它们在systemctl需要时丢失了。
    请注意,systemctl默认情况下不会在 Ubuntu 14.04 上安装,因为它是最后一个不使用 systemd 的版本(请参阅Is Ubuntu 14.04 using systemd?)。但不知何故systemd安装在你的系统上。

    使用 systemd,通常 postgres 服务文件应该由包自动创建/lib/systemd/system-generators/postgresql-generator,由postgresql-common包提供,并最终*.service以/lib/systemd/system/.

    我无法猜测为什么该部分无法在您的系统上工作或停止工作。

    如何手动启动 PostgreSQL

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

    $ sudo pg_ctlcluster 9.3 main start
    $ sudo pg_ctlcluster 11 main start
    
    • 4
  2. Ani Papyan
    2019-11-01T03:59:40+08:002019-11-01T03:59:40+08:00

    就我而言systemd,它在 Ubuntu 14.04 上运行,但最早从 16.04 开始支持。所以我运行了 sudo apt-get remove systemd 在我的情况下systemd是在 Ubuntu 14.04 上运行的,但最早从 16.04 开始支持。所以我跑了

    sudo apt-get remove systemd
    

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

    • 0

相关问题

  • 如何使用 Debian 进行双引导?

  • 从技术上讲,Ubuntu 与其他 Linux 发行版相比有何不同?[关闭]

  • 什么是最简单的 Debian 打包指南?

  • Ubuntu 与 Debian 有何不同?

  • Ubuntu 是基于 Debian 不稳定还是 Debian 测试?

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    如何运行 .sh 脚本?

    • 16 个回答
  • Marko Smith

    如何安装 .tar.gz(或 .tar.bz2)文件?

    • 14 个回答
  • Marko Smith

    如何列出所有已安装的软件包

    • 24 个回答
  • Marko Smith

    无法锁定管理目录 (/var/lib/dpkg/) 是另一个进程在使用它吗?

    • 25 个回答
  • Martin Hope
    Flimm 如何在没有 sudo 的情况下使用 docker? 2014-06-07 00:17:43 +0800 CST
  • Martin Hope
    Ivan 如何列出所有已安装的软件包 2010-12-17 18:08:49 +0800 CST
  • Martin Hope
    La Ode Adam Saputra 无法锁定管理目录 (/var/lib/dpkg/) 是另一个进程在使用它吗? 2010-11-30 18:12:48 +0800 CST
  • Martin Hope
    David Barry 如何从命令行确定目录(文件夹)的总大小? 2010-08-06 10:20:23 +0800 CST
  • Martin Hope
    jfoucher “以下软件包已被保留:”为什么以及如何解决? 2010-08-01 13:59:22 +0800 CST
  • Martin Hope
    David Ashford 如何删除 PPA? 2010-07-30 01:09:42 +0800 CST

热门标签

10.10 10.04 gnome networking server command-line package-management software-recommendation sound xorg

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve