/var/run/postgresql missing after reboot
If you examine /var/run
on your system, you'll see that it's actually a symlink to /run
:
# ls -ld /var/run
lrwxrwxrwx. 1 root root 6 Jan 19 09:12 /var/run -> ../run
And if you examine /run
, you'll see that it's actually a tmpfs
mountpoint:
# mount | grep /run
tmpfs on /run type tmpfs (rw,nosuid,nodev,seclabel,mode=755)
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 the systemd-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:
# rpm -ql postgresql-server | grep tmpfiles
/usr/lib/tmpfiles.d/postgresql.conf
# cat /usr/lib/tmpfiles.d/postgresql.conf
d /var/run/postgresql 0755 postgres postgres -
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.
Related videos on Youtube
Comments
-
iblazevic over 1 year
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
-
UrbanoJVR over 2 yearsIt works but I had to set the ownership of /var/run/postgresql to the user postgres with comand "chown postgres:postgres /var/run/postgresql". Without doing that, it didn't work for me.