I'm trying to set up a PostgreSQL cluster in my home directory on Debian.
EDIT: There are a couple of reasons why I think this a good idea:
- I don't use Postgres frequently so I don't currently have the
systemdservice enabled. I just start it with
servicewhenever I actually need it.
- The default data directory is on my root partition which is quite small. So I'd like to move it to my home partition which is big.
I've created the cluster and can successfully start the server, but I can't seem to daemonize it.
This is how I created the cluster, using the Debian custom wrapper command:
$ PG_CLUSTER_CONF_ROOT=/home/user/.local/etc/postgresql pg_createcluster -u user -d /home/user/.local/var/lib/postgresql -s /home/user/.local/var/run/postgresql -l /home/user/.local/var/log/postgresql -p 5434 --start-conf manual --locale en_GB.UTF-8 9.5 mycluster install: cannot change owner and permissions of ‘/home/user/.local/etc/postgresql/9.5’: Operation not permitted Creating new cluster 9.5/mycluster ... config /home/user/.local/etc/postgresql/9.5/mycluster data /home/user/.local/var/lib/postgresql locale en_GB.UTF-8 socket /home/user/.local/var/run/postgresql port 5434 Warning: The parent /var/run/postgresql of the selected stats_temp_directory is not writable for the cluster owner. Not adding this setting in postgresql.conf.
(I manually added the
I can now start the cluster like this (again, with the Debian wrapper command):
$ PG_CLUSTER_CONF_ROOT=/home/user/.local/etc/postgresql pg_ctlcluster --foreground 9.5 mycluster start
And it runs, and I see log messages in my console, and I can use
psql (as long as I set the socket file with
-h and the port with
-p, which is fine).
But I can't get it to start without the
--foregound option. It waits for a short while, and then says:
The PostgreSQL server failed to start. Please check the log output:
I've tried setting the log file, both like this:
$ PG_CLUSTER_CONF_ROOT=/home/user/.local/etc/postgresql pg_ctlcluster -o '-r /home/user/.local/var/log/postgresql/server.log' 9.5 mycluster start
And like this:
$ PG_CLUSTER_CONF_ROOT=/home/user/.local/etc/postgresql pg_ctlcluster 9.5 mycluster start -- -l /home/user/.local/var/log/postgresql/server.log
But I still get the same result. And no log file gets created.