Postgresql – master to multi-slave replication

postgresqlreplication

I am looking at replication of the master database (PostgreSQL) and this is the configuration I have to setup

master -- hot-standby (hs)
|
|
 --- read only slave (r1)
|
|
 --- read only slave (r2)

My requirement is that the either of master or standby should be available all the time and r1-r2 should be available most of the time.

I have setup streaming replication with recovery on hs and without recovery on r1,r2. All these 3 get the WAL logs from master.

My question is, when the master goes down and we trigger the failover on standby, what should I do to r1 and r2 ? re-parenting them to standby would mean a full base-backup and when eventually master comes up, i may need to re-parent again.

This is my first attempt at replication-setup. So if there is anything obvious I am missing or doing wrong, please let me know. If there are tools/solutions which cater to this sort of a thing, I would be very glad to know and learn.

Best Answer

There are some tricks to make r1/r2 follow new parent, but generally I see them as tricks, which means I wouldn't really depend on them in production environment.

You might want to check this blogpost: http://www.pateldenish.com/2010/11/possibility-of-graceful-switchover.html