Sign up ×
Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. It's 100% free, no registration required.

I need a reliable SQL DB for our application and have been looking at Postgresql's streaming replication support. It seems that it's not hard to setup master/slave replication and you can use the slave as a hot standby for read-only queries. All good so far. However how do I automatically promote a slave to master when the master fails (or the slave thinks the master has failed)? I know I can write a file on the slave to make it become master but am looking for scripts et al to do that (and make sure the master stays down etc.).

Anyone know of a nice tutorial on how to do this on Ubuntu 12.04? Hosted at Hetzner (for bonus points)? Chef recipes or something?

share|improve this question

migrated from Jun 26 '12 at 1:00

This question came from our site for professional and enthusiast programmers.

I should mention that we have quite a lot of data (500G+) and do several hundred writes/second so using a cloud DB service would be likely be very expensive – David Tinker Jun 25 '12 at 17:33
Probably a better fit on dba.SE. – Erwin Brandstetter Jun 25 '12 at 17:50
I just had a look there and didn't see any solution other than broad outlines. Not enough people know about the other stackexchange sites. – David Tinker Jun 25 '12 at 19:04
But some of the people who might best be able to provide an answer do. – Erwin Brandstetter Jun 25 '12 at 21:23
it's not easy to the task by script. – francs Jun 26 '12 at 6:05

2 Answers 2

Have a look at repmgr. It's a free software product that is meant to manage failovers and switchovers with PostgreSQL built-in replication.

share|improve this answer

It's not easy to do the task by script recently. Generally speaking, we shoud do the task by hand. When we need switch role between primary node and standby node, first, it's easy activate the standby node to primary node (just create a trigger file in standby node). But it's not easy to swtich the primary node to standby node because it needs complex steps.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.