SlideShare una empresa de Scribd logo
1 de 31
Descargar para leer sin conexión
An ultimate guide to
upgrading your
PostgreSQL
installation
Ilya Kosmodemiansky
ik@dataegret.com
2 Why this talk?
Upgrading your PostgreSQL is not a rocket science!
• ...but there are lots of small details
• Unsuccessful upgrade can ruin your data
• Or at least cause an unacceptable downtime
• Upgrade requires good knowledge of your system and substantial
preparation time
dataegret.com
3 Because of that
• DBAs do not like upgrades
• They are attached to outdated versions
• They manage to screw up an upgrade when they finally decide to perform
one
dataegret.com
4 Why do you need to upgrade?
• Bugfixes, security fixes
• Many performance improvements and new features over the last years
• Upgrading on time makes it easier
• Running 7.* in 2017 would make consultants too happy
dataegret.com
5 PostgreSQL version numbering
<= 9.6.*
9.4.3Major
Major
Minor
dataegret.com
5 PostgreSQL version numbering
> 9.6.*
10.2
Major Minor
dataegret.com
6 Types of upgrades
• Minor
New versions’ binaries can run on old version datafiles
• Major
New versions’ binaries can run on old version datafiles, but require new
system tables and internal data format may change
• Major with special requirements
dataegret.com
7 Before any upgrade
• Read carefully version specific release notes
• Play with chosen upgrade method in test environment
• Align with your application development team
• Make a backup and check it by test recovery
dataegret.com
8 Minor upgrades are easy
• You simply install new binaries and start new database server on the old
data directory
• There are no new features between minor versions
• Still - keep an eye on updating all PostgreSQL-related packages you use
dataegret.com
9 Major upgrade prerequisites
• Install new versions for all PostgreSQL-related packages
• Read carefully all release notes
• Know your PostgreSQL installation
• Choose the method and carefully read the documentation for this method
• Align with your application development team
• Do a backup and check it by doing a test recovery
dataegret.com
10 Check which PostgreSQL-related packages you use
your_server:~$ sudo dpkg -l *postgres*
||/ Name Version
+++-=================================================-=============================
ii postgresql-9.3 9.3.15-1.pgdg14.04+1
ii postgresql-client-9.3 9.3.15-1.pgdg14.04+1
ii postgresql-client-common 182.pgdg14.04+1
ii postgresql-common 182.pgdg14.04+1
ii postgresql-contrib-9.3 9.3.15-1.pgdg14.04+1
ii postgresql-plperl-9.3 9.3.15-1.pgdg14.04+1
ii postgresql-server-dev-9.3 9.3.15-1.pgdg14.04+1
your_server:~$ sudo dpkg -l *pg*
||/ Name Version
+++-=================================================-=============================
ii libdbd-pg-perl 2.19.3-2
ii pgbouncer 1.5.4-4
ii pgdg-keyring 2014.1
dataegret.com
11 Major upgrade methods
• Good old dump/restore
• pg_upgrade
• Replication-based methods
dataegret.com
12 Major upgrade using pg_dump
• Difficult to make without downtime if you have a large, heavyloaded
database
• Requires additional disk space
• Works with any PostgreSQL version since 7.0
• pg_dump -Fc - custom format, -Z - compression
• pg_dump -Fd –jobs can be a good option in terms of speed and downtime
• But if using -j you can’t do things like that: pg_dumpall -p 5432 | psql -d
postgres -p 5433
• If your installation can be upgraded easily by dump/restore, you are lucky!
dataegret.com
13 Major upgrade using pg_dump - procedure
• Install new binaries
• Initialize new cluster. Don’t forget about locale
• Change config files appropriately
• It can be a good idea to use newer version of pg_dump, but be careful if
running on pre-9.2 server
• Restore the dump, try to figure out if everything looks good
• Switch your application to the new cluster
dataegret.com
14 pg_upgrade - outline
• How it works?
• Procedure
Simple case - standalone server
How to minimize downtime?
Upgrading hot-standby cluster
• Details
dataegret.com
15 pg_upgrade - How it works?
user data
pg_clog
pg_catalog
pg_clog
pg_catalog
old
new
user data
pg_clog
pg_catalog
pg_clog
pg_catalog
freeze
user data
pg_clog
pg_catalog
pg_clog
pg_catalog
pg_clog and pg_control
user data
pg_clog
pg_catalog
pg_clog
pg_catalog
user data
dupm/restore of schema
and
cp or relink of datafiles
dataegret.com
15 pg_upgrade - How it works?
• Decouple pg_clog (pg_xact) from new cluster
• Couple old pg_clog to a new cluster and set xid
• Restore schema
• Copy or link datafiles from old cluster to a new one
dataegret.com
16 pg_upgrade - procedure
• Create empty database for new version of PostgreSQL
• Stop database with old PostgreSQL version
• Start upgrade procedure with pg_upgrade command
• Start database that runs on new PostgreSQL version
• Start collecting statistics (pg_upgrade does not transfer optimizer
statistics)
• When statistic collection started, you can open database for your
application
• Depending on your database, you can achieve 1-10 min downtime target
dataegret.com
17 pg_upgrade - minimizing downtime
• Use pgbouncer
PAUSE/RESUME
Issue CHECKPOINT; on old server before you start, to make shutdown
process faster
• Use -k (–link) to use hard links instead of copy (but carefully!)
dataegret.com
18 pg_upgrade - hot-standby replica
• Upgrade master as a standalone server
• Keep replica intact to failover if something goes wrong
• Reinstantiate your replica
• Procedure
Pause pgbouncer on standby or stop it
Clone a replica from upgraded master using pg_basebackup
Start replica with new binaries
Resume pgbouncer connections or start pgbouncer.
dataegret.com
19 pg_upgrade - Details
• pg_upgrade does not transfer optimizer statistics
• instead, it generates a script ./analyze_new_cluster.sh
It basically runs vacuumdb –all –analyze-in-stages
In some cases it is better to run vacuumdb –all –analyze-only
Since 9.5 you can vacuumdb run in parallel (-j)
We usually use vacuumdb –all –analyze-in-stages and open database for
application after medium optimizer statistics (10 targets) are generated
dataegret.com
20 pg_upgrade - Details
• Documentation suggests to use rsync to reinstantiate standby
• rsync –archive –delete –hard-links –size-only old_pgdata new_pgdata
remote_dir
• rsync allows you to save a lot of network traffic in that case
• ...and provides lots of opportunities to shoot yourself in the foot
dataegret.com
21 pg_upgrade - Details
• Debian/Ubuntu follow their own way
• Wrappers, like pg_ctlcluster are designed to manipulate PostgreSQL cluster
in a Debian way
• pg_upgradecluster -v 9.5 9.3 main1 -m upgrade -k supposed to be a
make-me-happy button for a DBA
• It even takes care of converting postgresql.conf parameters for you
• But I strongly recommend to do this manually
dataegret.com
22 pg_upgrade - Details
• Extensions can surprise you
• pg_upgrade keeps old versions of extensions
• We advise to cycle through all extensions and perform alter extension
EXTENSION_NAME update;
• Some extensions need special care: for example PostGIS should be
updated before an upgrade
dataegret.com
23 Using replication to upgrade PostgreSQL
• Streaming replication doesn’t work between versions
• But some replication methods can do that
Logical replication
Slony-I
Londiste
• Procedure
Setup new database cluster
Setup replication from old one to a new one
Perform failover
dataegret.com
24 Logical replication
• New promising method
• Allows you to upgrade from 9.4 to a newer version
• It can be tricky:
Check documentation carefully
If you have a complex schema, you may need some wrapper, like
https://github.com/rtshome/pgrepup
Check what you replicate using pglogical.replication_set
Don’t forget about sequences
dataegret.com
25 Slony-I
• Old and bulletproof
• Can be used with old versions
• Failover can be done really fast
• Drawbacks
Trigger based - can cause heavy load on old cluster
Extra disk space is needed
dataegret.com
26 Londiste
• I’am not a big fan of Londiste
• Same drawbacks as with Slony, but without Slony’s robustness
• Lots of bugs (compared to Slony)
• Tool was designed for a different purpose
dataegret.com
27 Conclusion
Method downtime extra disk space complexity riskiness
dump/restore high double low low
pg_upgrade (copy) high double high low
pg_upgrade (link) low low high very high
Logical replication low double high low
Slony-I low double medium low
Londiste low double medium low
dataegret.com
28 Reading list
• http://momjian.us/main/writings/pgsql/pg_upgrade.pdf
• https://blog.2ndquadrant.com/untangling-the-postgresql-upgrade/
• http://blog.endpoint.com/2016/12/postgres-statistics-and-pain-of-
analyze.html
• https://www.depesz.com/2016/11/08/major-version-upgrading-with-
minimal-downtime/
dataegret.com
29 Questions?
ik@dataegret.com
dataegret.com

