When you have multi-server architecture then you will need to make sure that both the servers are in synchronization. You will find lots of tools which help you to keep your servers in sync. For this kind of work, Lsyncd is the best tool to keep servers in sync.
What is Lsyncd?
Lsyncd is a tool which helps you to maintain the code synchronization over multiserver architecture. It means you have two servers and code resides under the "/data/docroot" directory. When some changes are done on any of the server lsyncd will help to immediately copy or synced the changes on another server.
This article will help you in the configuration of lsyncd which will maintain the synchronization task between the two servers.
In this guide, we will configure the lsyncd on Debian server but it will work a similar way for other a Linux distros as well.
Before using lsyncd on servers make sure both the servers are accessible or able to ssh each other with their internal IP addresses. Also, add ssh key based authentication on both the server so each server will access each other without password.
If you do not know how to configure ssh key based login then follow my previous guide on SSH.
Once done with the above mentioned recommended settings follow below steps to configure lsyncd service.
Step 1: Install Lsyncd
Use below commands to install lsyncd on server or system. First, run apt-get update to update the repository on the server. For lsyncd, you do not need to add any extra repository because lsyncd come will default repository.