解决postgresql 重启后无法启动的问题。

一日Linux 主机重重启,postgresql 无法启动,查看日志发现为以下提示。找了很多办法都没人解决。实际只要

ls -l /var/log/postgresql/

root@navappliance:/run/postgresql# ls -l /var/log/postgresql/
total 28
-rw-r----- 1 nobody adm 1722 Jun 17 23:25 postgresql-11-main.log
-rw-r----- 1 nobody adm 9272 Jun  6 08:00 postgresql-11-main.log.1
-rw-r----- 1 nobody adm  615 Jun  1 16:04 postgresql-11-main.log.2.gz
-rw-r----- 1 nobody adm 2126 May 17 08:00 postgresql-11-main.log.3.gz
-rw-r----- 1 nobody adm  571 May  9 08:00 postgresql-11-main.log.4.gz
 

发现目录无法写入,

chown -R postgres /var/log/postgresql/

重新给权限,恢复了启动成功。

root@appliance:/run/postgresql# systemctl status postgresql@11-main.service
● postgresql@11-main.service - PostgreSQL Cluster 11-main
   Loaded: loaded (/lib/systemd/system/postgresql@.service; enabled-runtime; vendor preset: enabled)
   Active: failed (Result: protocol) since Thu 2021-06-17 23:45:35 CST; 8s ago
  Process: 1728 ExecStart=/usr/bin/pg_ctlcluster --skip-systemctl-redirect 11-main start (code=exited, status=1/FAILURE)

Jun 17 23:45:35 navappliance systemd[1]: Starting PostgreSQL Cluster 11-main...
Jun 17 23:45:35 navappliance postgresql@11-main[1728]: Error: Could not open logfile /var/log/postgresql/postgresql-11-main.log
Jun 17 23:45:35 navappliance postgresql@11-main[1728]: Error: /usr/lib/postgresql/11/bin/pg_ctl /usr/lib/postgresql/11/bin/pg_ctl start -D /var/lib/postgresql/11/main -l /var/log/postgresql/postg
Jun 17 23:45:35 navappliance systemd[1]: postgresql@11-main.service: Can't open PID file /run/postgresql/11-main.pid (yet?) after start: No such file or directory
Jun 17 23:45:35 navappliance systemd[1]: postgresql@11-main.service: Failed with result 'protocol'.
Jun 17 23:45:35 navappliance systemd[1]: Failed to start PostgreSQL Cluster 11-main.


ls -l /var/log/postgresql/

chown -R postgres /var/log/postgresql/


root@navappliance:/run/postgresql# systemctl status postgresql@11-main.service
● postgresql@11-main.service - PostgreSQL Cluster 11-main
   Loaded: loaded (/lib/systemd/system/postgresql@.service; enabled-runtime; vendor preset: enabled)
   Active: active (running) since Thu 2021-06-17 23:49:58 CST; 7s ago
  Process: 1781 ExecStart=/usr/bin/pg_ctlcluster --skip-systemctl-redirect 11-main start (code=exited, status=0/SUCCESS)
 Main PID: 1786 (postgres)
    Tasks: 7 (limit: 4915)
   Memory: 43.7M
   CGroup: /system.slice/system-postgresql.slice/postgresql@11-main.service
           ├─1786 /usr/lib/postgresql/11/bin/postgres -D /var/lib/postgresql/11/main -c config_file=/etc/postgresql/11/main/postgresql.conf
           ├─1788 postgres: 11/main: checkpointer
           ├─1789 postgres: 11/main: background writer
           ├─1790 postgres: 11/main: walwriter
           ├─1791 postgres: 11/main: autovacuum launcher
           ├─1792 postgres: 11/main: stats collector
           └─1793 postgres: 11/main: logical replication launcher

Jun 17 23:49:56 navappliance systemd[1]: Starting PostgreSQL Cluster 11-main...
Jun 17 23:49:58 navappliance systemd[1]: Started PostgreSQL Cluster 11-main.

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值