我按照以下步骤更改了postgres数据目录:
systemctl stop postgresql-11.service
cp -r /var/lib/pgsql/11/data /home/eshel/pgsql-11/
chown -R postgres:postgres /home/eshel/pgsql-11/
chmod 700 /home/eshel/pgsql-11/
vi /usr/lib/systemd/system/postgresql-11.service
Environment=PGDATA=/home/eshel/pgsql-11/data/
systemctl daemon-reload
systemctl start postgresql-11.service
到目前为止,postgres-11正常。 在更改了新的data_directory的postgres.conf之后。
1. vim pgsql-11/data/postgresql.conf
data_directory = '/home/eshel/pgsql-11/data'
我无法启动postgres-11。我不知道该如何处理。 错误如下:
[root@localhost 11]# systemctl start postgresql-11.service
* Job for postgresql-11.service failed because the control process exited with error code. See "systemctl status postgresql-11.service" and "journalctl -xe" for details.
[root@localhost 11]# systemctl status postgresql-11.service
● postgresql-11.service - PostgreSQL 11 database server
* Loaded: loaded (/usr/lib/systemd/system/postgresql-11.service; enabled; vendor preset: disabled)
* Active: failed (Result: exit-code) since Fri 2019-10-11 23:05:00 CST; 27s ago
* Docs: https://www.postgresql.org/docs/11/static/
* Process: 12758 ExecStartPre=/usr/pgsql-11/bin/postgresql-11-check-db-dir ${PGDATA} (code=exited, status=1/FAILURE)
* Main PID: 11582 (code=exited, status=0/SUCCESS)
* Oct 11 23:05:00 localhost.localdomain systemd[1]: Starting PostgreSQL 11 database server...
* Oct 11 23:05:00 localhost.localdomain systemd[1]: postgresql-11.service: control process exited, code=exited status=1
* Oct 11 23:05:00 localhost.localdomain systemd[1]: Failed to start PostgreSQL 11 database server.
* Oct 11 23:05:00 localhost.localdomain systemd[1]: Unit postgresql-11.service entered failed state.
* Oct 11 23:05:00 localhost.localdomain systemd[1]: postgresql-11.service failed.
[root @ localhost 11]#journalctl -xe
* Oct 11 23:01:21 localhost.localdomain dbus[6461]: [system] Activating service name='org.freedesktop.problems' (using servicehe
* Oct 11 23:01:21 localhost.localdomain dbus[6461]: [system] Successfully activated service 'org.freedesktop.problems'
* Oct 11 23:04:51 localhost.localdomain nautilus-deskto[9318]: g_simple_action_set_enabled: assertion 'G_IS_SIMPLE_ACTION (simpl
* Oct 11 23:05:00 localhost.localdomain polkitd[6478]: Registered Authentication Agent for unix-process:12752:1022414 (system bu
* Oct 11 23:05:00 localhost.localdomain systemd[1]: Starting PostgreSQL 11 database server...
* -- Subject: Unit postgresql-11.service has begun start-up
* -- Defined-By: systemd
* -- Unit postgresql-11.service has begun starting up.
* Oct 11 23:05:00 localhost.localdomain postgresql-11-check-db-dir[12758]: "/home/eshel/pgsql-11/data/" is missing or empty.
* Oct 11 23:05:00 localhost.localdomain postgresql-11-check-db-dir[12758]: Use "/usr/pgsql-11/bin/postgresql-11-setup initdb" to
* Oct 11 23:05:00 localhost.localdomain postgresql-11-check-db-dir[12758]: See /usr/share/doc/postgresql11-11.4/README.rpm-dist
* Oct 11 23:05:00 localhost.localdomain systemd[1]: postgresql-11.service: control process exited, code=exited status=1
* Oct 11 23:05:00 localhost.localdomain systemd[1]: Failed to start PostgreSQL 11 database server.
* -- Subject: Unit postgresql-11.service has failed
* -- Defined-By: systemd
* -- Unit postgresql-11.service has failed.
* -- The result is failed.
* Oct 11 23:05:00 localhost.localdomain systemd[1]: Unit postgresql-11.service entered failed state.
* Oct 11 23:05:00 localhost.localdomain systemd[1]: postgresql-11.service failed.
答案 0 :(得分:0)
进程:10839 ExecStartPre = / usr / pgsql-11 / bin / postgresql-11-check-db-dir $ {PGDATA}(代码已退出,状态= 1 /失败) > postgres无法读取PGDATA目录。在其他人的帮助下,我们通过以下步骤解决了该问题:
Before modification:
drwx------. 19 eshel eshel 4096 Oct 12 21:00 eshel
After modification:
[root@localhost eshel]# chmod 755 ../eshel/
[root@localhost eshel]# ll ../
drwxr-xr-x. 19 eshel eshel 4096 Oct 12 21:00 eshel
然后我启动postgres11,就可以了!
systemctl start postgresql-11