我有一个带有Ubuntu14.04.5LTS(GNU/Linux2.6.32-042stat127.2 x86_64)的VPS,还安装了Postgresql。我在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.logpostgres状态下降
$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启动
$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。我不明白为什么它突然下降了,直到昨天它才恢复正常。
发布于 2018-11-01 12:33:29
根据pg_lsclusters,您的PostgreSQL实例9.3/main和11/main没有启动。这解释了“无法连接到服务器”错误。
postgresql.service和postgresql@9.3-main.service是systemd单元文件,您的问题似乎是,当systemctl需要它们时,它们就丢失了。注意,在Ubuntu14.04上默认不会安装systemctl,因为它是最后一个不使用systemd的版本(参见Ubuntu14.04是否使用系统?)。但是不知怎么的,systemd被安装在你的系统上了。
使用systemd,通常postgres服务文件应该由/lib/systemd/system-generators/postgresql-generator自动创建,由postgresql-common包提供,并以/lib/systemd/system/中的*.service单元文件结束。
我猜不出为什么那个部分在你的系统上不起作用或者停止工作。
pg_ctlcluster命令独立于systemd或upstart工作。您应该能够以以下方式启动PostgreSQL实例:
$ sudo pg_ctlcluster 9.3 main start
$ sudo pg_ctlcluster 11 main start发布于 2019-10-31 11:59:40
在我的例子中,systemd在Ubuntu14.04上运行,但这最早是从16.04开始支持的。因此,我运行supported,我的case systemd运行在Ubuntu14.04上,但这最早是从16.04开始支持的。所以我跑了
sudo apt-get remove systemd之后,postgresql服务已成功运行。
https://askubuntu.com/questions/1088590
复制相似问题