Postgresql 不再启动

Postgresql 不再启动

Debian 9.5 - postgresql cluster 9.4。这不是全新安装 - 它是一个运行良好的系统,直到我尝试重新启动服务

所有命令:/etc/init.d/postgresql startservice postgresql start行为systemctl start postgresql相同:提示挂起约 10-15 秒,然后什么都没有发生 - postgres 没有运行!

这是系统日志:

Jul 18 18:15:35 intranet systemd[1]: Starting PostgreSQL Cluster 9.4-main...
Jul 18 18:16:06 intranet [email protected][27610]: The PostgreSQL server failed to start. Please check the log output.
Jul 18 18:16:06 intranet systemd[1]: [email protected]: Control process exited, code=exited status=1
Jul 18 18:16:06 intranet systemd[1]: Failed to start PostgreSQL Cluster 9.4-main.
Jul 18 18:16:06 intranet systemd[1]: [email protected]: Unit entered failed state.
Jul 18 18:16:06 intranet systemd[1]: [email protected]: Failed with result 'exit-code'.

postgres-log(/var/log/postgresql/)是空的。

journalctl-xe:

-- Unit [email protected] has begun starting up.
Jul 18 18:16:06 intranet [email protected][27610]: The PostgreSQL server failed to start. Please check the log output.
Jul 18 18:16:06 intranet systemd[1]: [email protected]: Control process exited, code=exited status=1
Jul 18 18:16:06 intranet systemd[1]: Failed to start PostgreSQL Cluster 9.4-main.
-- Subject: Unit [email protected] has failed

systemctl 状态 postgresql

● postgresql.service - PostgreSQL RDBMS
   Loaded: loaded (/lib/systemd/system/postgresql.service; enabled; vendor preset: enabled)
   Active: active (exited) since Wed 2018-07-18 17:42:02 CEST; 37min ago
 Main PID: 29934 (code=exited, status=0/SUCCESS)
    Tasks: 0 (limit: 4915)
   CGroup: /system.slice/postgresql.service

Jul 18 17:42:02 intranet systemd[1]: Starting PostgreSQL RDBMS...
Jul 18 17:42:02 intranet systemd[1]: Started PostgreSQL RDBMS.

系统控制状态[电子邮件保护]

[email protected] - PostgreSQL Cluster 9.4-main
   Loaded: loaded (/lib/systemd/system/[email protected]; enabled; vendor preset: enabled)
   Active: failed (Result: exit-code) since Wed 2018-07-18 18:16:06 CEST; 1 day 14h ago
  Process: 27610 [email protected] --skip-systemctl-redirect 9.4-main start (code=exited, status=1/FAILURE)

Jul 18 18:15:35 intranet systemd[1]: Starting PostgreSQL Cluster 9.4-main...
Jul 18 18:16:06 intranet [email protected][27610]: The PostgreSQL server failed to start. Please check the log output.
Jul 18 18:16:06 intranet systemd[1]: [email protected]: Control process exited, code=exited status=1
Jul 18 18:16:06 intranet systemd[1]: Failed to start PostgreSQL Cluster 9.4-main.
Jul 18 18:16:06 intranet systemd[1]: [email protected]: Unit entered failed state.
Jul 18 18:16:06 intranet systemd[1]: [email protected]: Failed with result 'exit-code'.

所以根本没有任何迹象表明哪里出了问题。奇怪的是,系统一直运行正常,没有任何问题 - 我的应用程序刚刚崩溃,我尝试重新启动 postgres - 现在它无法再次启动。

经过几个小时的搜索,我发现奇怪的是,它可以手动启动。

我以 postgres 用户身份登录并使用以下命令:

/usr/lib/postgresql/9.4/bin/postgres -D /var/lib/postgresql/9.4/main -c config_file=/etc/postgresql/9.4/main/postgresql.conf

它运行正常 - 没有错误,没有问题。我甚至尝试添加“-d 3”以获得更详细的输出......但是没有什么异常。它运行良好 - 问题只是 init 脚本。我该如何解决这个问题 - 或者至少找出问题的根源?

答案1

我想我解决了这个问题。感谢评论者引导我找到问题。

的权限/var/log/postgresql不知何故发生了改变。该文件夹(以及其中的日志文件)不再属于 postgres 用户。因此显然它无法再写入/打开日志。

完成后chown postgres:postgres /var/log/postgresql/ -R,我能够通过 init-scripts 启动 postgres

相关内容