Kev*_*ore 5 postgresql digital-ocean postgresql-9.5
Digitalocean 禁用了我的 Droplet 的互联网访问。修复错误(回滚到旧备份)后,他们恢复了互联网访问。但后来我在部署时不断收到错误,我似乎无法启动并运行我的 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"?
Run Code Online (Sandbox Code Playgroud)
所以我使用 SSH 登录到我的服务器并检查我的 Postgres 是否实际运行:
pg_lsclusters
结果为:
Ver Cluster Port Status Owner Data directory Log file
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这样做后我得到了错误:Insecure directory in $ENV{PATH} while running with -T switch at /usr/bin/pg_ctlcluster line 403.
403 号线上/usr/bin/pg_ctlcluster说:
system 'systemctl', 'is-active', '-q', "postgresql\@$version-$cluster";
但我不确定这里可能出现什么问题以及如何解决这个问题。
我还尝试将权限更新/bin为 755,如此处所述。遗憾的是这并没有解决我的问题。
我将 /usr/bin 更改为 755。现在当我尝试时pg_ctlcluster 9.5 main start,我得到以下信息:
postgresql@9.5-main.service 的作业失败,因为控制进程退出并出现错误代码。有关详细信息,请参阅“systemctl status postgresql@9.5-main.service”和“journalctl -xe”。
并在里面systemctl status postgresql@9.5-main.service:
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'.
Run Code Online (Sandbox Code Playgroud)
谢谢!
小智 2
你最好不要混合systemctl和pg_ctlcluster。让我们使用正确的用户和权限systemctl进行调用。pg_ctlcluster你应该启动你的 postgresql 实例
sudo systemctl start postgresql@9.5-main.service
Run Code Online (Sandbox Code Playgroud)
另外,检查启动日志中的错误。您也可以发布它们,以帮助您了解发生了什么。
您systemctl status还输出该服务已禁用,因此,当服务器重新启动时,您必须手动启动该服务。要启用它,请运行:
sudo systemctl enable postgresql@9.5-main.service
Run Code Online (Sandbox Code Playgroud)
我希望它有帮助
| 归档时间: |
|
| 查看次数: |
13832 次 |
| 最近记录: |