How to rename a PostgreSQL cluster?
Update: version 166 of the postgresl-common package added pg_renamecluster. See Ilya's new answer about that.



In older versions (including Postgres 9.1.4 on Ubuntu 11.10) the name of a cluster is bound to the name of the data directory in the "Multi-Version/Multi-Cluster PostgreSQL architecture" introduced by Martin Pitt. This is shipped with Debian packages (Debian, Ubuntu and related distributions). For a detailed description of the architecture, see:

/usr/share/doc/postgresql-common/README.Debian.gz


Or browse the file online here.

Other installations do not have all of these features, so some people may be confused when you talk about cluster names.

Just renaming the data directory does not work, because you have to change the directory in/etc/postgresql/&lt;version&gt;/&lt;cluster&gt; accordingly.

And there are a couple of settings in your postgresql.conf, that have to be adjusted, too. Run a grep in the directory to see:

postgres@db:/etc/postgresql/9.1/main$ grep 'main' ./*