Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I need to re-build a cluster due to some incorrect parameters set when it was first created. In particular every database in the cluster is set to LC_COLLATE of en_GB.UTF8 and needs to be changed to C.

I'm comfortable with backup up the cluster with pg_dumpall, creating a new cluster with the correct configuration parameters and then restoring the backup to the new cluster.

To keep the risk as low as possible I would like to leave the existing cluster as unchanged as possible so that it can be started on request, but does NOT auto start on a call such as sudo service postgresql start. There is easily enough disk space to do this. Edit: To be clear on this I want to leave the old cluster installed, just not started.

How can I leave the cluster in place, but not have it started automatically along with the new (correctly configured) replacement? That is, how do I stop PostgreSQL from starting the old cluster, even though it is starts the new one?

share|improve this question
add comment

1 Answer

up vote 1 down vote accepted

I've spent some more time on Google and as a result of an argument for another answer, read through the startup scrips. This turns out to be quite simple:


Disabling the old cluster

Under the config files for each cluster (/etc/postgresql/<version>/<cluster>/) there is a file called start.conf. This contains just one uncommented word - auto. By simply changing this to manual the startup scripts will ignore this cluster completely.

To start a cluster manually you can use pg_ctlcluster <version> <name>.


Renaming the old / new cluster

The PostgreSQL scripts work on the basis that the postgresql.conf file for EVERY cluster can be found at /etc/postgresql/<version>/<cluster name>/postgresql.conf.

It's tempting to think that you can simply rename this directory to change the cluster name (keeping the version name the same). Actually it nearly is that simple.

However postgresql.conf references a couple of other files such as pg_hba.conf. These will also get moved when you rename the directory. So after renaming the directory you also need to update these references in postgresql.conf.

There is no requirement to rename the data directory, however it helps maintain your sanity if the data directory name follows that of the cluster. Again if you rename this, remember to update it in the postgresql.conf.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.