Postgresql:更改默认的数据path

我想在启动时将PostgreSQL服务器指向特定的非默认数据目录。 现在,我必须(手动或在脚本中)使用pg_ctl来停止并使用/new/path/to/data重新启动数据库。

操作系统是Ubuntu,默认数据目录是/var/lib/postgresql/8.4/main

打开/etc/postgresql/8.4/main/postgresql.conf并将data_directory属性调整为新数据path,并使用( pg_ctlcluster 8.4 main stop/startpg_ctlcluster 8.4 main stop/start或pg_ctl重新启动服务器(如果需要的话)。

确保/new/path/to/data仅适用于postgres用户:

 chown postgres.postgres /new/path/to/data chmod 700 /new/path/to/data