filmov
tv
PostgreSQL Upgrade from version 12 To 16 | Upgrading Postgres | step-by-step | CloudRevol Hosting
Показать описание
This article explains how to update PostgreSQL from Version 12 to Version 16 step-by-step. We'll also go over some best practices both before and after the PostgreSQL upgrade in this video.
Prerequisites
One Server with PostgreSQL 12 installed
Ubuntu 20.04 LTS
Shell access with sudo privileges
Note: Backed up current databases for precaution if process breaks or fail
Before starting, ensure you have access to your Ubuntu 20.04 LTS server with shell access and sudo privileges. Additionally, back up your current databases to safeguard against any issues during the upgrade process.
Step 1: Prepare for PostgreSQL 16 Installation
Access the Terminal
Log in to your Ubuntu 20.04 LTS server via SSH or directly if it's a local machine.
Add PostgreSQL Repository Key
Use wget to retrieve the PostgreSQL repository key:
Add PostgreSQL Repository
Add the PostgreSQL repository to your system's sources list:
Update System Packages
Update the package list to ensure you have access to the latest PostgreSQL version:
sudo apt update
Install PostgreSQL 16
Install PostgreSQL 16 along with the client:
sudo apt install postgresql-16 postgresql-client-16 -y
Verify Installation
Check if PostgreSQL 16 is installed correctly:
dpkg -l | grep postgresql
Check PostgreSQL Clusters
View the PostgreSQL clusters available:
pg_lsclusters
Step 2: Upgrade PostgreSQL
Stop PostgreSQL Service
Stop the PostgreSQL service to prepare for the upgrade:
sudo service postgresql stop
Drop Old PostgreSQL Cluster
Remove the old PostgreSQL 16 cluster:
sudo pg_dropcluster 16 main --stop
Upgrade PostgreSQL Cluster
Perform the upgrade of the main cluster from version 12 to 16:
sudo pg_upgradecluster 12 main
Step 3: Start PostgreSQL Service
Start PostgreSQL
Restart the PostgreSQL service:
sudo service postgresql start
Check PostgreSQL Clusters
Verify that PostgreSQL 16 is now active:
pg_lsclusters
Step 4: Drop Old PostgreSQL Cluster (Optional)
If you are certain that the upgrade was successful and you no longer need the old PostgreSQL 12 cluster:
Drop Old Cluster
Permanently remove the PostgreSQL 12 cluster:
sudo pg_dropcluster 12 main
Remember, upgrading a critical service like a database management system carries risks. Always ensure you have backups and test the process in a controlled environment before performing upgrades on a production system.
#postgresql #cloudrevol #tutorial #devops #upgrade #postgres
Prerequisites
One Server with PostgreSQL 12 installed
Ubuntu 20.04 LTS
Shell access with sudo privileges
Note: Backed up current databases for precaution if process breaks or fail
Before starting, ensure you have access to your Ubuntu 20.04 LTS server with shell access and sudo privileges. Additionally, back up your current databases to safeguard against any issues during the upgrade process.
Step 1: Prepare for PostgreSQL 16 Installation
Access the Terminal
Log in to your Ubuntu 20.04 LTS server via SSH or directly if it's a local machine.
Add PostgreSQL Repository Key
Use wget to retrieve the PostgreSQL repository key:
Add PostgreSQL Repository
Add the PostgreSQL repository to your system's sources list:
Update System Packages
Update the package list to ensure you have access to the latest PostgreSQL version:
sudo apt update
Install PostgreSQL 16
Install PostgreSQL 16 along with the client:
sudo apt install postgresql-16 postgresql-client-16 -y
Verify Installation
Check if PostgreSQL 16 is installed correctly:
dpkg -l | grep postgresql
Check PostgreSQL Clusters
View the PostgreSQL clusters available:
pg_lsclusters
Step 2: Upgrade PostgreSQL
Stop PostgreSQL Service
Stop the PostgreSQL service to prepare for the upgrade:
sudo service postgresql stop
Drop Old PostgreSQL Cluster
Remove the old PostgreSQL 16 cluster:
sudo pg_dropcluster 16 main --stop
Upgrade PostgreSQL Cluster
Perform the upgrade of the main cluster from version 12 to 16:
sudo pg_upgradecluster 12 main
Step 3: Start PostgreSQL Service
Start PostgreSQL
Restart the PostgreSQL service:
sudo service postgresql start
Check PostgreSQL Clusters
Verify that PostgreSQL 16 is now active:
pg_lsclusters
Step 4: Drop Old PostgreSQL Cluster (Optional)
If you are certain that the upgrade was successful and you no longer need the old PostgreSQL 12 cluster:
Drop Old Cluster
Permanently remove the PostgreSQL 12 cluster:
sudo pg_dropcluster 12 main
Remember, upgrading a critical service like a database management system carries risks. Always ensure you have backups and test the process in a controlled environment before performing upgrades on a production system.
#postgresql #cloudrevol #tutorial #devops #upgrade #postgres
Комментарии