大网数据广告活动
服务器运维问答

/var/run/postgresql missing after reboot

· 52CE 我爱测

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"…

问题原文

原帖链接 · iblazevic · CC BY-SA 3.0

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

已采纳解答

原帖链接 · larsks · CC BY-SA 3.0

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.

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2016-03-27)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 3.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。