Ignasi
Ignasi

Reputation: 340

Failed to start PostgreSQL Cluster 10-main when booting

when I try to boot Ubuntu, it never finishes the boot process because it appears the message "Failed to start PostgreSQL Cluster 10-main." I also get the same message with 9.5-main. But lets focus on 10.

When I execute:

systemctl status [email protected]

I get the following message:

[email protected] - PostgreSQL Cluster 10-main
  Loaded: loaded (/lib/systemd/system/[email protected]; indirect; vendor preset: enabled)
  Active: failed (Result: protocol) since Wed 2020-02-19 17:57:22 CET; 30 min ago
 Process: 1602 ExecStart=/usr/bin/pg_ctlcluster --skip-systemctl-redirect 10-main start (code_exited, status=1/FAILURE)
PC_info systemd[1]: Starting PostgreSQL Cluster 10-main...
PC_info postgresql@10-main[1602]: Error: /usr/lib/postgresql/10/bin/pg_ctl /usr/lib/postgresql/10/bin/pg_ctl start -D /var/lib/postgresql/10/main -l /var/log/postgresql/postgresql-19-main.log -s -o -c config_file="/etc/postgresql/10/main/postgresql.conf" exit with status 1:
PC_info systemd[1]: [email protected]: Can't open PID file /var/run/postgresql/10-main.pid (yet?) after start: No such file or directory
PC_info systemd[1]: [email protected]: Failed with result 'protocol'.
PC_info systemd[1]: Failed to start PostgreSQL Cluster 10-main.

PC_info is information about my computer (user, date..) not relevant

I got this error from one day to an other without touching anything related to Database Servers. I tried to fix it by my self but nothing worked

Writing the command

service postgresql@10-main start

I get

Job for [email protected] failed because the service did not take the steps required by its unit configuration
See "systemctl status [email protected]" and "journalctl -xe"  for details.

Running this two command I get the message from the beginning.

Anyone has an idea of what is happening? How I can fix it?

Upvotes: 19

Views: 45392

Answers (6)

Kitisak Auttasran
Kitisak Auttasran

Reputation: 441

Create new Cluster for current data in /main.

Step by step.

(1) sudo systemctl stop postgresql

(2) edit postgresql.conf

data_directory = '/var/lib/postgresql/12/main3'

(3) sudo -u postgres /usr/lib/postgresql/12/bin/initdb -D /var/lib/postgresql/12/main3

(4) sudo cd /var/lib/postgresql/12/

(5) sudo rm -Rf main3

(6) sudo cp -a main main3

(7) sudo systemctl start postgresql

Upvotes: 0

LucMorizur
LucMorizur

Reputation: 11

I had this issue because I had (stupidly) once taken ownership ( chown luc:luc ) over whole /var/log/ folder. It had the effect to make file /var/log/postgresql/postgresql-14-main.log unaccessible during boot, causing the PostgreSQL startup fail.

Restoring ownership of /var/log/ folder to root ( # chown -R root:root /var/log/* ) fixed the issue.

Upvotes: 1

This happened to me in Postgres 15 because of insufficient free space. Cleaning up my PC solved this issue.

Upvotes: 1

Omkar
Omkar

Reputation: 3620

I had same issue, I followed below steps,

Error status :

  • pg_lsclusters
Ver Cluster Port Status Owner    Data directory              Log file

10  main    5432 down   postgres /var/lib/postgresql/10/main
/var/log/postgresql/postgresql-10-main.log

Applied Solution :

  • sudo chmod 700 -R /var/lib/postgresql/10/main
  • sudo -i -u postgres
  • postgres@abc:~$ /usr/lib/postgresql/10/bin/pg_ctl restart -D /var/lib/postgresql/10/main

After Solution status :

  • pg_lsclusters
Ver Cluster Port Status Owner    Data directory              Log file
 
10  main    5432 online postgres /var/lib/postgresql/10/main
/var/log/postgresql/postgresql-10-main.log

Upvotes: 30

Frank Oppong Konadu
Frank Oppong Konadu

Reputation: 99

I was facing the same challenge, I try a lot of methods but none work for me till I try these commands below

sudo apt-get -y install postgresql
sudo systemctl start [email protected]
pg_lsclusters

then everything started working fine, but please the version of postgresql i'm using is 15 that's you are seeing 15 in the second command so in your case you substitute it with the version you are using

Upvotes: 0

Sekar S
Sekar S

Reputation: 183

as mentioned by @gruentee in comment above,

/usr/lib/postgresql/10/bin/pg_ctl restart -D /var/lib/postgresql/10/main -l /var/log/postgresql/postgresql-10-main.log -s -o  '-c config_file="/etc/postgresql/10/main/postgresql.conf"'

started the postgresSql DB. Dont forget to

sudo -i -u postgres

before issuing above command

Upvotes: 1

Related Questions