简体   繁体   English

Postgresql 致命:无法创建锁定文件“/var/run/postgresql/.s.PGSQL.5432.lock”:权限被拒绝

[英]Postgresql FATAL: could not create lock file "/var/run/postgresql/.s.PGSQL.5432.lock": Permission denied

I try to start postgresql: /usr/pgsql-11/bin/pg_ctl -D appli/postgres/data/ -l logfile start but I don't understand why I have always this error in my logfile:我尝试启动 postgresql: /usr/pgsql-11/bin/pg_ctl -D appli/postgres/data/ -l logfile start但我不明白为什么我的日志文件中总是出现此错误:

FATAL:  could not create lock file "/var/run/postgresql/.s.PGSQL.5432.lock": Permission denied

I tried to change permission but I get always Permission denied:我试图更改权限,但我总是被拒绝权限:

chown -R postgres:postgres /var/run/postgresql
chmod 755 /var/run/postgresql

Edit postgresql.conf and change unix_socket_directories back to the factory default value /tmp .编辑postgresql.conf并将unix_socket_directories更改回出厂默认值/tmp

Alternatively, start PostgreSQL as operating system user postgres .或者,以操作系统用户postgres启动 PostgreSQL。

If you installed from source, the directory should probably be '/tmp'.如果您从源代码安装,该目录可能应该是“/tmp”。 If you installed from a repository, the shipped start-up script should handle the permissions for you.如果您从存储库安装,则附带的启动脚本应该为您处理权限。 Why not use that rather than running pg_ctl yourself?为什么不使用它而不是自己运行 pg_ctl 呢?

I had the same problem and what did it for me was creating the directory "postgresql" which didn't exist previously for some bizarre reason and running我遇到了同样的问题,为我做了什么是创建目录“postgresql”,该目录以前由于某些奇怪的原因不存在并正在运行

sudo chown postgres /var/run/postgresql

after that pg_ctl was able to create the lock file without problems.之后 pg_ctl 能够毫无问题地创建锁定文件。

I ran into it with an alpine docker image.我遇到了一张alpine docker图像。 As it turned out they changed the default:结果他们改变了默认值:

Using /tmp for sockets allows everyone to spoof a PostgreSQL server.为 sockets 使用 /tmp 允许每个人欺骗 PostgreSQL 服务器。

There are 2 options:有 2 个选项:

  1. Create the /run/postgresql dir:创建/run/postgresql目录:

     mkdir /run/postgresql && chown postgres: /run/postgresql
  2. Change unix_socket_directories in postgresql.conf ( unix_socket_directories = '/tmp' ).postgresql.conf ( unix_socket_directories = '/tmp' ) 中更改unix_socket_directories

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 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« 无法连接到服务器:“/var/run/postgresql/.s.PGSQL.5432”? - could not connect to server: “/var/run/postgresql/.s.PGSQL.5432”? PostgreSQL 服务器启动失败,无法创建锁定文件:权限被拒绝 - PostgreSQL server failed to start, could not create lock file: permission denied PostgreSQL:无法连接到服务器:域套接字“/var/run/postgresql/.s.PGSQL.5432” - PostgreSQL: could not connect to server: domain socket "/var/run/postgresql/.s.PGSQL.5432" 连接到套接字“/var/run/postgresql/.s.PGSQL.5432”上的服务器失败:致命:角色“rootuser”不存在 - connection to server on socket "/var/run/postgresql/.s.PGSQL.5432" failed: FATAL: role "rootuser" does not exist PG::ConnectionBad:连接到套接字“/var/run/postgresql/.s.PGSQL.5432”上的服务器失败:没有这样的文件或目录 - PG::ConnectionBad: connection to server on socket "/var/run/postgresql/.s.PGSQL.5432" failed: No such file or directory 连接到套接字“/var/run/postgresql/.s.PGSQL.5432”上的服务器失败:没有这样的文件或目录 - connection to server on socket "/var/run/postgresql/.s.PGSQL.5432" failed: No such file or directory 致命:无法创建锁定文件“postmaster.pid”:权限被拒绝 - FATAL: could not create lock file “postmaster.pid”: Permission denied 得到错误:“Unix 域套接字上的连接”/var/run/postgresql/.s.PGSQL.5432“?” 尝试在 centos 上使用 postgresql 创建用户时 - getting error: “connections on Unix domain socket ”/var/run/postgresql/.s.PGSQL.5432“?” when trying to create a user with postgresql on centos psql:错误:连接到套接字“/var/run/postgresql/.s.PGSQL.5432”上的服务器失败:致命:用户“postgres”的对等身份验证失败(Ubuntu) - psql: error: connection to server on socket "/var/run/postgresql/.s.PGSQL.5432" failed: FATAL: Peer authentication failed for user "postgres" (Ubuntu)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM