Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

By large file tree I mean about 200k files, and growing all the time. A relatively small number of files are being changed in any given hour though.

By bidirectional I mean that changes may occur on either server and need to be pushed to the other, so rsync doesn't seem appropriate.

By distant I mean that the servers are both in data centers, but geographically remote from each other. Currently there are only 2 servers, but that may expand over time.

By real-time, it's ok for there to be a little latency between syncing, but running a cron every 1-2 minutes doesn't seem right, since a very small fraction of files may change in any given hour, let alone minute.

EDIT: This is running on VPS's so I might be limited on the kinds of kernel-level stuff I can do. Also, the VPS's are not resource-rich, so I'd shy away from solutions that require lots of ram (like Gluster?).

What's the best / most "accepted" approach to get this done? This seems like it would be a common need, but I haven't been able to find a generally accepted approach yet, which was surprising. (I'm seeking the safety of the masses. :)

I've come across lsyncd to trigger a sync at the filesystem change level. That seems clever though not super common, and I'm a bit confused by the various lsyncd approaches. There's just using lsyncd with rsync, but it seems this could be fragile for bidirectionality since rsync doesn't have a notion of memory (eg- to know whether a deleted file on A should be deleted on B or whether it's a new file on B that should be copied to A). lipsync appears to be just a lsyncd+rsync implementation, right?

Then there's using lsyncd with csync2, like this: http://www.axivo.com/community/threads/lightning-fast-synchronization-with-csync2-and-lsyncd.121/ ... I'm leaning towards this approach, but csync2 is a little quirky, though I did do a successful test of it. I'm mostly concerned that I haven't been able to find a lot of community confirmation of this method.

People on here seem to like Unison a lot, but it seems that it is no longer under active development and it's not clear that it has an automatic trigger like lsyncd.

I've seen Gluster mentioned, but maybe overkill for what I need?

UPDATE: fyi- I ended up going with the original solution I mentioned: lsyncd+csync2. It seems to work quite well, and I like the architectural approach of having the servers be very loosely joined, so that each server can operate indefinitely on its own regardless of the link quality between them.

share|improve this question
    
What kind of changes do you need to handle? E.G. creation, deletion, modification. –  sciurus Sep 16 '11 at 22:22
    
Also, do you expect conflicts? Could the same file be modified on both servers? –  sciurus Sep 16 '11 at 22:24
    
All changes: creation, deletion, modification. There is a potential for conflicts, but they should be rare. I wouldn't mind if I simply receive an alert on a conflict that I then have to resolve manually. –  dlo Sep 17 '11 at 12:30

6 Answers 6

up vote 5 down vote accepted
+50

DRBD in Dual-primary mode with a Proxy is an option.

share|improve this answer
    
The Proxy appears to be neither open source nor free, right? I'm not sure I understand the consequence of not having a Proxy in async mode: during an extended downtime, if there's no Proxy, the [small?] output buffer could fill up and we would lose the sync? Is it hard to recover from that? –  dlo Sep 17 '11 at 12:21
    
See my answer above. I don`t think the proxy is the thing you need. Even during a small downtime the drbd-meta-device will mark "dirty" blocks and will transfer them after the connection is up again. I think the main difference between proxy and async-mode is that async-mode uses a maximum buffer of some MBs. After that it syncs up befor filling the buffer again. The proxy propably allows for a bigger buffer (needed if you have big latency or can write much faster locally than remote). –  Nils Sep 22 '11 at 20:37

Implementing a distributed filesystem is probably better than hacking this together with tools and scripts, especially if the cluster of servers will grow. You'll also be able to handle a downed node better.

I don't think Gluster (or AFS) is overkill at all.

share|improve this answer
    
Gluster requires 1GB ram? gluster.com/community/documentation/index.php/… ... I'm also on a VPS, so I'm not sure about making kernel level changes that AFS might require. But I'm starting to see that a proper distributed fs is the better path. –  dlo Sep 17 '11 at 12:23
    
Yeah, sorry I didn't catch earlier that you were using VPS hosts. Gluster memory footprints, both server and client, are not small and they can grow substantially. DRBD sounds more appropriate. –  user94876 Sep 17 '11 at 20:17
    
AFS is the way to go. –  Anthony Giorgio Sep 23 '11 at 13:34

In your case I would recommend a combination of DRBD in dual-primary-mode and gfs or ocfs.

The drawback of DRBD in dual-primary is that it will be running in syncronous mode. But write-speed does not seem to be important here right?

An alternative to DRBD might be a Soft-Raid1 using many (2+) iSCSI-Targets - but I would prefer DRBD with two nodes.

share|improve this answer
1  
Synchronous mode would be bad--I don't need it, and I wouldn't want to undermine performance since the servers are connected over a WAN across continents. But can't you have dual-primary in async mode? –  dlo Sep 17 '11 at 12:28
    
I am currently using DRBD 8.3.5 - there you have to be in sync-mode ("C") to get into dual primary mode. I have no personal experience with DRBD proxy but it seems to be similar to Veritas Volume Replicator - but this is propably not suited since you want write-access on both sides. Sync mode on block-level might not be as bad as you think - perhaps gfs and/or ocfs can buffer writes. –  Nils Sep 17 '11 at 20:25
    
I just checked a german article comparing GFS2 and OCFS2. From that at least OCFS2 seems to support buffered file-system-access. GFS2 is recommended in that article since it is older. See RedHat documentation on GFS2 for details about GFS2 - it uses buffering, too - but you should use different dirs for concurrent writes to get the best performance. –  Nils Sep 17 '11 at 20:36

Rather than syncing, why not share the same filesystem over NFS?

share|improve this answer
2  
NFS is awful, just awful. Anything would be better than NFS –  AliGibbs Sep 14 '11 at 14:31
1  
One of the main points of the multi-server setup is failover/redundancy. So one server must be able to continue without the other. –  dlo Sep 14 '11 at 15:01
    
You should have mentioned that in your question then - no need to vote down a perfectly reasonable answer! –  Bart B Sep 14 '11 at 16:20
    
fyi I didn't downvote it--somebody else did. But yes, I should have mentioned that to begin with. –  dlo Sep 14 '11 at 16:41
    
@Bart: Well - he did mention that there is concurrent access on two distant sites. So even if you put up HA-NFS that would be a bad solution, since one side would suffer from latency during NFS-access. And I did not downvote either. But I`ve been NFS admin long enough to support AliGibbs. :-/ –  Nils Sep 20 '11 at 19:28

As demonstrated above, many solutions are available, each with its advantages and drawbacks.

I think I would consider placing the whole tree under version control (Subversion, for instance) and periodically checking in/updating from both servers in cron jobs.

share|improve this answer

Having just ended somewhat of a quest regarding the same thing, I'm going with gluster. However, I haven't done or found any performance tests.

share|improve this answer

Your Answer

 
discard

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.