Postgresql – Postgres database migration “zero” downtime

postgresql

I have a setup with a JBoss EAP server, postgres 9.1 database.
I will soon update so I have two JBoss servers in a cluster. This is mostly to avoid downtime when doing application deployments.

With the database as a single point of failure, how can I get close to zero downtime when having database migrations.

Best Answer

how can I get close to zero downtime when having database migrations.

Set up a streaming replica pair, with a master and a replica. Use WAL archiving in addition to streaming replication to deal with connectivity drops. Make sure your application is easily reconfigured to switch to a different server for if you need to fail over; if it's not easy to reconfigure, run a local PgBouncer on each node so you can switch it to connect to a different PostgreSQL without needing to mess with the rest of the server config.

A tool like repmgr makes this considerably simpler.

To learn more, read the manual.