Más contenido relacionado

La actualidad más candente

Broken Linux Performance Tools 2016
Broken Linux Performance Tools 2016Broken Linux Performance Tools 2016
Broken Linux Performance Tools 2016Brendan Gregg
 
PostgreSQL9.3 Switchover/Switchback
PostgreSQL9.3 Switchover/SwitchbackPostgreSQL9.3 Switchover/Switchback
PostgreSQL9.3 Switchover/SwitchbackVibhor Kumar
 
The consequences of sync_binlog != 1
The consequences of sync_binlog != 1The consequences of sync_binlog != 1
The consequences of sync_binlog != 1Jean-François Gagné
 
MySQL Parallel Replication: All the 5.7 and 8.0 Details (LOGICAL_CLOCK)
MySQL Parallel Replication: All the 5.7 and 8.0 Details (LOGICAL_CLOCK)MySQL Parallel Replication: All the 5.7 and 8.0 Details (LOGICAL_CLOCK)
MySQL Parallel Replication: All the 5.7 and 8.0 Details (LOGICAL_CLOCK)Jean-François Gagné
 
Deep dive into PostgreSQL statistics.
Deep dive into PostgreSQL statistics.Deep dive into PostgreSQL statistics.
Deep dive into PostgreSQL statistics.Alexey Lesovsky
 
PostgreSQL WAL for DBAs
PostgreSQL WAL for DBAs PostgreSQL WAL for DBAs
PostgreSQL WAL for DBAs PGConf APAC
 
ProxySQL - High Performance and HA Proxy for MySQL
ProxySQL - High Performance and HA Proxy for MySQLProxySQL - High Performance and HA Proxy for MySQL
ProxySQL - High Performance and HA Proxy for MySQLRené Cannaò
 
Patroni: PostgreSQL HA in the cloud
Patroni: PostgreSQL HA in the cloudPatroni: PostgreSQL HA in the cloud
Patroni: PostgreSQL HA in the cloudLucio Grenzi
 
Postgresql database administration volume 1
Postgresql database administration volume 1Postgresql database administration volume 1
Postgresql database administration volume 1Federico Campoli
 
What is new in PostgreSQL 14?
What is new in PostgreSQL 14?What is new in PostgreSQL 14?
What is new in PostgreSQL 14?Mydbops
 
NGINX: High Performance Load Balancing
NGINX: High Performance Load BalancingNGINX: High Performance Load Balancing
NGINX: High Performance Load BalancingNGINX, Inc.
 
What’s the Best PostgreSQL High Availability Framework? PAF vs. repmgr vs. Pa...
What’s the Best PostgreSQL High Availability Framework? PAF vs. repmgr vs. Pa...What’s the Best PostgreSQL High Availability Framework? PAF vs. repmgr vs. Pa...
What’s the Best PostgreSQL High Availability Framework? PAF vs. repmgr vs. Pa...ScaleGrid.io
 
Deep dive to PostgreSQL Indexes
Deep dive to PostgreSQL IndexesDeep dive to PostgreSQL Indexes
Deep dive to PostgreSQL IndexesIbrar Ahmed
 
