HiveBrain v1.2.0
Get Started
← Back to all entries
snippetsqlMinor

How to switch master server and warm standby (with streaming replication) in PostgreSQL?

Submitted by: @import:stackexchange-dba··
0
Viewed 0 times
postgresqlwithandwarmreplicationstandbymasterstreaminghowserver

Problem

I would like to know what is the way to switch the role of 2 servers when using warm standby?

I have 2 servers : S_1 and S_2, and at a time T, S_1 is the master server and S_2 is a warm standby with streaming replication.

At a later moment, I would like to switch S_2 become the master server and S_1 the warm standby.

What do I have to do to switch roles ?

Solution

Keep in mind that currently you cannot demote a master to a standby. Doing so will corrupt your database!

The basic documentation for doing this is at: http://www.postgresql.org/docs/9.1/static/warm-standby-failover.html

However the basic thing is you can't switch these other than:

-
Turn off primary

-
Promote secondary

-
Rebuild former primary as new secondary off the new primary.

Context

StackExchange Database Administrators Q#29488, answer score: 7

Revisions (0)

No revisions yet.