在fedora 22中移动postgresql 9.4数据目录

在fedora 22中移动postgresql 9.4数据目录,postgresql,fedora,database-migration,Postgresql,Fedora,Database Migration,我想知道如何在Fedora22安装中移动PostgreSQL数据库目录。在Ubuntu中,通过使用pg_dropcluster和sudo pg_createcluster-d/the/new/location/9.4 main,这是非常简单的,但Fedora似乎没有类似的功能 我将目录/var/lib/pgsql/data复制到一个新位置,并执行了以下操作: su - postgres service postgresql stop export PGDATA="/the/new/locatio

我想知道如何在Fedora22安装中移动PostgreSQL数据库目录。在Ubuntu中,通过使用
pg_dropcluster
sudo pg_createcluster-d/the/new/location/9.4 main
,这是非常简单的,但Fedora似乎没有类似的功能

我将目录
/var/lib/pgsql/data
复制到一个新位置,并执行了以下操作:

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;
这仍然会导致默认的
/var/lib/pgsql/data

有人可以提供一个相关的最新教程的链接,或者解释如何完成移动


注意:我知道这个问题已经在其他发行版和旧版本的Fedora和Psql中得到了回答,但似乎很多文件都被移动了,并且没有一种方法适合我。

因此,这个方法已经过时了。正确的方法是使用
nano/etc/systemd/system/postgresql.service添加此文件:

.include /lib/systemd/system/postgresql.service
[Service]
Environment=PGDATA=/the/new/location/
我相信这也需要重新启动


之后,仍然需要正确设置SELinux才能启动PostgreSQL。

编辑/new/location//PostgreSQL.conf中的参数data\u目录并重新启动。