A Step-by-Step Guide to upgrade postgresql from 9-6 to 10 on ubuntu 16
1.Make a backup. Make sure that your database is not being updated.
pg_dumpall > outputfile
2. Install Postgres 10.
a) Create the file /etc/apt/sources.list.d/pgdg.list and add a line for the repository
deb http://apt.postgresql.org/pub/repos/apt/ xenial-pgdg main
b) Import the repository signing key, and update the package lists
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add - sudo apt-get update
3. Run sudo apt-get install postgresql-10. A newer version will be installed side-by-side with the earlier version.
4. Run pg_lsclusters:
Ver Cluster Port Status Owner Data directory Log file
9.6 main 5433 online postgres /9.6/main /var/log/postgresql/postgresql-9.6-main.log
10 main 5432 online postgres /10/main /var/log/postgresql/postgresql-10-main.log
There already is a cluster main for 10 (since this is created by default on package installation). This is done so that a fresh installation works out of the box without the need to create a cluster first, but of course it clashes when you try to upgrade 9.6/main when 10/main also exists. The recommended procedure is to remove the 10 cluster with pg_dropcluster and then upgrade with pg_upgradecluster.
5. Stop the 10 cluster and drop it: sudo pg_dropcluster 10 main --stop
6. Stop all processes and services writing to the database. Stop the database:
sudo systemctl stop postgresql
7. Upgrade the 9.6 cluster: sudo pg_upgradecluster -m upgrade 9.6 main
8. Run pg_lsclusters. Your 9.6 cluster should now be "down", and the 10 cluster should be online at 5432:
Ver Cluster Port Status Owner Data directory Log file
9.6 main 5433 down postgres /9.6/main /var/log/postgresql/postgresql-9.6-main.log
10 main 5432 online postgres /10/main /var/log/postgresql/postgresql-10-main.log
Comments
Post a Comment