Lsyncd实现实时同步

一、下载

Lsyncd官网是:http://axkibe.github.io/lsyncd/

rpm方式:https://mirrors.aliyun.com/epel/

二、安装

cmake .

make

make install

或 rpm -ivh lsyncd

三,配置文件

settings {
logfile = "/var/log/lsyncd/lsyncd.log",
statusFile = "/var/log/lsyncd/lsyncd.status",
inotifyMode = "CloseWrite",
maxProcesses = 8
}

sync {
default.rsync,
source = "/home/test",
target = "backup@10.168.3.117::test",
delete="running",
exclude = { ".swp", ".tmp" },
delay = 20,
init = false,
rsync = {
binary = "/usr/bin/rsync",
archive = true,
compress = true,
verbose = true,
password_file = "/etc/rsync_client.pass",
_extra = {"--bwlimit=800"}
}
}

四、启动

systemctl enable lsyncd

systemctl start lsyncd