Re: moving postgresql's data directory

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Henry Drexler <alonup8tb(at)gmail(dot)com>
Cc: PGSQL-Novice <pgsql-novice(at)postgresql(dot)org>
Subject: Re: moving postgresql's data directory
Date: 2014-01-10 15:06:16
Message-ID: 11517.1389366376@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

Henry Drexler <alonup8tb(at)gmail(dot)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

In response to

Responses

Browse pgsql-novice by date

  From Date Subject
Next Message Henry Drexler 2014-01-10 15:38:43 Re: moving postgresql's data directory
Previous Message Henry Drexler 2014-01-10 14:30:22 moving postgresql's data directory