Platinum Partner
architects,devops,tips and tricks,tools & methods,rsync

How Do You Use Rsync for High Availability Environments?

What if...

  • What if I have a large number of web servers and I need to deploy the same code on all of them?
  • What if  I would like to enable high availability and redundancy for static user content such as images?
  • What if I want to to backup files to a central storage?

A Swiss knife for static content replication
rsync was considered for a long time as the best solution for static content and code replication  in environments that consist of large number of servers.
rsync has a simple protocol that replicates a directory (one or more) on a single server to other servers. This can be achieved in two different methods (like SCP that it is based on):

  • Push from the master to the slave: rsync [OPTION] … SRC[SRC] … [USER@]
    HOST:DEST
    
    
  • Pull from the server by the slave: rsync [OPTION] …[USER@]HOST:SRC [DEST]

Can I perform a change on the destination directory?
Please note that the rsync protocol analyzes differences between two directories, and therefore probably will not match cases when you want to change the content of the destination directory.
How should I authenticate?
Use one of the two options:

  1. Static user/pwd using sshpass for non interactive SSH based authentication.
  2. PKI authentication using on-the-fly keys generation or pre-generated keys
Master-Master replication
Like in MySQL, Master-Master replication can be achieved by a dual Master-Slave connections setup. Please consider to enable only one of these connections. Then, during a failover, disable the replication. Last, when you bring the master server back enable the other replication.

Note: you may consider using OpenStack Storage for these purposes as well, as it provides an out the box solution for high availability and redundancy that easily supports multi master out of the box

Published at DZone with permission of {{ articles[0].authors[0].realName }}, DZone MVB. (source)

Opinions expressed by DZone contributors are their own.

{{ tag }}, {{tag}},

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}
{{ parent.authors[0].realName || parent.author}}

{{ parent.authors[0].tagline || parent.tagline }}

{{ parent.views }} ViewsClicks
Tweet

{{parent.nComments}}