Skip site navigation (1) Skip section navigation (2)

Re: Switchover of Master and Slave roles

From: Jerry Sievers <gsievers19(at)comcast(dot)net>
To: Simon Riggs <simon(at)2ndQuadrant(dot)com>
Cc: Ray Stell <stellr(at)cns(dot)vt(dot)edu>, A J <s5aly(at)yahoo(dot)com>, Kevin Grittner <Kevin(dot)Grittner(at)wicourts(dot)gov>, pgsql-admin <pgsql-admin(at)postgresql(dot)org>
Subject: Re: Switchover of Master and Slave roles
Date: 2011-06-08 00:53:45
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-admin
Simon Riggs <simon(at)2ndQuadrant(dot)com> writes:

> On Tue, Jun 7, 2011 at 8:41 PM, Ray Stell <stellr(at)cns(dot)vt(dot)edu> wrote:
>> On Tue, Jun 07, 2011 at 11:59:07AM -0700, A J wrote:
>>> We then rely on filesystem tools (or other third party tools) to get the
>>> original master in sync with the new master efficiently and then make it join as
>>> slave.
>> the doc would not be corrupted by an additional few words that stated as such:
>> "To return to normal operation, a standby server must be recreated using
>> external tools such as rsync, either on the former primary system when
>> it comes up, or on a third, possibly new, system."
> You need repmgr:

Well, I am not sure on the 9.x versions but, we used to do reversible
master/standby with log shipping on the 8.x versions quite routinely,
sometimes reshaping clusters of multiple standbys., designating a new
master, restarting the old master in recovery mode and repointing the
remaining standbys..

The procedure was similar to...

apps down and locked out
pg_rotate_xlog() on master
verify final log received on standbys and consumed
bring up new master
kill immediate on old master and remaining standbys
configure old master as standby w/recovery.conf and point to new xlog
repoint other standbys to new repository and restart

There was no need to reinitialize from scratch or rsync the old master
or other standbys.

Somewhere between 8.2 and 8.4 there was a change that would require
you to increment the recovery target timeline during this operation.
It took me a bit of head scratching to get it right.

This capability was apparently little known and used, perhaps due to
uncertainty that it was viable, given the undocumented nature of

Disclaimer: I do not know if this still works on 9.x using either log
shipping or streaming replication.

I covered this strategy briefly during my talk at the 2010 Pg-East
conference in Philly.


> -- 
>  Simon Riggs         
>  PostgreSQL Development, 24x7 Support, Training & Services
> -- 
> Sent via pgsql-admin mailing list (pgsql-admin(at)postgresql(dot)org)
> To make changes to your subscription:

Jerry Sievers
Postgres DBA/Development Consulting
e: gsievers19(at)comcast(dot)net
p: 305.321.1144

In response to

pgsql-admin by date

Next:From: Fujii MasaoDate: 2011-06-08 01:51:25
Subject: Re: Switchover of Master and Slave roles
Previous:From: Simon RiggsDate: 2011-06-07 22:07:10
Subject: Re: Sync replication waits for only 1 slave

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group