/var/run/postgresql missing after reboot
Solution 1:
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.