Drop Down MenusCSS Drop Down MenuPure CSS Dropdown Menu

Upgrade PostgreSQL 9.4 to 9.6 on Debian Jessie

Shutdown all service that may access PostgreSQL, e.q. odoo.

Install PostgreSQL 9.6 from backport using:
# apt-get -t jessie-backports install postgresql-9.6 postgresql-client-9.6
To view PostgreSQL cluster:
# pg_lsclusters
Ver Cluster Port Status Owner    Data directory               Log file
9.4 main    5432 down   postgres /var/lib/postgresql/9.4/main /var/log/postgresql/postgresql-9.4-main.log
9.6 main    5433 down   postgres /var/lib/postgresql/9.6/main /var/log/postgresql/postgresql-9.6-main.log

"There already is a cluster "main" for 9.6 (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.4/main when 9.6/main also exists. The recommended procedure is to remove the 9.6 cluster with pg_dropcluster and then upgrade with pg_upgradecluster."

To remove cluster 9.6 created during installation:
# pg_dropcluster 9.6 main --stop
Redirecting stop request to systemctl
Now upgrade our cluster 9.4 to 9.6:
# pg_upgradecluster 9.4 main
Stopping old cluster...
Notice: extra pg_ctl/postgres options given, bypassing systemctl for stop operation
Disabling connections to the old cluster during upgrade...
Restarting old cluster with restricted connections...
Redirecting start request to systemctl
Creating new cluster 9.6/main ...
  config /etc/postgresql/9.6/main
  data   /var/lib/postgresql/9.6/main
  locale en_US.UTF-8
  socket /var/run/postgresql
  port   5433
Disabling connections to the new cluster during upgrade...
Redirecting start request to systemctl
Roles, databases, schemas, ACLs...
Fixing hardcoded library paths for stored procedures...
Upgrading database postgres...
Analyzing database postgres...
Fixing hardcoded library paths for stored procedures...
Upgrading database YOUR_DB...
Analyzing database YOUR_DB...
Fixing hardcoded library paths for stored procedures...
Upgrading database template1...
Analyzing database template1...
Re-enabling connections to the old cluster...
Re-enabling connections to the new cluster...
Copying old configuration files...
Copying old start.conf...
Copying old pg_ctl.conf...
Stopping target cluster...
Redirecting stop request to systemctl
Stopping old cluster...
Redirecting stop request to systemctl
Disabling automatic startup of old cluster...
Configuring old cluster to use a different port (5433)...
Starting target cluster on the original port...
Redirecting start request to systemctl
Success. Please check that the upgraded cluster works. If it does,
you can remove the old cluster with

  pg_dropcluster 9.4 main 
After upgrade list cluster becomes like this:
# pg_lsclusters
Ver Cluster Port Status Owner    Data directory               Log file
9.4 main    5433 down   postgres /var/lib/postgresql/9.4/main /var/log/postgresql/postgresql-9.4-main.log
9.6 main    5432 online postgres /var/lib/postgresql/9.6/main /var/log/postgresql/postgresql-9.6-main.log
After everything work fine, we can drop old cluster i.e. 9.4
# pg_dropcluster 9.4 main
# pg_lsclusters
Ver Cluster Port Status Owner    Data directory               Log file
9.6 main    5432 online postgres /var/lib/postgresql/9.6/main /var/log/postgresql/postgresql-9.6-main.log
We can remove and purge postgresql 9.4
# apt-get --purge remove postgresql-9.4 postgresql-client-9.4
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages will be REMOVED:
  postgresql* postgresql-9.4* postgresql-client* postgresql-client-9.4*
0 upgraded, 0 newly installed, 4 to remove and 0 not upgraded.
After this operation, 25.3 MB disk space will be freed.
Do you want to continue? [Y/n] y
(Reading database ... 97410 files and directories currently installed.)
Removing postgresql (9.4+165+deb8u2) ...
Removing postgresql-9.4 (9.4.10-0+deb8u1) ...
Purging configuration files for postgresql-9.4 (9.4.10-0+deb8u1) ...
Removing postgresql-client (9.4+165+deb8u2) ...
Removing postgresql-client-9.4 (9.4.10-0+deb8u1) ...
Processing triggers for postgresql-common (178~bpo8+1) ...
Building PostgreSQL dictionaries from installed myspell/hunspell packages...
Removing obsolete dictionary files:
About Debian Backports

Comments

Popular posts from this blog

How to find the server is whether standby (slave) or primary(master) in Postgresql replication ?

7 Steps to configure BDR replication in postgresql

How to Get Table Size, Database Size, Indexes Size, schema Size, Tablespace Size, column Size in PostgreSQL Database

Ora2PG - Oracle/MySQL to Postgres DB migration Version 20.0

PostgreSQL Introduction