Note: HAVE TO BE IN THIS STATE FIRST: 1. 9.5 main exists on both servers 2. 9.5 main replication is configured and working 3. pg_lsclusters needs to show a 9.6 main cluster 4. /etc/postgresql/9.6/main needs to contain the .conf files and the conf.d needs to be checked out 5. /var/lib/postgresql/9.6/main needs to be symlinked to /media/postgresql/data/9.6/main 6. /media/postgresql/data/9.6/main needs to be an “empty” postgresql db (see step 1) we need a "working" PG9.6 (i.e. create a db) 1. sudo su postgres 2. /usr/lib/postgresql/9.6/bin/initdb /var/lib/postgresql/9.6/main; 3. rm /var/lib/postgresql/9.6/main/postgresql.conf /var/lib/postgresql/9.6/main/pg_hba.conf /var/lib/postgresql/9.6/main/pg_ident.conf 7. Stop pg 9.5 on the master (as yourself) a. sudo systemctl stop postgresql@9.5-main 8. Run the pg_upgrade in check mode -- check it's OK (as postgres) a. /usr/lib/postgresql/9.6/bin/pg_upgrade --check --old-bindir=/usr/lib/postgresql/9.5/bin/ --new-bindir=/usr/lib/postgresql/9.6/bin/ --old-datadir=/var/lib/postgresql/9.5/main --new-datadir=/var/lib/postgresql/9.6/main --link --old-options="-c config_file=/etc/postgresql/9.5/main/postgresql.conf" --new-options="-c config_file=/etc/postgresql/9.6/main/postgresql.conf" 9. Run the pg_upgrade in break-everything mode (as postgres) a. /usr/lib/postgresql/9.6/bin/pg_upgrade --old-bindir=/usr/lib/postgresql/9.5/bin/ --new-bindir=/usr/lib/postgresql/9.6/bin/ --old-datadir=/var/lib/postgresql/9.5/main --new-datadir=/var/lib/postgresql/9.6/main --link --old-options="-c config_file=/etc/postgresql/9.5/main/postgresql.conf" --new-options="-c config_file=/etc/postgresql/9.6/main/postgresql.conf" 10. Stop the standby servers & upgrade (as yourself) a. sudo systemctl stop postgresql@9.5-main 11. Backup the recovery conf on the standby (as postgres) a. cp /var/lib/postgresql/9.5/main/recovery.conf /tmp/recovery.conf 12. Sync the datafiles (on the master as postgres) a. rsync --verbose --size-only --archive --delete --hard-links --no-inc-recursive /media/postgresql/data/main /media/postgresql/data/9.6 PGRETESTA02:/media/postgresql/data 13. Start PG9.6 on the master -- check error logs etc (as yourself) a. sudo systemctl start postgresql@9.6-main b. sudo tail -f /var/log/postgresql/postgresql-9.6-main.log 14. On the standby, copy the recovery.conf into position (as postgres) a. mv /tmp/recovery.conf /var/lib/postgresql/9.6/main/recovery.conf 15. Start PG9.6 on the standby (as yourself) a. sudo systemctl start postgresql@9.6-main b. sudo tail -f /var/log/postgresql/postgresql-9.6-main.log 10. Run the statistics update thing on the master a. ./analyze_new_cluster.sh 11. Drop the old cluster on the primary and then the standbys (as postgres) a. pg_lsclusters b. pg_dropcluster 9.5 main 12. reload systemd and cleanup (as yourself) a. sudo systemctl daemon-reload b. sudo systemctl status postgresql@* c. sudo rm -R /media/postgresql/data/main