How to Install Lsyncd on CentOS 7 for Real-Time File Synchronization
Lsyncd combines inotify and rsync. It uses the inotify or fsevents interface to monitor local directory tree events. It aggregates and combines events for a few seconds, then spawns one or more processes to synchronize the changes.

Requirements
There are two CentOS 7 servers. Server A (192.168.1.100) needs to have its files synchronized in real-time to Server B (192.168.1.200).
Install rsync
Lsyncd is based on rsync and requires rsync version 3.1 or higher. You can check the current version by running rsync -v. If the version does not meet the requirement, please refer to CentOS Upgrade rsync Version. rsync must be installed on both Server A and Server B.
Set Up Key-Based Login
To synchronize data from A to B, Server A must have passwordless login permissions to Server B. This can be achieved by setting up key-based login. Execute the following commands on Server A:
# Generate key file
ssh-keygen -t rsa
# Copy public key to B
ssh-copy-id username@remote-server
# Test connection
ssh username@remote-server
username is the username on Server B, and remote-server is the IP address of Server B. If the server does not use port 22 for SSH, you need to specify the port number using the -p parameter. For more details, refer to SSH Passwordless Login: Just Two Simple Steps (Linux).
Install EPEL Repository
The built-in repositories for CentOS 7 do not include Lsyncd. While you can compile Lsyncd manually, the easier method is to install the EPEL repository first, which allows direct installation via yum. Execute the following command on Server A:
yum -y install epel-release
Install and Configure Lsyncd
If the EPEL repository is already installed, you can install Lsyncd directly using the following command on Server A:
# Install lsyncd
yum -y install lsyncd
# Check lsyncd version
lsyncd --version
After installation, the configuration file is located at /etc/lsyncd.conf. You will see content similar to the following, where -- denotes a comment:
----
-- User configuration file for lsyncd.
--
-- Simple example for default rsync, but executing moves through on the target.
--
-- For more examples, see /usr/share/doc/lsyncd*/examples/
--
sync{default.rsyncssh, source="/var/www/html", host="localhost", targetdir="/tmp/htmlcopy/"}
Edit the configuration file using vi /etc/lsyncd.conf. Comment out or delete the default last line, then add your own configuration:
settings {
logfile = "/tmp/lsyncd.log",
statusFile = "/tmp/lsyncd.status",
insist = true,
statusInterval = 10
}
sync {
default.rsyncssh,
source="/home/test1",
host="192.168.1.200",
targetdir="/home/test2",
rsync = {
archive = true,
compress = false,
whole_file = false
},
ssh = {
port = 22
}
}
Run the command lsyncd -nodaemon /etc/lsyncd.conf to check for errors. If there are errors, check and modify them according to the error messages. If there are no errors, exit and start Lsyncd using:
systemctl start lsyncd
Parameter Explanation
settings (Global Configuration):
logfile: Path to the log file.statusFile: Path to the status file.insist: Continue running even if there are failed targets.statusInterval: How many seconds to write to the file (default is 10s).
sync (Synchronization Configuration):
source: Local file directory.host: Remote server address.targetdir: Remote target directory.port: SSH port number of the current host (default is 22).
Related Commands
# Start
systemctl start lsyncd
# Stop
systemctl stop lsyncd
# Restart
systemctl restart lsyncd
# Enable auto-start on boot
systemctl enable lsyncd
Summary
The above method was tested on CentOS 7. For CentOS 6, some parts may differ slightly, but the process and steps remain the same.
Lsyncd is an open-source synchronization software based on inotify + rsync, supporting incremental synchronization. Compared to Resilio Sync, its advantages are higher security, lower resource usage, and more convenient custom configuration via multiple parameters. Its disadvantage is that configuration is slightly more complex than Resilio Sync, and in scenarios involving multiple servers, the speed may not match Resilio Sync, as Resilio Sync utilizes P2P sharing.
Lsyncd Official Documentation: https://axkibe.github.io/lsyncd/ Project Address: https://github.com/axkibe/lsyncd