You are not logged in.
Pages: 1
Topic closed
I'm following the instructions to change default data dir here: https://wiki.archlinux.org/index.php/Po … _directory
But I just can't get postgresql started after doing so. I've tried both methods of overriding the whole postgresql.service, and using a postgresql.service.d/override.conf snippet. Both setting Environment=PGROOT=/home/postgres and as well PIDFile down in that dir.
I keep getting this from systemd:
-- Unit postgresql.service has begun starting up.
Mar 07 12:01:52 ot postgres[12196]: "/home/postgres/data" is missing or empty. Use a command like
Mar 07 12:01:52 ot postgres[12196]: su - postgres -c "initdb --locale en_US.UTF-8 -D '/home/postgres/data'"
Mar 07 12:01:52 ot postgres[12196]: with relevant options, to initialize the database cluster.
Mar 07 12:01:52 ot systemd[1]: postgresql.service: Control process exited, code=exited status=1
Mar 07 12:01:52 ot systemd[1]: Failed to start PostgreSQL database server.
That is the postgresql-check-db-dir failing, but no, /home/postgres/data is not empty. Doing it manually works fine and gives no error:
# su - postgres -c "/usr/bin/postgresql-check-db-dir /home/postgres/data"
#
I have of course also tried doing the initdb again -- it doesn't help. Also, I adjust $HOME of the postgres user in /etc/passwd, but it doesn't do anything (and maybe should not be necessary anyway). Permissions on /home/postgres and down are postgres:postgres, sure.
I try rolling back everything to use /var/lib/postgres/ and it just works. Perhaps it would be relevant to see exactly how systemd calls postgresql-check-db-dir. Can I do that somehow? Not that there are many ways to call it eh...
Last edited by quite (2016-04-05 18:43:39)
Offline
Also, I was able to start up manually from my moved data dir, after first creating the run dir:
mkdir /run/postgresql
chown postgres:postgres /run/postgresql
su - postgres -c "pg_ctl -D /home/postgres/data -l logfile start"
Offline
I'm back at this... I have managed to get the actual output from postgresql-check-db-dir (/var/log/daemon.log !)
Apr 5 20:26:35 ot postgres[4332]: "/home/postgres/data" is missing or empty. Use a command like
Apr 5 20:26:35 ot postgres[4332]: su - postgres -c "initdb --locale en_US.UTF-8 -D '/home/postgres/data'"
Apr 5 20:26:35 ot postgres[4332]: with relevant options, to initialize the database cluster.
This is kinda mad, because /home/postgres/data does exist and is readable by postgres user. If I remove the ExecStartPre=/usr/bin/postgresql-check-db... from the unit file, I instead get the following error output:
Apr 5 20:29:57 ot postgres[4543]: pg_ctl: could not access directory "/home/postgres/data": Permission denied
So, there is something fishy with how systemd i starting the service. How can /home/postgres/data not be accessible?
I wish I could somehow run strace inside the unitfile, ExecStart=/usr/bin/strace >/tmp/foobar /usr/bin/pg_ctl -s ... or so. But I don't get any foobar file...
Again, if I manually become the postgres user on the command-line, I am able to start postgres using pg_ctl (and run postgresql-check-db-dir).
Last edited by quite (2016-04-05 18:35:12)
Offline
OK. Now I know how /home/postgres/data can be inaccessible... ProtectHome=false solved all this.
Offline
Thank you, this was helpful for me too.
Offline
Thanks for this !!
I have been puzzling over this for a few months. I also have my Postgres data directory under /home. I had been running postgres with systemd for a couple of years under Arch with no problems. But I recently switched to Manjaro (I like their XFCE setup) and when I tried to run postgres as I had under Arch it would not start event though I could run the startup steps manually.
This solves my problem.
Thanks again
Offline
Thanks a lot! I've been going crazy with this issue
Offline
Thank you a lot!
Offline
@groonya, please don't necrobump.
https://wiki.archlinux.org/index.php/Co … bumping.22
Closing thread.
Offline
Pages: 1
Topic closed