Reputation: 5416
I would like to know how to move the PostgreSQL database directory in a Fedora 22 installation. In Ubuntu, this is very straightforward by using pg_dropcluster
and sudo pg_createcluster -d /the/new/location/ 9.4 main
, but Fedora does not appear to have anything of the sort.
I copied the directory /var/lib/pgsql/data
to a new location and, did the following:
su - postgres
service postgresql stop
export PGDATA="/the/new/location/"
echo $PGDATA # gives the correct /the/new/location/
service postgresql start
psql
show data_directory;
Which still results in the default /var/lib/pgsql/data
...
Could someone please either provide a link to a relevant and up-to-date tutorial or explain how to complete the move?
Note: I am aware that this question has been answered for other distributions and older versions of Fedora and Psql, but it seems a lot of the files have been moved about and none of the approaches seem to work for me.
Upvotes: 0
Views: 865
Reputation: 5416
So it turns out that this method is out of date. The correct way to do it is to add this file with nano /etc/systemd/system/postgresql.service
:
.include /lib/systemd/system/postgresql.service
[Service]
Environment=PGDATA=/the/new/location/
I believe this also requires a reboot.
Afterwards, one still has to set up SELinux correctly before PostgreSQL can start up.
Upvotes: 2