PostgreSQL worst practices, version PGConf.US 2017 by Ilya Kosmodemiansky
PostgreSQL worst practices, version PGConf.US 2017 by Ilya KosmodemianskyPostgreSQL worst practices, version PGConf.US 2017 by Ilya Kosmodemiansky
PostgreSQL worst practices, version PGConf.US 2017 by Ilya KosmodemianskyPostgreSQL-Consulting
 
[Pgday.Seoul 2017] 8. PostgreSQL 10 새기능 소개 - 김상기
[Pgday.Seoul 2017] 8. PostgreSQL 10 새기능 소개 - 김상기[Pgday.Seoul 2017] 8. PostgreSQL 10 새기능 소개 - 김상기
[Pgday.Seoul 2017] 8. PostgreSQL 10 새기능 소개 - 김상기PgDay.Seoul
 
Mastering PostgreSQL Administration
Mastering PostgreSQL AdministrationMastering PostgreSQL Administration
Mastering PostgreSQL AdministrationEDB
 
MariaDB Performance Tuning and Optimization
MariaDB Performance Tuning and OptimizationMariaDB Performance Tuning and Optimization
MariaDB Performance Tuning and OptimizationMariaDB plc
 
PostgreSQL and JDBC: striving for high performance
PostgreSQL and JDBC: striving for high performancePostgreSQL and JDBC: striving for high performance
PostgreSQL and JDBC: striving for high performanceVladimir Sitnikov
 

La actualidad más candente (20)

Broken Linux Performance Tools 2016
Broken Linux Performance Tools 2016Broken Linux Performance Tools 2016
Broken Linux Performance Tools 2016
 
PostgreSQL replication
PostgreSQL replicationPostgreSQL replication
PostgreSQL replication
 
PostgreSQL9.3 Switchover/Switchback
PostgreSQL9.3 Switchover/SwitchbackPostgreSQL9.3 Switchover/Switchback
PostgreSQL9.3 Switchover/Switchback
 
The consequences of sync_binlog != 1
The consequences of sync_binlog != 1The consequences of sync_binlog != 1
The consequences of sync_binlog != 1
 
MySQL Parallel Replication: All the 5.7 and 8.0 Details (LOGICAL_CLOCK)
MySQL Parallel Replication: All the 5.7 and 8.0 Details (LOGICAL_CLOCK)MySQL Parallel Replication: All the 5.7 and 8.0 Details (LOGICAL_CLOCK)
MySQL Parallel Replication: All the 5.7 and 8.0 Details (LOGICAL_CLOCK)
 
Deep dive into PostgreSQL statistics.
Deep dive into PostgreSQL statistics.Deep dive into PostgreSQL statistics.
Deep dive into PostgreSQL statistics.
 
PostgreSQL WAL for DBAs
PostgreSQL WAL for DBAs PostgreSQL WAL for DBAs
PostgreSQL WAL for DBAs
 
ProxySQL - High Performance and HA Proxy for MySQL
ProxySQL - High Performance and HA Proxy for MySQLProxySQL - High Performance and HA Proxy for MySQL
ProxySQL - High Performance and HA Proxy for MySQL
 
Backup and-recovery2
Backup and-recovery2Backup and-recovery2
Backup and-recovery2
 
Patroni: PostgreSQL HA in the cloud
Patroni: PostgreSQL HA in the cloudPatroni: PostgreSQL HA in the cloud
Patroni: PostgreSQL HA in the cloud
 
Postgresql database administration volume 1
Postgresql database administration volume 1Postgresql database administration volume 1
Postgresql database administration volume 1
 
What is new in PostgreSQL 14?
What is new in PostgreSQL 14?What is new in PostgreSQL 14?
What is new in PostgreSQL 14?
 
NGINX: High Performance Load Balancing
NGINX: High Performance Load BalancingNGINX: High Performance Load Balancing
NGINX: High Performance Load Balancing
 
What’s the Best PostgreSQL High Availability Framework? PAF vs. repmgr vs. Pa...
What’s the Best PostgreSQL High Availability Framework? PAF vs. repmgr vs. Pa...What’s the Best PostgreSQL High Availability Framework? PAF vs. repmgr vs. Pa...
What’s the Best PostgreSQL High Availability Framework? PAF vs. repmgr vs. Pa...
 
Deep dive to PostgreSQL Indexes
Deep dive to PostgreSQL IndexesDeep dive to PostgreSQL Indexes
Deep dive to PostgreSQL Indexes
 
PostgreSQL worst practices, version PGConf.US 2017 by Ilya Kosmodemiansky
PostgreSQL worst practices, version PGConf.US 2017 by Ilya KosmodemianskyPostgreSQL worst practices, version PGConf.US 2017 by Ilya Kosmodemiansky
PostgreSQL worst practices, version PGConf.US 2017 by Ilya Kosmodemiansky
 
[Pgday.Seoul 2017] 8. PostgreSQL 10 새기능 소개 - 김상기
[Pgday.Seoul 2017] 8. PostgreSQL 10 새기능 소개 - 김상기[Pgday.Seoul 2017] 8. PostgreSQL 10 새기능 소개 - 김상기
[Pgday.Seoul 2017] 8. PostgreSQL 10 새기능 소개 - 김상기
 
Mastering PostgreSQL Administration
Mastering PostgreSQL AdministrationMastering PostgreSQL Administration
Mastering PostgreSQL Administration
 
MariaDB Performance Tuning and Optimization
MariaDB Performance Tuning and OptimizationMariaDB Performance Tuning and Optimization
MariaDB Performance Tuning and Optimization
 
PostgreSQL and JDBC: striving for high performance
PostgreSQL and JDBC: striving for high performancePostgreSQL and JDBC: striving for high performance
PostgreSQL and JDBC: striving for high performance
 

Similar a Ilya Kosmodemiansky - An ultimate guide to upgrading your PostgreSQL installation PGConf.EU

