Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/apache/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Postgresql PG::连接错误Postgres群集关闭_Postgresql_Digital Ocean_Postgresql 9.5 - Fatal编程技术网

Postgresql PG::连接错误Postgres群集关闭

Postgresql PG::连接错误Postgres群集关闭,postgresql,digital-ocean,postgresql-9.5,Postgresql,Digital Ocean,Postgresql 9.5,Digitalocean禁用了我的水滴的internet访问。修复错误(回滚到旧备份)后,他们恢复了internet访问。但后来我在部署时经常出错,我似乎无法启动和运行我的Postgres数据库 每次尝试部署应用程序时都会出现错误 PG::ConnectionBad: could not connect to server: No such file or directory Is the server running locally and accepting connecti

Digitalocean禁用了我的水滴的internet访问。修复错误(回滚到旧备份)后,他们恢复了internet访问。但后来我在部署时经常出错,我似乎无法启动和运行我的Postgres数据库

每次尝试部署应用程序时都会出现错误

PG::ConnectionBad: 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"?
因此,我使用SSH登录到我的服务器,并检查我的Postgres是否实际运行:

pg\lsu集群

结果为:

Ver群集端口状态所有者数据目录日志文件
9.5 main 5432 down postgres/var/lib/postgresql/9.5/main/var/log/postgresql/postgresql-9.5-main.log

Postgres服务器状态

所以我的Postgres服务器好像坏了。我试着用以下方法再次“支撑”它:

pg_ctlcluster 9.5 main start
执行此操作后,在/usr/bin/pg_ctlcluster行403处使用-T开关运行时,我在$ENV{PATH}中得到了一个错误:
不安全的目录。

第403行的
/usr/bin/pg_/ctlcluster
显示:

system'systemctl'、'is active'、'q'、'postgresql\@$version-$cluster'
但我不确定这里会出现什么问题,以及如何解决这个问题

更新 我还尝试将
/bin
上的权限更新为前面提到的755。遗憾的是,这并没有解决我的问题

更新2 我将/usr/bin更改为755。现在,当我尝试
pg_ctlcluster 9.5 main start
时,我发现:

工作postgresql@9.5-main.service失败,因为控制进程已退出,错误代码为。请参阅“系统控制状态”postgresql@9.5-“main.service”和“journalctl-xe”获取详细信息

并且在
systemctl状态中postgresql@9.5-主服务

postgresql@9.5-main.service - PostgreSQL Cluster 9.5-main
   Loaded: loaded (/lib/systemd/system/postgresql@.service; disabled; vendor preset: enabled)
   Active: failed (Result: exit-code) since Sun 2018-01-28 17:32:38 EST; 45s ago
  Process: 22473 ExecStart=postgresql@%i --skip-systemctl-redirect %i start (code=exited, status=1/FAILURE)

Jan 28 17:32:08 *url* systemd[1]: Starting PostgreSQL Cluster 9.5-main...
Jan 28 17:32:38 *url* postgresql@9.5-main[22473]: The PostgreSQL server failed to start.
Jan 28 17:32:38 *url* systemd[1]: postgresql@9.5-main.service: Control process exited, code=exited status=1
Jan 28 17:32:38 *url* systemd[1]: Failed to start PostgreSQL Cluster 9.5-main.
Jan 28 17:32:38 *url* systemd[1]: postgresql@9.5-main.service: Unit entered failed state.
Jan 28 17:32:38 *url* systemd[1]: postgresql@9.5-main.service: Failed with result 'exit-code'.


谢谢

你最好不要把
systemctl
pg\u-ctlcluster
混在一起。让
systemctl
使用正确的用户和权限调用
pg_ctlcluster
。您应该使用以下命令启动postgresql实例

sudo systemctl start postgresql@9.5-main.service
另外,检查启动日志中的错误。你也可以发布它们,以帮助你了解发生了什么

您的
systemctl状态
还输出该服务已禁用,因此,当服务器重新启动时,您必须手动启动该服务。要启用它,请运行:

sudo systemctl enable postgresql@9.5-main.service

我希望它能有所帮助

主要是因为/etc/hosts文件被更改了。我已经删除了/etc/hosts文件中的额外空间。请使用cat/etc/hosts 将这些行添加到文件中

  • 127.0.0.1本地主机
  • 127.0.1.1您的主机名
  • ::1 ip6本地主机ip6环回
  • 我已经授予了/etc/hosts文件644权限。即使在系统重新启动后,它仍能为我工作