Upgrading PostgreSQL
Starting with Tamr v2020.012, Tamr requires PostgreSQL 12. Upgrade to Postgres 12 using the procedures in this section.
PostgreSQL Upgrading Considerations
- You can upgrade to PostgreSQL 12 beginning with Tamr v2020.004 or greater.
- Starting with Tamr v2020.012, PostgreSQL 12 is required. Therefore, before you upgrade to Tamr v2020.012 or greater, you must upgrade PostgreSQL to 12.
Since PostgreSQL 10, PostgreSQL versioning has changed. PostgreSQL 12 denotes a major version of PostgreSQL required by Tamr. Minor releases of PostgreSQL contain only bug and security fixes and are fully compatible with each other. We recommend that you install or upgrade to the latest available minor version of PostgreSQL 12.
Note: If, before upgrading to Tamr v2020.012, you cannot upgrade your PostgreSQL instance to 12 for any reason in your environment and must use an earlier version, contact Tamr Support to obtain advice on the best course of action.
Upgrading PostgreSQL to Version 12 on RHEL 7
These instructions rely on PostgreSQL instructions for upgrading using dumpall
. This method allows you to dump data from one major version of PostgreSQL and reload it in another. You must use a logical backup utility, pg_dumpall
, and not the system backup. For more information, see Upgrading PostgreSQL with Dumpall in the PostgreSQL v12.x documentation.
To upgrade PostgreSQL to version 12 on RHEL 7:
- Stop Tamr and its dependencies. Use the following commands or see Restarting.
sudo su - <tamr-functional-user>
cd <tamr-home-directory>/tamr
./stop-unify.sh
./stop-dependencies.sh
- Install the PostgreSQL 12 client. That way, the pg_dumpall will use newer binaries.
sudo yum install postgresql12
For detailed PostgreSQL 12.x installation instructions, see Installing PostgreSQL in this documentation, or use the procedure outlined in the PostgreSQL YUM Repository.
3. Optional. Write the Tamr PostgreSQL user password <tamr-postgres-user-password>
to a local hidden file and change permissions to avoid prompting for the password.
sudo echo "localhost:5432:*:tamr:<tamr-postgres-user-password>" > .pgpass
sudo chmod 600 .pgpass
- Run the
dumpall
command on the Tamr database (its default name isdoit
). This creates thedumpfile
. Thedumpfile
contains bothpostgres
and thedoit
databases.
pg_dumpall -w -h localhost -U tamr -l doit > dumpfile
- Stop the previously-installed PostgreSQL server. If the current version is not 9.4, change the following command appropriately.
sudo systemctl stop postgresql-9.4
- Install the PostgreSQL 12 server.
sudo yum install postgresql12-server
- Initialize the new version of PostgreSQL client and enable an automatic start.
sudo /usr/pgsql-12/bin/postgresql-12-setup initdb
sudo systemctl enable postgresql-12
sudo systemctl start postgresql-12
- Restore any previous
pg_hba.conf
andpostgresql.conf
modifications. Compare/var/lib/pgsql/9.4/data/pg_hba.conf
and/var/lib/pgsql/12/data/pg_hba.conf
and restore any non-default location forPG_DATA
. - Open
postgresql.conf
and add an entry to it as follows, to make the Postgres instance listen on all addresses, and not only on the loopback address. Save the file.
listen_addresses = '*'
- Open the
postgresql.conf
again and confirm that the port for Postgres is specified correctly as 5432.
By default, PostgreSQL 12 binds the port 5432 after an upgrade when it takes over from PostgreSQL 9.4 or earlier. However, your instance of PostgreSQL 12 may not be configured to use port 5432 after restart. This may happen if the port 5432 is taken by the instance with the previous version of PostgreSQL, such as PostgreSQL 9.4, before that instance is dropped.
port = 5432
- Restart the database.
sudo systemctl restart postgresql-12
- Log into the upgraded instance of PostgreSQL as a PostgreSQL user and move the
dumpfile
.
sudo mv dumpfile /var/lib/pgsql
```
13. Make the `dumpfile` location accessible to the PostgreSQL user.
```shell
sudo chown postgres:postgres /var/lib/pgsql/dumpfile
```
14. Switch to the PostgreSQL user, and use `psql` to restore from the `dumpfile`, as follows. The `psql` command restores the postgres and doit databases present in the `dumpfile`. You run it as the `postgres` user against the `postgres` database because, when the command starts on the upgraded instance, the Tamr functional user and the `doit` database do not yet exist on the instance. They are created during the restore process.
```shell
sudo u - postgres psql -d postgres -f /var/lib/pgsql/dumpfile
logout
```
15. Start Tamr. Use the following commands, or see [Restarting](doc:restarting).
```shell
sudo su - <tamr-functional-user>
cd <tamr-home-directory>/tamr
./start-dependencies.sh
./start-unify.sh
```
16. Optional. Delete the `dumpfile`.
```shell
sudo rm /var/lib/pgsql/dumpfile
```
17. Optional. Disable and uninstall the PostgreSQL client for the previous version.
```shell
sudo yum remove postgresql94
```
#Upgrading PostgreSQL to Version 12 on Ubuntu
These instructions assume that you are running Tamr version before v2020.012.0 and want to upgrade your PostgreSQL instance to v12.
- If you are installing Tamr v2020.012.0 or greater for the first time, you must install PostgreSQL v12. See [Installing PostgreSQL](doc:installing-postgres) in this documentation.
- If you are upgrading to Tamr v2020.012.0 or greater, you must upgrade to PostgreSQL v12 using these instructions.
**To upgrade Your Instance of PostgreSQL to Version 12:**
1. Stop Tamr and its dependencies. See [Restarting](doc:restarting).
```shell
cd /home/ubuntu/tamr
./stop-unify.sh
./stop-dependencies.sh
```
2. Confirm that a single PostgreSQL cluster with version 9.4 exists.
```shell
sudo pg_lsclusters
```
3. Install the PostgreSQL client version 12.
```shell
sudo apt install postgresql-12 postgresql-client-12
```
4. List PostgreSQL clusters.
```shell
sudo pg_lsclusters
```
You should see two clusters running, with PostgreSQL versions 9.4 and 12.
5. Drop the PostgreSQL 12 cluster and stop it.
```shell
sudo pg_dropcluster 12 main --stop
```
6. List PostgreSQL clusters to verify that now the PostgreSQL 9.4 cluster is running.
```shell
sudo pg_lsclusters
```
7. Upgrade the 9.4 cluster to PostgreSQL version 12.
```shell
sudo pg_upgradecluster -v 12 9.4 main
```
8. List PostgreSQL clusters to verify that the PostgreSQL cluster with version 9.4 is present but stopped, and the PostgreSQL cluster with version 12 is running.
```shell
sudo pg_lsclusters
```
9. Verify that PostgreSQL v12 is installed.
```shell
sudo psql --version
```
10. Restore any previous `pg_hba.conf` and `postgresql.conf` modifications. Compare `/var/lib/pgsql/9.4/data/pg_hba.conf` and `/var/lib/pgsql/12/data/pg_hba.conf` and restore any non-default location for `PG_DATA`.
11. Open `postgresql.conf` and add an entry to it as follows, to make the Postgres instance listen on all addresses, and not only on the loopback address. Save the file.
```shell
listen_addresses = '*'
```
12. Open the `postgresql.conf` again and confirm that the port for PostgreSQL is specified correctly as 5432.
By default, PostgreSQL 12 binds the port 5432 after an upgrade when it takes over from PostgreSQL 9.4 or earlier. However, your instance of PostgreSQL 12 may not be configured to use port 5432 after restart. This may happen if the port 5432 is taken by the instance with the previous version of PostgreSQL, such as PostgreSQL 9.4, before that instance is dropped.
```shell
port = 5432
```
13. Verify that Tamr can connect to its database in this instance of PostgreSQL. The default Tamr database name is `doit`.
```shell
sudo psql -h localhost -U tamr -l doit
```
14. Start Tamr and its dependencies, and then upgrade Tamr to v2020.012.0 or greater. See [Upgrading](doc:upgrading).
```shell
./start-dependencies.sh
./start-unify.sh
```
15. Run the Tamr backup to confirm that you have PostgreSQL 12 installed. For example, run:
```shell
cd utils
./unify-admin.sh upgrade --zipFile ~/unify-<version>.zip --installDir ~/ --nobackup
```
This command should succeed if everything is working as required.
**Note:** This command should fail if you are upgrading to a Tamr version before v2020.012, because of a PostgreSQL validation error caused by the PostgreSQL version being higher than required.
16. Confirm that there are no other validation errors and then run the upgrade without validation. See [Upgrading](doc:upgrading) and [Validation](doc:validation).
For example, run:
```shell
./unify-admin.sh upgrade --zipFile ~/unify-<version>.zip --installDir ~/ --nobackup --skipEnvironmentValidation PGValidator
```
17. Optional. Drop the PostgreSQL cluster for the previous version.
```shell
sudo pg_dropcluster 9.4 main
```
Updated over 2 years ago