Replicate to more than one replica?

Bron Gondwana brong at fastmail.fm
Tue Jun 6 19:00:57 EDT 2006


On Wed, 07 Jun 2006 09:49:13 +1200, "Roland Pope" <rpope at jadeworld.com> said:
> David Korpiewski wrote:
> >
> You cannot replicate from one master to more than one replica.
> However, you should be able to replicate from master to replica, then 
> from replica to another replica.
> 
> Ie. Master->Replica1->Replica2
> 
> I realise this will introduce a small delay in the replication from 
> Master to Replica2, and will rely on replica1 being available, but it 
> should still be a valid option.

Unless sync_server is logging all its actions to sync_client then this is
a bit pointless, Replica2 will never have anything automatically sent to
it.  A quick grep of my 2.3.6 source directory suggests that it doesn't.

There's no technical reason for sync_client not to be extended to support
syncing to two different backend servers though (other than it being a
mess of global communications variables, but I was already thinking about
writing a patch to fix that).

You would want to make sure that a failure on either replica didn't stop
the other one running, and possibly do something like copy the log file
twice, once for each backend - then spawn separate processes managing the
actual sync...

My problem at the moment is that if you can't contact the replica then the
master doesn't even [expletive] start, which is just insane.  I've attached
a patch that fixes that in a pretty hacky way - but still has global
connection objects.  I don't think it's worthy of inclusion upstream until
I make it more flexible.

This patch also includes a command line option '-o' to sync_client which
allows you to run it from the command line even if the replica isn't running
and it will only attempt to connect once rather than spend 1000 seconds
backing off trying to get a connection.  I'm using that option in the master
shutdown script - after closing down the server I run:

if [ -f /var/cyrus/$HOST/sync/log ]; then
  sudo -u cyrus /usr/cyrus/bin/sync_client -C /etc/imapd-$HOST.conf \
       -o -r -f /var/cyrus/$HOST/sync/log
fi

(equivalent to the more simplistic: sync_client -o -r -f /var/imap/sync/log)

and depending on the exit code of sync_client above I know if I can consider
the two copies "identical" when starting up again or if I need to force the
next master start to be on the same host.  This assumes replication is 100%
reliable, which isn't really true, sync_client is still bailing out far too
often.  It's a start though.

The cyrus init scripts also start up IP addresses (using Heartbeat's IPAddr2)
which cyrus binds to.  This allows us to run multiple master servers on the
same host if necessary, just by switching over a replica, and also to keep
contacting a particular named server via its IP address regardless of which
replica host is actually running the master at that time.

(NOTE: none of this is actually fully working yet, but it's starting to look
pretty good.  I got it up and running with heartbeat management yesterday on
my test bed!)

Bron.
-- 
  Bron Gondwana
  brong at fastmail.fm

-------------- next part --------------
A non-text attachment was scrubbed...
Name: cyrus-client-connect-2.3.6.diff
Type: text/x-patch
Size: 43578 bytes
Desc: not available
Url : http://lists.andrew.cmu.edu/pipermail/info-cyrus/attachments/20060607/0dbf4072/cyrus-client-connect-2.3.6-0001.bin


More information about the Info-cyrus mailing list