I have Centos7 machine set up and I'm having problems with postgres not starting after reboot. Even when I try to run the service manually I'm getting
UTC FATAL: could not create lock file "/var/run/postgresql/.s.PGSQL.5432.lock": No such file or directory
Taking a closer look, I noticed that /var/run/postgresql
is not event existing after the reboot.
So a couple of questions really, as I didn't find clear answers in my research.
How and when are the directories in /var/run even created, is it something that get created on starting a service or what is the way?
What could be causing this specific issue to happen and not to start postgres after reboot?
I've never seend this behavior before, although in all fairness I have been using ubuntu mostly so far.
Thanks
Best Answer
If you examine
/var/run
on your system, you'll see that it's actually a symlink to/run
:And if you examine
/run
, you'll see that it's actually atmpfs
mountpoint:A
tmpfs
filesystem is an in-memory filesystem: anything there disappears when the system reboots. As Federico says in his comment, CentOS 7 (and Fedora, and RHEL 7, etc) use thesystemd-tmpfiles
facility to automatically create things like lock directories and other ephemeral storage locations when the system boots.The
postgresql-server
package included in CentOS 7 already does the right thing:If you are using a third-party postgresql package, don't be surprised that it doesn't integrate correctly with CentOS. You can manually correct is by setting up the same
tmpfiles.d
entry shown here.