< Previous | Contents | Next >
Managing PostgreSQL Clusters
First, it is worth noting that the concept of “PostgreSQL cluster” is a Debian-specific addition and that you will not find any reference to this term in the official PostgreSQL documentation. From the point of view of the PostgreSQL tools, such a cluster is just an instance of a database server running on a specific port.
That said, Debian’s postgresql-common package provides multiple tools to manage such clusters: pg_createcluster, pg_dropcluster, pg_ctlcluster, pg_upgradecluster, pg_renamecluster, and pg_lsclusters. We won’t cover all those tools here, but you can refer to their respective manual pages for more information.
What you must know is that when a new major version of PostgreSQL gets installed on your system, it will create a new cluster that will run on the next port (usually 5433) and you will keep using the old version until you migrate your databases from the old cluster to the new one.
You can retrieve a list of all the clusters and their status with pg_lsclusters. More impor- tantly, you can automate the migration of your cluster to the latest PostgreSQL version with pg_upgradecluster old-version cluster-name. For this to succeed, you might have to first remove the (empty) cluster created for the new version (with pg_dropcluster new-version cluster-name). The old cluster is not dropped in the process, but it also won’t be started au- tomatically. You can drop it once you have checked that the upgraded cluster works fine.