Upgrading PostgreSQL Version on Ubuntu Server
Odoo v12 is supporting PostgreSQL 9.5 and above. SO if you are running Odoo server in some of the older version and you wish to upgrade the PostgreSQL, this blog will help you.
When you need to upgrade the PostgreSQL version on Ubuntu, the process is pretty straightforward. This works for upgrading any version from Postgres 9.1, 9.2, 9.3, 9.4, 9.5, and 9.6.
Overview
We're going to be upgrading PostgreSQL server on Ubuntu in this guide. It doesn't matter which version you're upgrading from or to. You can do this with Postgres 9.1, 9.2, 9.3, 9.4, 9.5, and 9.6 or whatever is the most recent version. In this example, I'm upgrading Postgres 9.3 to Postgres 9.5 but all you have to do is replace the version numbers in the commands below to match which old version you're using and the new version you're upgrading to.
This only takes a couple minutes if you have a small database, so let's get started!
1. Install the latest version of Postgres
If you're using the default version available on Ubuntu, you can just upgrade to the latest
sudo apt-get upgrade
To find the installed versions that you currently have on your machine, you can run the following:
$
You can also list the clusters that are on your machine by
$ pg_lsclusters
Ver Cluster Port Status Owner Data directory Log file
9.3 main 5433 down postgres /var/lib/postgresql/9.3/main /var/log/postgresql/postgresql-9.3-main.log
9.6 main 5432 online postgres /var/lib/postgresql/9.6/main /var/log/postgresql/postgresql-9.6-main.log
2. Stop Postgres before we make any changes
First thing's first, we need to stop any services using
3. Rename the new Postgres version's default cluster
When Postgres packages install, they create a default cluster for you to use. We need to rename the new
sudo pg_renamecluster 9.6 main main_pristine
4. Upgrade the old cluster to the latest version
Just replace the version (9.3) here with the old version of Postgres that you're currently using.
5. Make sure everything is working again
We can start Postgres back up again and this time it should be running the new
You should also see that the old cluster is down and the new version of Postgres is up:
$ pg_lsclusters
Ver Cluster Port Status Owner Data directory Log file
9.3 main 5433 down
9.6 main 5432 online
You can keep running of older and new