PostgreSQL Upgrade Guide v11 to 16
This document describes the steps to upgrade the PostgreSQL version from 11 to 16.
This document applies to RedHat OS v9.2 and Ubuntu v22.04.
Prerequisites
- Ensure there is no broken package from the Ubuntu OS side. If any, please resolve it before initiating the upgrade process.
- Stop the Main-server and Analytics-server service.
- Stop the MeshCentral and HA Observer server services if it exists
- Stop the slave PostgreSQL Database server service if it exists
- Take the database backup and download it at another location
- Take the backup of PostgreSQL Config and Data Directory
- Ensure the PostgreSQL Server service is running
- Check the PostgreSQL version before applying the upgrade
Procedure
Ubuntu v22.04
To upgrade the PostgreSQL in Ubuntu, follow the below steps:
- Stop the main-server and analytics-server service using the below commands:
systemctl stop ft-main-server
systemctl stop ft-analytics-server
- Verify the status of the services using the below commands:
systemctl status ft-main-server
systemctl status ft-analytics-server
Verify the status of the PostgreSQL service using the below command:
systemctl status postgresql
Check the PostgreSQL server version using the below command:
sudo -u postgres psql -c "SELECT version();"
Download the MotadataPGDatabaseUpgrade file and grant the chmod permission using the below command:
chmod 777 MotadataPGDatabaseUpgrade
Execute the downloaded file using the below command:
./MotadataPGDatabaseUpgrade
It will ask for confirmation to install the PostgreSQL 16 database. Type "y" and enter.
Depending on the PostgreSQL server's side, the upgrade process may take some time.
- Once the process is completed, a message "Upgrade Complete" will appear.
Next, verify the PostgreSQL server version using the below command:
sudo -u postgres psql -c "SELECT version();"
If any issue or error appears, inform Motadata without performing any action. You can collect the logs using the below command:
pg_lsclusters
Check the PostgreSQL server service using the below command:
systemctl status postgresql
- Once the PostgreSQL server is upgraded successfully, start checking the main-server and analytics-server services.
systemctl start ft-main-server
systemctl start ft-analytics-server
RedHat v9.2
Similar to Ubuntu 22, follow the below process:
Take the PostgreSQL database backup.
Back up the PostgreSQL Config and Data Directory.
Download the MotadataPGDBUpgrade file and grant the chmod permission using the below command:
chmod 777 MotadataPGDBUpgrade
- Execute the file, and a confirmation message will appear. Type y and click enter to install the PostgreSQL 16 database.
- The upgrade process will begin.
Upon successful upgrade, check the PostgreSQL server version.
sudo -u postgres psql -c "SELECT version();"
- Also, check the PostgreSQL server service status.
Take the backup of VM Snapshot.