Operating PostgreSQL at Scale with Kubernetes
Operating PostgreSQL at Scale with KubernetesOperating PostgreSQL at Scale with Kubernetes
Operating PostgreSQL at Scale with KubernetesJonathan Katz
 
Rapid Upgrades With Pg_Upgrade, Bruce Momjian
Rapid Upgrades With Pg_Upgrade, Bruce MomjianRapid Upgrades With Pg_Upgrade, Bruce Momjian
Rapid Upgrades With Pg_Upgrade, Bruce MomjianFuenteovejuna
 
Best Practices: Migrating a Postgres Production Database to the Cloud
Best Practices: Migrating a Postgres Production Database to the CloudBest Practices: Migrating a Postgres Production Database to the Cloud
Best Practices: Migrating a Postgres Production Database to the CloudEDB
 
Pg upgrade employer
Pg upgrade employerPg upgrade employer
Pg upgrade employerEDB
 
Using PostgreSQL With Docker & Kubernetes - July 2018
Using PostgreSQL With Docker & Kubernetes - July 2018Using PostgreSQL With Docker & Kubernetes - July 2018
Using PostgreSQL With Docker & Kubernetes - July 2018Jonathan Katz
 
Upgrade to MySQL 5.6 without downtime
Upgrade to MySQL 5.6 without downtimeUpgrade to MySQL 5.6 without downtime
Upgrade to MySQL 5.6 without downtimeOlivier DASINI
 
What's New in PostgreSQL 9.3
What's New in PostgreSQL 9.3What's New in PostgreSQL 9.3
What's New in PostgreSQL 9.3EDB
 
TechEvent PostgreSQL Best Practices
TechEvent PostgreSQL Best PracticesTechEvent PostgreSQL Best Practices
TechEvent PostgreSQL Best PracticesTrivadis
 
Overview of Postgres Utility Processes
Overview of Postgres Utility ProcessesOverview of Postgres Utility Processes
Overview of Postgres Utility ProcessesEDB
 
Webinar: Best Practices for Upgrading to MongoDB 3.2
Webinar: Best Practices for Upgrading to MongoDB 3.2Webinar: Best Practices for Upgrading to MongoDB 3.2
Webinar: Best Practices for Upgrading to MongoDB 3.2Dana Elisabeth Groce
 
Postgre sql best_practices
Postgre sql best_practicesPostgre sql best_practices
Postgre sql best_practicesJacques Kostic
 
Openstack hk-summit-upgrades-talk
Openstack hk-summit-upgrades-talkOpenstack hk-summit-upgrades-talk
Openstack hk-summit-upgrades-talkBuvanesh Kumar
 
Checklist for Upgrades and Migrations
Checklist for Upgrades and MigrationsChecklist for Upgrades and Migrations
Checklist for Upgrades and MigrationsMarkus Flechtner
 
ProstgreSQLFailoverConfiguration
ProstgreSQLFailoverConfigurationProstgreSQLFailoverConfiguration
ProstgreSQLFailoverConfigurationSuyog Shirgaonkar
 
Running PostgreSQL in a Kubernetes cluster: CloudNativePG
Running PostgreSQL in a Kubernetes cluster: CloudNativePGRunning PostgreSQL in a Kubernetes cluster: CloudNativePG
Running PostgreSQL in a Kubernetes cluster: CloudNativePGNick Ivanov
 
What's coming in Airflow 2.0? - NYC Apache Airflow Meetup
What's coming in Airflow 2.0? - NYC Apache Airflow MeetupWhat's coming in Airflow 2.0? - NYC Apache Airflow Meetup
What's coming in Airflow 2.0? - NYC Apache Airflow MeetupKaxil Naik
 
Best And Worst Practices Deploying IBM Connections
Best And Worst Practices Deploying IBM ConnectionsBest And Worst Practices Deploying IBM Connections
Best And Worst Practices Deploying IBM ConnectionsLetsConnect
 

Similar a Ilya Kosmodemiansky - An ultimate guide to upgrading your PostgreSQL installation PGConf.EU (20)

The Accidental DBA
The Accidental DBAThe Accidental DBA
The Accidental DBA
 
Operating PostgreSQL at Scale with Kubernetes
Operating PostgreSQL at Scale with KubernetesOperating PostgreSQL at Scale with Kubernetes
Operating PostgreSQL at Scale with Kubernetes
 
Rapid Upgrades With Pg_Upgrade, Bruce Momjian
Rapid Upgrades With Pg_Upgrade, Bruce MomjianRapid Upgrades With Pg_Upgrade, Bruce Momjian
Rapid Upgrades With Pg_Upgrade, Bruce Momjian
 
Best Practices: Migrating a Postgres Production Database to the Cloud
Best Practices: Migrating a Postgres Production Database to the CloudBest Practices: Migrating a Postgres Production Database to the Cloud
Best Practices: Migrating a Postgres Production Database to the Cloud
 
Pg upgrade employer
Pg upgrade employerPg upgrade employer
Pg upgrade employer
 
Using PostgreSQL With Docker & Kubernetes - July 2018
Using PostgreSQL With Docker & Kubernetes - July 2018Using PostgreSQL With Docker & Kubernetes - July 2018
Using PostgreSQL With Docker & Kubernetes - July 2018
 
Upgrade to MySQL 5.6 without downtime
Upgrade to MySQL 5.6 without downtimeUpgrade to MySQL 5.6 without downtime
Upgrade to MySQL 5.6 without downtime
 
Database upgradation
Database upgradationDatabase upgradation
Database upgradation
 
What's New in PostgreSQL 9.3
What's New in PostgreSQL 9.3What's New in PostgreSQL 9.3
What's New in PostgreSQL 9.3
 
TechEvent PostgreSQL Best Practices
TechEvent PostgreSQL Best PracticesTechEvent PostgreSQL Best Practices
TechEvent PostgreSQL Best Practices
 
Overview of Postgres Utility Processes
Overview of Postgres Utility ProcessesOverview of Postgres Utility Processes
Overview of Postgres Utility Processes
 
