Forum OpenACS Q&A: Postgres not starting up

Posted by Jade Rubick on
On a server I am hosting on a Debian stable box, Postgres doesn't start up correctly after reboots.

I'm running the Postgres from backports.

Has anybody had this happen to them?

Using /etc/init.d/postgres start or restart does not work, because it actually thinks it's already started up. The only solution I've found is here:

Posted by Andrew Piskorski on
Jade, I'm not familiar with it, but they key to debugging this seems to be, why does the init.d script think that Postgres is already running? Is it checking some bogus lock file, or what?
Posted by Deds Castillo on
I don't have debian but it looks like the stop script is not removing the lockfile so when it reboots the lockfile is still present. On RH/FC, stop usually contains:

rm -f /var/run/postmaster.${PGPORT}.pid
rm -f /var/lock/subsys/${NAME}

Check also that you are in fact executing a stop script. Check the scripts being executed for runlevels 0 and 6 as they may be missing the call to stop PG.

Posted by Randy O'Meara on
Just add a line to your startup script (in RH & Fedora it would be /etc/rc.d/rc.sysinit) that removes any stale postgres sockets and run files like so:

rm -f /tmp/.s.PGSQL.*
rm -f ~postgres/data/*.pid

I do this just before the swapon command.