How to replicate files between two separate apache machines in bidirectional

load balancingreplicationsynchronization

How to replicate /var/www/html/ between two separate machines which has separate hard disk storage running Apache web servers. I was planning to setup load balancing between these two Apache servers and configured Nginx as front end for those two Apache servers, the files should sync from server 1 to server 2 and vice-versa

Best Answer

Multiple options / solutions come to my mind:

  • NFS:

    Network File System (NFS) is a distributed file system protocol originally developed by Sun Microsystems in 1984,[1] allowing a user on a client computer to access files over a computer network much like local storage is accessed.

  • DRBD aka Distributed Replicated Block Device:

    DRBD® software is a distributed replicated storage system for the Linux platform. It is implemented as several userspace management applications and some shell scripts and is normally used on high availability (HA) computer clusters.

  • csync2:

    Csync2 is a cluster synchronization tool. It can be used to keep files on multiple hosts in a cluster in sync. Csync2 can handle complex setups with much more than just 2 hosts, handle file deletions and can detect conflicts.

There are other options available as well, just take this as a starting point.