无法启动 PostgreSQL 数据库服务器

无法启动 PostgreSQL 数据库服务器

经过一些尝试更改访问权限pqsqldata/var/lib/pgsql/data/我的 postgres 服务器中失败。

Postgresql 状态是:

 Loaded: loaded (/usr/lib/systemd/system/postgresql.service; enabled; 
 vendor preset: disabled)
 Active: failed (Result: exit-code) since Ср 2020-02-05 12:46:48 MSK; 
 2min 19s ago
 Process: 572 ExecStart=/usr/bin/pg_ctl start -D ${PGDATA} -s -o -p 
 ${PGPORT} -w -t 300 (code=exited, status=1/FAILURE)
  Process: 564 ExecStartPre=/usr/bin/postgresql-check-db-dir ${PGDATA} 
 (code=exited, status=0/SUCCESS)

 plesk.iline.pro systemd[1]: Starting PostgreSQL database server...
 plesk.iline.pro pg_ctl[572]: FATAL:  data directory 
"/var/lib/pgsql/data" has wrong ownership
 plesk.iline.pro pg_ctl[572]: HINT:  The server must be started by the 
 user that owns the data directory.
  plesk.iline.pro pg_ctl[572]: pg_ctl: could not start server
  plesk.iline.pro pg_ctl[572]: Examine the log output.
  plesk.iline.pro systemd[1]: postgresql.service: control process 
 exited, code=exited status=1
 plesk.iline.pro systemd[1]: Failed to start PostgreSQL database 
 server.
 plesk.iline.pro systemd[1]: Unit postgresql.service entered failed 
 state.
 plesk.iline.pro systemd[1]: postgresql.service failed.

journalctl -xe我看到:

input_userauth_request: invalid user isp [preauth]
plesk.iline.pro sshd[17416]: pam_unix(sshd:auth): check pass; user unknown
plesk.iline.pro sshd[17416]: pam_unix(sshd:auth): authentication failure; logname= uid=0 euid=0 tty=ssh ruser= rhost=118.25.105.121
plesk.iline.pro dreamwhiteApi[4034]: 2020/02/05 12:15:02 Requesting: GET  https://online.moysklad.ru/api/remap/1.1/entity/employee/?
plesk.iline.pro postfix/postdrop[1048]: warning: mail_queue_enter: create file maildrop/663461.1048: Permission denied
 plesk.iline.pro postfix/postdrop[25484]: warning: mail_queue_enter: create file maildrop/739287.25484: Permission denied

我将权利恢复到初始状态:

drwxr-xr-x   4 postgres     postgres     4096  pgsql
drwxr-xr-x  15  polkitd     postgres     4096  data

但问题仍然存在。

Postgresql-version 是 9.2(由于我的服务器中的某些原因,我无法更改此版本)。

答案1

postgres 数据文件夹和所有包含的文件应由用户和组 postgres 拥有:

drwx------ 19 postgres postgres 4.0K Feb  2 14:32 data

像这样修复权限,更改所有者:

sudo chown -R postgres:postgres /var/lib/postgres/data

最后,重新启动 postgresql 服务器:

sudo systemctl restart postgresql

相关内容