How to set up synchronous streaming replication in postgres? How to set up synchronous streaming replication in postgres? database database

How to set up synchronous streaming replication in postgres?


I was the first person to put Streaming Replication (AKA "Binary Replication") into production when 9.0 came out two years ago, but skipped over 9.1 because Postgres' replication feature was in a state of flux. Now, as of about the second week of September or thereabouts, 9.2 is out - you WANT to know about it!

With 9.2, replication has been simplified and GREATLY improved!

Now you can have replication cascade! Previously, you had to have the master serve all the slaves directly. Now you can off-load the master by streaming to just ONE slave, and then have that slave stream to as many as you like! This lets you set up your first-level slave as a potential hot-stand-by system that will take over in the event your master fails.

The whole strategy for configuring this has been revamped and I found your question because I myself was looking for a quick-setup-guide type of thing because I already know all the basics. However, you can get started with the new 9.2 stuff here:

Postgres 9.2 High Availability, Load Balancing, and Replication

Meanwhile, at least one vendor has come out with something to help mere mortals make good use of this: Science Tools announced "Dual Mode" has been added to their PolyglotSQL product. PolyglotSQL lets an application operate against most any SQL database and ignore dialect differences. Similarly, the "dual mode" feature lets you have one read-only connection and another connection for writes, without having to re-write your application (!!), so you can take advantage of the Postgres Synchronous Replication, offloading the master of all writes, and putting that load on whatever readers you have configured.

I highly recommend you move to Postgres v 9.2.


Too late to answer but Here is a great video tutorial which covers step step process to do stream replication for postgresql. This was really helpful.


I don't see anything about synchronous_standby_names - you need to tell it which servers it the master will wait on.

http://www.postgresql.org/docs/9.1/static/warm-standby.html#SYNCHRONOUS-REPLICATION

http://www.postgresql.org/docs/9.1/static/runtime-config-replication.html#GUC-SYNCHRONOUS-STANDBY-NAMES

Oh - don't forget to tweak your wal_level setting if you want to run queries on the slave server.