-
-
Save edib/f9965ff37df9828016658ef329c9792a to your computer and use it in GitHub Desktop.
Upgrade PostgreSQL 9.3 to 9.6 on Ubuntu 16.04
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sudo apt-get install postgresql-9.6 postgresql-server-dev-9.6 postgresql-contrib-9.6 -y | |
sudo su - postgres -c "psql template1 -p 5433 -c 'CREATE EXTENSION IF NOT EXISTS hstore;'" | |
sudo su - postgres -c "psql template1 -p 5433 -c 'CREATE EXTENSION IF NOT EXISTS \"uuid-ossp\";'" | |
sudo systemctl stop postgresql | |
sudo su - postgres -c '/usr/lib/postgresql/9.6/bin/pg_upgrade -b /usr/lib/postgresql/9.3/bin -B /usr/lib/postgresql/9.6/bin \ | |
-d /var/lib/postgresql/9.3/main/ -D /var/lib/postgresql/9.6/main/ \ | |
-O "-c config_file=/etc/postgresql/9.6/main/postgresql.conf" -o "-c config_file=/etc/postgresql/9.3/main/postgresql.conf" --link' | |
sudo apt-get remove postgresql-9.3 -y | |
sudo sed -i "s:5433:5432:g" /etc/postgresql/9.6/main/postgresql.conf | |
sudo systemctl enable postgresql@9.6-main.service | |
sudo systemctl start postgresql@9.6-main.service |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Tried this on Ubuntu 16.04 and found that after postgres was installed via apt, the data directory
/var/lib/postgresql/9.6/main
was not created. I could initialize everything with pg_ctl but aren't sure how that would affect the pg_upgrade script. Any ideas?Edit: After a bit of digging, I believe the issue was that the 9.6 install setup a cluster for the new instance which was interrupting the pg_upgrade. I ended up getting it working by dropping the new cluster and upgrading the 9.3 cluster using pg_upgradecluster from the following gist: https://gist.github.com/delameko/bd3aa2a54a15c50c723f0eef8f583a44
Install packages
List clusters. Should show existing (9.3) and newly installed (9.6)
Output:
Stop new cluster
Upgrade existing 9.3
Drop old 9.3 cluster