Webinar: Best Practices for Upgrading to MongoDB 3.2
Webinar: Best Practices for Upgrading to MongoDB 3.2Webinar: Best Practices for Upgrading to MongoDB 3.2
Webinar: Best Practices for Upgrading to MongoDB 3.2
 
Postgre sql best_practices
Postgre sql best_practicesPostgre sql best_practices
Postgre sql best_practices
 
Postgre sql best_practices
Postgre sql best_practicesPostgre sql best_practices
Postgre sql best_practices
 
Openstack hk-summit-upgrades-talk
Openstack hk-summit-upgrades-talkOpenstack hk-summit-upgrades-talk
Openstack hk-summit-upgrades-talk
 
Checklist for Upgrades and Migrations
Checklist for Upgrades and MigrationsChecklist for Upgrades and Migrations
Checklist for Upgrades and Migrations
 
ProstgreSQLFailoverConfiguration
ProstgreSQLFailoverConfigurationProstgreSQLFailoverConfiguration
ProstgreSQLFailoverConfiguration
 
Running PostgreSQL in a Kubernetes cluster: CloudNativePG
Running PostgreSQL in a Kubernetes cluster: CloudNativePGRunning PostgreSQL in a Kubernetes cluster: CloudNativePG
Running PostgreSQL in a Kubernetes cluster: CloudNativePG
 
What's coming in Airflow 2.0? - NYC Apache Airflow Meetup
What's coming in Airflow 2.0? - NYC Apache Airflow MeetupWhat's coming in Airflow 2.0? - NYC Apache Airflow Meetup
What's coming in Airflow 2.0? - NYC Apache Airflow Meetup
 
Best And Worst Practices Deploying IBM Connections
Best And Worst Practices Deploying IBM ConnectionsBest And Worst Practices Deploying IBM Connections
Best And Worst Practices Deploying IBM Connections
 

Más de PostgreSQL-Consulting

