Reputation: 53
I changed the postgres data directory following these steps:
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
So far, the postgres-11 is normal. After I changed the new data_directory's postgres.conf.
1. vim pgsql-11/data/postgresql.conf
data_directory = '/home/eshel/pgsql-11/data'
I can't start postgres-11. I don't know how to handle this. The error follows:
[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.
Upvotes: 3
Views: 6064
Reputation: 53
Process: 10839 ExecStartPre=/usr/pgsql-11/bin/postgresql-11-check-db-dir ${PGDATA} (code=exited, status=1/FAILURE)
The postgres can't read the PGDATA direcotry.With the help of someone else, We solved this by following: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
Then I start postgres11, and it's OK!
systemctl start postgresql-11
Upvotes: 1