Take the 2-minute tour ×
Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. It's 100% free, no registration required.

How do you rename a Postgreql cluster?

I googled and found this old web page, which said just to change the name of the directory. I tried it but it didn't work:

$ pg_lsclusters 
Version Cluster   Port Status Owner    Data directory                     Log file
8.4     main      5432 down   postgres /var/lib/postgresql/8.4/main       /var/log/postgresql/postgresql-8.4-main.log
9.1     main      50420 online postgres /var/lib/postgresql/9.1/main       /var/log/postgresql/postgresql-9.1-main.log$ pg_ctlcluster 9.1 main stop

$ pwd
/var/lib/postgresql/9.1

$ ls
main

$ mv main oldmain

$ pg_ctlcluster 9.1 oldmain start
Error: specified cluster does not exist

Postgresql 9.1.4, Ubuntu 11.10

share|improve this question
    
I'm confused. A PostgreSQL cluster does not have a name. –  a_horse_with_no_name Jul 24 '12 at 22:07
    
@a_horse_with_no_name, I added pg_lsclusters output above. I'm new to this, but I believe you can have multiple clusters, and you have to identify which cluster you are talking to by its name (or maybe directory name, I'm not sure). –  Rob Bednark Jul 24 '12 at 23:43
    
@a_horse_with_no_name: Cluster names are specific to multi-version/multi-cluster architecture in Debian, Ubuntu & friends. I hope my answer can shed some light on this. –  Erwin Brandstetter Jul 25 '12 at 3:28
    
@ErwinBrandstetter: thanks I didn't know that. You live and learn ;) –  a_horse_with_no_name Jul 25 '12 at 6:38
add comment

1 Answer 1

up vote 2 down vote accepted

The name of a cluster is bound to the name of the data directory in the Multi-Version/Multi-Cluster PostgreSQL architecture by Martin Pitt. This is shipped with Debian packages (Debian, Ubuntu and related distributions). 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 according directory in/etc/postgresql/<version>/<cluster> 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' ./*
share|improve this answer
    
Thanks @Erwin_Brandstetter! Nice detailed answer with useful link to Martin Pitt's architecture. I will give your answer a try. –  Rob Bednark Jul 25 '12 at 15:09
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.