Postgres 10 cluster does not start automatically after I changed the directory data

时间:2018-03-22 23:28:09

标签: postgresql

I changed the postgres data directory following this steps:

sudo systemctl stop postgresql

sudo rsync -av /var/lib/postgresql /mnt/volume-nyc1-01

sudo nano /etc/postgresql/10/main/postgresql.conf

then I edited postgresql.conf: data_directory = '/mnt/volume-nyc1-01/postgresql/9.5/main'

sudo systemctl start postgresql

The new directory data is owned by the postgres user. The problem is that, after starting ubuntu the postgres cluster is down. I run the command pg_lsclusters and got the answer:

10  main    5432 down   <unknown> /mnt/volume-nyc1-01 /var/log/postgresql/postgresql-10-main.log

And after run sudo systemctl start postgresql@10-main the cluster starts and postgres works ok. So what can I do to fix this and the clusters starts normally after Ubuntu starts?

1 个答案:

答案 0 :(得分:0)

You're editing the PostgreSQL version 9.5 configuration file, as indicated by the directory name. However, the cluster you actually have and are starting is PostgreSQL 10, and probably has a configuration file in a different location. Straighten out the agreement between configuration files, PostgreSQL versions, and systemd unit files, and the cluster should start up automatically.