Skip to main content

How to Upgrade Default PostgreSQL Cluster

Overview

This guide walks you through upgrading your PostgreSQL cluster to version 13, which is required for NextGen compatibility. The upgrade copies the entire cluster, so plan accordingly for disk space and downtime.

Estimated duration: approximately 1.5 to 4 hours per 100 GB of PostgreSQL data.

The minimum supported PostgreSQL version for NextGen is 13. If your version is already 13 or higher, no upgrade is required.

Upgrading PostgreSQL on a production instance is a sensitive operation. We strongly recommend performing this upgrade outside of working hours. If you are unable to upgrade due to cluster size or other constraints, contact the Teramind team. We can apply specific workarounds manually without upgrading the cluster version.

Prerequisites

1. Check Your Current PostgreSQL Version

psql --version

Look for psql (PostgreSQL) XX.XX. The major version is what matters here. In this case, it is “15”. We will refer to it as <postgres_version>.

You do not have to upgrade your cluster at this time if <postgres_version> is 13 or higher.

2. Verify Available Disk Space

The upgrade process copies your entire cluster, temporarily resulting in two clusters (old and new) on disk:

sudo du -sh /var/lib/postgresql/<postgres_version>/main

Look for the value in the first column (e.g., "11G"). Ensure you have at least 1.5x to 2x that amount of free disk space before proceeding.

Upgrade Steps

Step 1: Install PostgreSQL 13 Packages

sudo apt update
sudo apt install -y postgresql-13 postgresql-client-13 postgresql-contrib-13

Step 2: Stop Services

Check the current cluster status, then stop Teramind and PostgreSQL:

pg_lsclusters
sudo systemctl stop teramind
sudo pg_ctlcluster <postgres_version> main stop
pg_lsclusters

Confirm that the cluster status shows as down before continuing.

Step 3: Run the Upgrade

sudo pg_upgradecluster <postgres_version> main -v 13

This may take a while depending on the size of your database. Do not interrupt the process.

Step 4: Start the New Cluster and Teramind

sudo pg_ctlcluster 13 main start
pg_lsclusters
sudo systemctl start teramind

Step 5: Verify the Upgrade

1. Open Teramind in your browser and confirm you can log in.

2. Run the following command to verify that the new cluster (version 13) is online and the old cluster (<postgres_version>) is down:

pg_lsclusters

Step 6: Clean Up the Old Cluster

Once everything is confirmed working, remove the old cluster to reclaim disk space:

sudo pg_dropcluster <postgres_version> main

Need Help?

If you encounter any issues during the upgrade or are running a PostgreSQL version older than 13 with special constraints, reach out to the Teramind Support Team for assistance.

Did this answer your question?