pg_lsclusters: show information about all PostgreSQL clusters (postgresql-common)
pg_lsclusters [OPTIONS]
What it does
One line per cluster: Ver Cluster Port Status Owner Data-directory Log-file. Status is online, down, or online,recovery for a replica (or a server in recovery).
Options you will use
-h, --no-header- do not print the header line.
-s, --start-conf- add a column with the cluster's start.conf setting (auto, manual, disabled).
-j, --json- output in JSON.
Examples
$ pg_lsclustersevery cluster on the box: port, status, data directory, log
Gotchas
- Not part of PostgreSQL itself: pg_lsclusters, pg_ctlcluster, pg_createcluster and pg_dropcluster come from Debian and Ubuntu's postgresql-common package. On RHEL-style systems use systemctl and pg_ctl.
- A typical line:
18 main 5432 online postgres /var/lib/postgresql/18/main /var/log/postgresql/postgresql-18-main.log. - Status down after a start = it failed: read the Log file column, then
journalctl -u postgresql@18-main. A second cluster on the box gets the next free port (5433).
Taught in
On the blog
Try pg_lsclusters in a real terminal Free, in your browser - a real Ubuntu terminal to try it in, with missions that check your work.