This section describes how to upgrade in-use instances of the for a working deployment of the
.
When you upgrade to a new release of the platform, the underlying databases and their structures are automatically migrated to the new format. However, the database releases are not touched.
In this example, Postgres 9.3 is upgraded to Postgres 9.6.
Before you begin, please verify that you have a valid backup of each . See Backup and Recovery in the Admin Guide.
Before you begin, you must:
5432
.For more information, see Install Databases for PostgreSQL.
For more information, see Install Databases for MySQL.
This procedure describes the process for upgrading the PostgreSQL version in use by the . This procedure assumes the following:
The default port for these commands is port 5432
.
If you are using a non-standard port for either the pre- or post-upgrade versions of PostgreSQL, you can use the following parameters with the pg_upgrade
command:
Parameter | Description |
---|---|
--old-port=<pre-upgrade_port> | The port number of the pre-upgrade instance of PostgreSQL |
--new-port=<post-upgrade_port> | The port number to use for the post-upgrade instance of PostgreSQL |
For more information, see https://www.postgresql.org/docs/9.6/pgupgrade.html.
For CentOS 7.x:
wget https://download.postgresql.org/pub/repos/yum/9.6/redhat/rhel-7-x86_64/pgdg-centos96-9.6-3.noarch.rpm sudo yum -y install pgdg-centos96-9.6-3.noarch.rpm |
For CentOS 8.x:
wget https://download.postgresql.org/pub/repos/yum/9.6/redhat/rhel-8-x86_64/pgdg-centos96-9.6-3.noarch.rpm sudo yum -y install pgdg-centos96-9.6-3.noarch.rpm |
For Red Hat Enterprise Linux 7.x:
wget https://download.postgresql.org/pub/repos/yum/9.6/redhat/rhel-7-x86_64/pgdg-centos96-9.6-3.noarch.rpm sudo yum -y install pgdg-redhat96-9.6-3.noarch.rpm |
For Red Hat Enterprise Linux 8.x:
wget https://download.postgresql.org/pub/repos/yum/9.6/redhat/rhel-8-x86_64/pgdg-centos96-9.6-3.noarch.rpm sudo yum -y install pgdg-redhat96-9.6-3.noarch.rpm |
Install the upgraded version. Below, PostgreSQL 9.6 is installed.
sudo yum install postgresql96.x86_64 postgresql96-server.x86_64 postgresql96-contrib.x86_64 -y |
Create a new data directory for the new database version:
For CentOS 7.x, CentOS 8.x:
sudo /usr/pgsql-9.6/bin/postgresql96-setup initdb |
For RHEL 7.x, RHEL 8.x:
sudo /usr/pgsql-9.6/bin/postgresql96-setup initdb |
Use the following commands to verify that the upgrade is possible:
su postgres cd ~ /usr/pgsql-9.6/bin/pg_upgrade --old-bindir=/usr/pgsql-9.3/bin/ --new-bindir=/usr/pgsql-9.6/bin/ --old-datadir=/var/lib/pgsql/9.3/data/ --new-datadir=/var/lib/pgsql/9.6/data/ --check |
If all is well, you should see a Clusters are compatible
message.
CentOS/RHEL:
sudo service postgresql-9.3 stop |
postgres
user:CentOS/RHEL:
su postgres /usr/pgsql-9.6/bin/pg_upgrade --old-bindir=/usr/pgsql-9.3/bin/ --new-bindir=/usr/pgsql-9.6/bin/ --old-datadir=/var/lib/pgsql/9.3/data/ --new-datadir=/var/lib/pgsql/9.6/data/ |
Upgrade for Ubuntu 16.04 (Xenial)Steps:
Upgrade for Ubuntu 18.04 (Bionic Beaver)PostgreSQL should not be on version 9.3 if you are using this version of the operating system. |
For all operating systems, you must transfer the settings from your old version of PostgreSQL to the new one.
Transfer settings from the configuration files for your old database version to the new one. Please review the old and new versions of these files:
NOTE: It is risky to perform a straight copy of these configuration files. Settings may change. New ones may be introduced. Setting values specific to to the installation may be overwritten in a copy. Please retain a backup of both versions of each file before migrating settings. |
Path to PostgreSQL 9.3 file | Path to PostgreSQL 9.6 file |
---|---|
/var/lib/pgsql/9.3/data/pg_hba.conf | /var/lib/pgsql/9.6/data/pg_hba.conf |
/var/lib/pgsql/9.3/data/postgresql.conf | /var/lib/pgsql/9.6/data/postgresql.conf |
CentOS/RHEL:
sudo service postgresql-9.6 start |
Ubuntu:
sudo service postgresql start |
When the service restarts, you can check the cluster status using the following script:
./analyze_new_cluster.sh |
After you have completed the database installation, you must review the port number of the newly installed database, which may have changed between versions of the database software. That new port number must be applied through the . For more information, see Change Database Port.
If all is well, restart the platform. See Start and Stop the Platform in the Install Guide.
If all of the above tests pass, you can use the following script to delete the old PostgreSQL version and its data directory:
./delete_old_cluster.sh |