Linux IO internals for database administrators (SCaLE 2017 and PGDay Nordic 2...
Linux IO internals for database administrators (SCaLE 2017 and PGDay Nordic 2...Linux IO internals for database administrators (SCaLE 2017 and PGDay Nordic 2...
Linux IO internals for database administrators (SCaLE 2017 and PGDay Nordic 2...PostgreSQL-Consulting
 
PostgreSQL worst practices, version FOSDEM PGDay 2017 by Ilya Kosmodemiansky
PostgreSQL worst practices, version FOSDEM PGDay 2017 by Ilya KosmodemianskyPostgreSQL worst practices, version FOSDEM PGDay 2017 by Ilya Kosmodemiansky
PostgreSQL worst practices, version FOSDEM PGDay 2017 by Ilya KosmodemianskyPostgreSQL-Consulting
 
Linux internals for Database administrators at Linux Piter 2016
Linux internals for Database administrators at Linux Piter 2016Linux internals for Database administrators at Linux Piter 2016
Linux internals for Database administrators at Linux Piter 2016PostgreSQL-Consulting
 
10 things, an Oracle DBA should care about when moving to PostgreSQL
10 things, an Oracle DBA should care about when moving to PostgreSQL10 things, an Oracle DBA should care about when moving to PostgreSQL
10 things, an Oracle DBA should care about when moving to PostgreSQLPostgreSQL-Consulting
 
Autovacuum, explained for engineers, new improved version PGConf.eu 2015 Vienna
Autovacuum, explained for engineers, new improved version PGConf.eu 2015 ViennaAutovacuum, explained for engineers, new improved version PGConf.eu 2015 Vienna
Autovacuum, explained for engineers, new improved version PGConf.eu 2015 ViennaPostgreSQL-Consulting
 
Linux tuning to improve PostgreSQL performance
Linux tuning to improve PostgreSQL performanceLinux tuning to improve PostgreSQL performance
Linux tuning to improve PostgreSQL performancePostgreSQL-Consulting
 
PostgreSQL Meetup Berlin at Zalando HQ
PostgreSQL Meetup Berlin at Zalando HQPostgreSQL Meetup Berlin at Zalando HQ
PostgreSQL Meetup Berlin at Zalando HQPostgreSQL-Consulting
 
How does PostgreSQL work with disks: a DBA's checklist in detail. PGConf.US 2015
How does PostgreSQL work with disks: a DBA's checklist in detail. PGConf.US 2015How does PostgreSQL work with disks: a DBA's checklist in detail. PGConf.US 2015
How does PostgreSQL work with disks: a DBA's checklist in detail. PGConf.US 2015PostgreSQL-Consulting
 
Как PostgreSQL работает с диском
Как PostgreSQL работает с дискомКак PostgreSQL работает с диском
Как PostgreSQL работает с дискомPostgreSQL-Consulting
 
Максим Богук. Postgres-XC
Максим Богук. Postgres-XCМаксим Богук. Postgres-XC
Максим Богук. Postgres-XCPostgreSQL-Consulting
 
Илья Космодемьянский. Использование очередей асинхронных сообщений с PostgreSQL
Илья Космодемьянский. Использование очередей асинхронных сообщений с PostgreSQLИлья Космодемьянский. Использование очередей асинхронных сообщений с PostgreSQL
Илья Космодемьянский. Использование очередей асинхронных сообщений с PostgreSQLPostgreSQL-Consulting
 

Más de PostgreSQL-Consulting (14)

Linux IO internals for database administrators (SCaLE 2017 and PGDay Nordic 2...
Linux IO internals for database administrators (SCaLE 2017 and PGDay Nordic 2...Linux IO internals for database administrators (SCaLE 2017 and PGDay Nordic 2...
Linux IO internals for database administrators (SCaLE 2017 and PGDay Nordic 2...
 
PostgreSQL worst practices, version FOSDEM PGDay 2017 by Ilya Kosmodemiansky
PostgreSQL worst practices, version FOSDEM PGDay 2017 by Ilya KosmodemianskyPostgreSQL worst practices, version FOSDEM PGDay 2017 by Ilya Kosmodemiansky
PostgreSQL worst practices, version FOSDEM PGDay 2017 by Ilya Kosmodemiansky
 
Linux internals for Database administrators at Linux Piter 2016
Linux internals for Database administrators at Linux Piter 2016Linux internals for Database administrators at Linux Piter 2016
Linux internals for Database administrators at Linux Piter 2016
 
10 things, an Oracle DBA should care about when moving to PostgreSQL
10 things, an Oracle DBA should care about when moving to PostgreSQL10 things, an Oracle DBA should care about when moving to PostgreSQL
10 things, an Oracle DBA should care about when moving to PostgreSQL
 
Autovacuum, explained for engineers, new improved version PGConf.eu 2015 Vienna
Autovacuum, explained for engineers, new improved version PGConf.eu 2015 ViennaAutovacuum, explained for engineers, new improved version PGConf.eu 2015 Vienna
Autovacuum, explained for engineers, new improved version PGConf.eu 2015 Vienna
 
Linux tuning to improve PostgreSQL performance
Linux tuning to improve PostgreSQL performanceLinux tuning to improve PostgreSQL performance
Linux tuning to improve PostgreSQL performance
 
PostgreSQL Meetup Berlin at Zalando HQ
PostgreSQL Meetup Berlin at Zalando HQPostgreSQL Meetup Berlin at Zalando HQ
PostgreSQL Meetup Berlin at Zalando HQ
 
How does PostgreSQL work with disks: a DBA's checklist in detail. PGConf.US 2015
How does PostgreSQL work with disks: a DBA's checklist in detail. PGConf.US 2015How does PostgreSQL work with disks: a DBA's checklist in detail. PGConf.US 2015
How does PostgreSQL work with disks: a DBA's checklist in detail. PGConf.US 2015
 
Pgconfru 2015 kosmodemiansky
Pgconfru 2015 kosmodemianskyPgconfru 2015 kosmodemiansky
Pgconfru 2015 kosmodemiansky
 
Как PostgreSQL работает с диском
Как PostgreSQL работает с дискомКак PostgreSQL работает с диском
Как PostgreSQL работает с диском
 
Kosmodemiansky wr 2013
Kosmodemiansky wr 2013Kosmodemiansky wr 2013
Kosmodemiansky wr 2013
 
Максим Богук. Postgres-XC
Максим Богук. Postgres-XCМаксим Богук. Postgres-XC
Максим Богук. Postgres-XC
 
Иван Фролков. Tricky SQL
Иван Фролков. Tricky SQLИван Фролков. Tricky SQL
Иван Фролков. Tricky SQL
 
Илья Космодемьянский. Использование очередей асинхронных сообщений с PostgreSQL
Илья Космодемьянский. Использование очередей асинхронных сообщений с PostgreSQLИлья Космодемьянский. Использование очередей асинхронных сообщений с PostgreSQL
Илья Космодемьянский. Использование очередей асинхронных сообщений с PostgreSQL
 

Último

Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Dr.Costas Sachpazis
 
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur High Profile
 
result management system report for college project
result management system report for college projectresult management system report for college project
result management system report for college projectTonystark477637
 
MANUFACTURING PROCESS-II UNIT-1 THEORY OF METAL CUTTING
MANUFACTURING PROCESS-II UNIT-1 THEORY OF METAL CUTTINGMANUFACTURING PROCESS-II UNIT-1 THEORY OF METAL CUTTING
MANUFACTURING PROCESS-II UNIT-1 THEORY OF METAL CUTTINGSIVASHANKAR N
 
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...ranjana rawat
 
BSides Seattle 2024 - Stopping Ethan Hunt From Taking Your Data.pptx
BSides Seattle 2024 - Stopping Ethan Hunt From Taking Your Data.pptxBSides Seattle 2024 - Stopping Ethan Hunt From Taking Your Data.pptx
BSides Seattle 2024 - Stopping Ethan Hunt From Taking Your Data.pptxfenichawla
 
Introduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptxIntroduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptxupamatechverse
 
Booking open Available Pune Call Girls Pargaon 6297143586 Call Hot Indian Gi...
Booking open Available Pune Call Girls Pargaon  6297143586 Call Hot Indian Gi...Booking open Available Pune Call Girls Pargaon  6297143586 Call Hot Indian Gi...
Booking open Available Pune Call Girls Pargaon 6297143586 Call Hot Indian Gi...Call Girls in Nagpur High Profile
 
University management System project report..pdf
University management System project report..pdfUniversity management System project report..pdf
University management System project report..pdfKamal Acharya
 
Coefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptxCoefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptxAsutosh Ranjan
 
UNIT-III FMM. DIMENSIONAL ANALYSIS
UNIT-III FMM.        DIMENSIONAL ANALYSISUNIT-III FMM.        DIMENSIONAL ANALYSIS
UNIT-III FMM. DIMENSIONAL ANALYSISrknatarajan
 
Porous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writingPorous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writingrakeshbaidya232001
 
AKTU Computer Networks notes --- Unit 3.pdf
AKTU Computer Networks notes ---  Unit 3.pdfAKTU Computer Networks notes ---  Unit 3.pdf
AKTU Computer Networks notes --- Unit 3.pdfankushspencer015
 
Introduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptxIntroduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptxupamatechverse
 
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...roncy bisnoi
 
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...ranjana rawat
 
Glass Ceramics: Processing and Properties
Glass Ceramics: Processing and PropertiesGlass Ceramics: Processing and Properties
Glass Ceramics: Processing and PropertiesPrabhanshu Chaturvedi
 
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service Nashik
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service NashikCall Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service Nashik
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service NashikCall Girls in Nagpur High Profile
 
Online banking management system project.pdf
Online banking management system project.pdfOnline banking management system project.pdf
Online banking management system project.pdfKamal Acharya
 
Russian Call Girls in Nagpur Grishma Call 7001035870 Meet With Nagpur Escorts
Russian Call Girls in Nagpur Grishma Call 7001035870 Meet With Nagpur EscortsRussian Call Girls in Nagpur Grishma Call 7001035870 Meet With Nagpur Escorts
Russian Call Girls in Nagpur Grishma Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur High Profile
 

Último (20)

Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
 
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
 
result management system report for college project
result management system report for college projectresult management system report for college project
result management system report for college project
 
MANUFACTURING PROCESS-II UNIT-1 THEORY OF METAL CUTTING
MANUFACTURING PROCESS-II UNIT-1 THEORY OF METAL CUTTINGMANUFACTURING PROCESS-II UNIT-1 THEORY OF METAL CUTTING
MANUFACTURING PROCESS-II UNIT-1 THEORY OF METAL CUTTING
 
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
 
BSides Seattle 2024 - Stopping Ethan Hunt From Taking Your Data.pptx
BSides Seattle 2024 - Stopping Ethan Hunt From Taking Your Data.pptxBSides Seattle 2024 - Stopping Ethan Hunt From Taking Your Data.pptx
BSides Seattle 2024 - Stopping Ethan Hunt From Taking Your Data.pptx
 
Introduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptxIntroduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptx
 
Booking open Available Pune Call Girls Pargaon 6297143586 Call Hot Indian Gi...
Booking open Available Pune Call Girls Pargaon  6297143586 Call Hot Indian Gi...Booking open Available Pune Call Girls Pargaon  6297143586 Call Hot Indian Gi...
Booking open Available Pune Call Girls Pargaon 6297143586 Call Hot Indian Gi...
 
University management System project report..pdf
University management System project report..pdfUniversity management System project report..pdf
University management System project report..pdf
 
Coefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptxCoefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptx
 
UNIT-III FMM. DIMENSIONAL ANALYSIS
UNIT-III FMM.        DIMENSIONAL ANALYSISUNIT-III FMM.        DIMENSIONAL ANALYSIS
UNIT-III FMM. DIMENSIONAL ANALYSIS
 
Porous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writingPorous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writing
 
AKTU Computer Networks notes --- Unit 3.pdf
AKTU Computer Networks notes ---  Unit 3.pdfAKTU Computer Networks notes ---  Unit 3.pdf
AKTU Computer Networks notes --- Unit 3.pdf
 
Introduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptxIntroduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptx
 
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
 
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
 
Glass Ceramics: Processing and Properties
Glass Ceramics: Processing and PropertiesGlass Ceramics: Processing and Properties
Glass Ceramics: Processing and Properties
 
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service Nashik
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service NashikCall Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service Nashik
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service Nashik
 
Online banking management system project.pdf
Online banking management system project.pdfOnline banking management system project.pdf
Online banking management system project.pdf
 
Russian Call Girls in Nagpur Grishma Call 7001035870 Meet With Nagpur Escorts
Russian Call Girls in Nagpur Grishma Call 7001035870 Meet With Nagpur EscortsRussian Call Girls in Nagpur Grishma Call 7001035870 Meet With Nagpur Escorts
Russian Call Girls in Nagpur Grishma Call 7001035870 Meet With Nagpur Escorts
 

Ilya Kosmodemiansky - An ultimate guide to upgrading your PostgreSQL installation PGConf.EU

  • 1. An ultimate guide to upgrading your PostgreSQL installation Ilya Kosmodemiansky ik@dataegret.com
  • 2. 2 Why this talk? Upgrading your PostgreSQL is not a rocket science! • ...but there are lots of small details • Unsuccessful upgrade can ruin your data • Or at least cause an unacceptable downtime • Upgrade requires good knowledge of your system and substantial preparation time dataegret.com
  • 3. 3 Because of that • DBAs do not like upgrades • They are attached to outdated versions • They manage to screw up an upgrade when they finally decide to perform one dataegret.com
  • 4. 4 Why do you need to upgrade? • Bugfixes, security fixes • Many performance improvements and new features over the last years • Upgrading on time makes it easier • Running 7.* in 2017 would make consultants too happy dataegret.com
  • 5. 5 PostgreSQL version numbering <= 9.6.* 9.4.3Major Major Minor dataegret.com
  • 6. 5 PostgreSQL version numbering > 9.6.* 10.2 Major Minor dataegret.com
  • 7. 6 Types of upgrades • Minor New versions’ binaries can run on old version datafiles • Major New versions’ binaries can run on old version datafiles, but require new system tables and internal data format may change • Major with special requirements dataegret.com
  • 8. 7 Before any upgrade • Read carefully version specific release notes • Play with chosen upgrade method in test environment • Align with your application development team • Make a backup and check it by test recovery dataegret.com
  • 9. 8 Minor upgrades are easy • You simply install new binaries and start new database server on the old data directory • There are no new features between minor versions • Still - keep an eye on updating all PostgreSQL-related packages you use dataegret.com
  • 10. 9 Major upgrade prerequisites • Install new versions for all PostgreSQL-related packages • Read carefully all release notes • Know your PostgreSQL installation • Choose the method and carefully read the documentation for this method • Align with your application development team • Do a backup and check it by doing a test recovery dataegret.com
  • 11. 10 Check which PostgreSQL-related packages you use your_server:~$ sudo dpkg -l *postgres* ||/ Name Version +++-=================================================-============================= ii postgresql-9.3 9.3.15-1.pgdg14.04+1 ii postgresql-client-9.3 9.3.15-1.pgdg14.04+1 ii postgresql-client-common 182.pgdg14.04+1 ii postgresql-common 182.pgdg14.04+1 ii postgresql-contrib-9.3 9.3.15-1.pgdg14.04+1 ii postgresql-plperl-9.3 9.3.15-1.pgdg14.04+1 ii postgresql-server-dev-9.3 9.3.15-1.pgdg14.04+1 your_server:~$ sudo dpkg -l *pg* ||/ Name Version +++-=================================================-============================= ii libdbd-pg-perl 2.19.3-2 ii pgbouncer 1.5.4-4 ii pgdg-keyring 2014.1 dataegret.com
  • 12. 11 Major upgrade methods • Good old dump/restore • pg_upgrade • Replication-based methods dataegret.com
  • 13. 12 Major upgrade using pg_dump • Difficult to make without downtime if you have a large, heavyloaded database • Requires additional disk space • Works with any PostgreSQL version since 7.0 • pg_dump -Fc - custom format, -Z - compression • pg_dump -Fd –jobs can be a good option in terms of speed and downtime • But if using -j you can’t do things like that: pg_dumpall -p 5432 | psql -d postgres -p 5433 • If your installation can be upgraded easily by dump/restore, you are lucky! dataegret.com
  • 14. 13 Major upgrade using pg_dump - procedure • Install new binaries • Initialize new cluster. Don’t forget about locale • Change config files appropriately • It can be a good idea to use newer version of pg_dump, but be careful if running on pre-9.2 server • Restore the dump, try to figure out if everything looks good • Switch your application to the new cluster dataegret.com
  • 15. 14 pg_upgrade - outline • How it works? • Procedure Simple case - standalone server How to minimize downtime? Upgrading hot-standby cluster • Details dataegret.com
  • 16. 15 pg_upgrade - How it works? user data pg_clog pg_catalog pg_clog pg_catalog old new user data pg_clog pg_catalog pg_clog pg_catalog freeze user data pg_clog pg_catalog pg_clog pg_catalog pg_clog and pg_control user data pg_clog pg_catalog pg_clog pg_catalog user data dupm/restore of schema and cp or relink of datafiles dataegret.com
  • 17. 15 pg_upgrade - How it works? • Decouple pg_clog (pg_xact) from new cluster • Couple old pg_clog to a new cluster and set xid • Restore schema • Copy or link datafiles from old cluster to a new one dataegret.com
  • 18. 16 pg_upgrade - procedure • Create empty database for new version of PostgreSQL • Stop database with old PostgreSQL version • Start upgrade procedure with pg_upgrade command • Start database that runs on new PostgreSQL version • Start collecting statistics (pg_upgrade does not transfer optimizer statistics) • When statistic collection started, you can open database for your application • Depending on your database, you can achieve 1-10 min downtime target dataegret.com
  • 19. 17 pg_upgrade - minimizing downtime • Use pgbouncer PAUSE/RESUME Issue CHECKPOINT; on old server before you start, to make shutdown process faster • Use -k (–link) to use hard links instead of copy (but carefully!) dataegret.com
  • 20. 18 pg_upgrade - hot-standby replica • Upgrade master as a standalone server • Keep replica intact to failover if something goes wrong • Reinstantiate your replica • Procedure Pause pgbouncer on standby or stop it Clone a replica from upgraded master using pg_basebackup Start replica with new binaries Resume pgbouncer connections or start pgbouncer. dataegret.com
  • 21. 19 pg_upgrade - Details • pg_upgrade does not transfer optimizer statistics • instead, it generates a script ./analyze_new_cluster.sh It basically runs vacuumdb –all –analyze-in-stages In some cases it is better to run vacuumdb –all –analyze-only Since 9.5 you can vacuumdb run in parallel (-j) We usually use vacuumdb –all –analyze-in-stages and open database for application after medium optimizer statistics (10 targets) are generated dataegret.com
  • 22. 20 pg_upgrade - Details • Documentation suggests to use rsync to reinstantiate standby • rsync –archive –delete –hard-links –size-only old_pgdata new_pgdata remote_dir • rsync allows you to save a lot of network traffic in that case • ...and provides lots of opportunities to shoot yourself in the foot dataegret.com
  • 23. 21 pg_upgrade - Details • Debian/Ubuntu follow their own way • Wrappers, like pg_ctlcluster are designed to manipulate PostgreSQL cluster in a Debian way • pg_upgradecluster -v 9.5 9.3 main1 -m upgrade -k supposed to be a make-me-happy button for a DBA • It even takes care of converting postgresql.conf parameters for you • But I strongly recommend to do this manually dataegret.com
  • 24. 22 pg_upgrade - Details • Extensions can surprise you • pg_upgrade keeps old versions of extensions • We advise to cycle through all extensions and perform alter extension EXTENSION_NAME update; • Some extensions need special care: for example PostGIS should be updated before an upgrade dataegret.com
  • 25. 23 Using replication to upgrade PostgreSQL • Streaming replication doesn’t work between versions • But some replication methods can do that Logical replication Slony-I Londiste • Procedure Setup new database cluster Setup replication from old one to a new one Perform failover dataegret.com
  • 26. 24 Logical replication • New promising method • Allows you to upgrade from 9.4 to a newer version • It can be tricky: Check documentation carefully If you have a complex schema, you may need some wrapper, like https://github.com/rtshome/pgrepup Check what you replicate using pglogical.replication_set Don’t forget about sequences dataegret.com
  • 27. 25 Slony-I • Old and bulletproof • Can be used with old versions • Failover can be done really fast • Drawbacks Trigger based - can cause heavy load on old cluster Extra disk space is needed dataegret.com
  • 28. 26 Londiste • I’am not a big fan of Londiste • Same drawbacks as with Slony, but without Slony’s robustness • Lots of bugs (compared to Slony) • Tool was designed for a different purpose dataegret.com
  • 29. 27 Conclusion Method downtime extra disk space complexity riskiness dump/restore high double low low pg_upgrade (copy) high double high low pg_upgrade (link) low low high very high Logical replication low double high low Slony-I low double medium low Londiste low double medium low dataegret.com
  • 30. 28 Reading list • http://momjian.us/main/writings/pgsql/pg_upgrade.pdf • https://blog.2ndquadrant.com/untangling-the-postgresql-upgrade/ • http://blog.endpoint.com/2016/12/postgres-statistics-and-pain-of- analyze.html • https://www.depesz.com/2016/11/08/major-version-upgrading-with- minimal-downtime/ dataegret.com