PostgreSQL 服务器无法在 ArchLinux 上启动:致命错误:无法创建锁定文件 »/run/postgresql/.s.PGSQL.5432.lock«

PostgreSQL server fails to start on ArchLinux: FATAL: could not create lockfile »/run/postgresql/.s.PGSQL.5432.lock«

我是 Arch 的新手,也是 PostgreSQL 的新手,所以这可能是一个非常基础的问题。

我从 extra 安装了 postgresql 11.5-4,从 AUR 安装了 pgadmin 4,两者似乎 运行 都很好。 我使用以下命令创建了一个测试数据库:

initdb -D /home/lg/test-db

我得到了答案:

You can start the db-server using:
pg_ctl -D /home/lg/test-db -l logdatei start

我试过了,得到了:

pg_ctl -D /home/lg/test-db -l logdatei start
waiting for serer to start.... stopped 
pg_ctl: could not start the server
check the log.

日志只说无法创建锁定文件 »/run/postgresql/.s.PGSQL.5432.lock«,因为找不到文件夹。 /运行 下没有名为 "postgresql" 的文件夹。我想 postgresql 不能创建这个文件夹,因为它没有权限。然而,一些在线帖子建议将数据库的 user/owner 更改为 sudo。然而,Postgresql 阻止了这种情况。当我以 sudo 身份尝试任何命令时,postgresql 告诉我该命令不能 运行 作为 root。一定是我这里的思路有什么很基础的错误,我弄了3个小时都没弄清楚

在启动服务器之前,您必须从 postgresql.conf 中的 unix_socket_directories 中删除 /run/postgresql

可能你有 /var/run 符号链接到 /运行 并且 运行 在 tmpfs 上。您应该将 d /run/postgresql 0755 postgres postgres - 之类的内容添加到 /usr/lib/tmpfiles.d/postgresql.conf