Re: moving postgresql's data directory - Mailing list pgsql-novice

From Tom Lane
Subject Re: moving postgresql's data directory
Date
Msg-id 11517.1389366376@sss.pgh.pa.us
Whole thread Raw
In response to moving postgresql's data directory  (Henry Drexler <alonup8tb@gmail.com>)
Responses Re: moving postgresql's data directory  (Henry Drexler <alonup8tb@gmail.com>)
List pgsql-novice
Henry Drexler <alonup8tb@gmail.com> writes:
> I am just trying to move postgresql's data directory on Fedora 20,
> PostgreSQL 9.3.

> sudo systemctl stop postgresql.service
> sudo mv /var/lib/pgsql/data /home/pgdata
> sudo ln -s /home/pgdata/data  /var/lib/pgsql/
> sudo chown -R postgres:postgres /home/pgdata

That symlink doesn't sound like a terribly good idea.  You should customize
the service file to specify a correct PGDATA path, instead.  Another
thought is that it might be a good idea to alter the postgres user's
home directory setting (in /etc/passwd or wherever they keep it these
days) to be /home/pgdata.

However, I suspect that the key reason this isn't working is SELinux
restrictions.  Does it start if you "setenforce 0"?  I hasten to say
that that's a lousy permanent solution, but it would allow the theory
to be confirmed or denied quickly.  If that's it, you probably need to be
paying attention to the SELinux labeling (cf "ls -Z") of the moved
files and directories.

Also, the reason you're not finding any relevant log entries is probably
that you're not looking in the right place.  If memory serves, the Red Hat
service file starts the postmaster with log output going to
/var/lib/pgsql/postmaster.log or something like that.  The postmaster
will shortly later redirect its log output into some file under
/var/lib/pgsql/pg_log/, but startup-time failure messages might appear
in either place.

            regards, tom lane


pgsql-novice by date:

Previous
From: Henry Drexler
Date:
Subject: moving postgresql's data directory
Next
From: Henry Drexler
Date:
Subject: Re: moving postgresql's data directory