1.官方地址
[https://github.com/axkibe/lsyncd](https://github.com/axkibe/lsyncd)
2.lsyncd介绍
[https://www.cnblogs.com/zxci/p/6243574.html](https://www.cnblogs.com/zxci/p/6243574.html)
lsyncd简介
Lysncd 实际上是lua语言封装了 inotify 和 rsync 工具,采用了 Linux 内核(2.6.13 及以后)里的 inotify 触发机制,然后通过rsync去差异同步,达到实时的效果。我认为它最令人称道的特性是,完美解决了 `inotify + rsync`海量文件同步带来的文件频繁发送文件列表的问题 —— 通过时间延迟或累计触发事件次数实现。另外,它的配置方式很简单,lua本身就是一种配置语言,可读性非常强。lsyncd也有多种工作模式可以选择,本地目录cp,本地目录rsync,远程目录rsyncssh。 实现简单高效的本地目录同步备份(网络存储挂载也当作本地目录),一个命令搞定。
3.安装
[root@nfs01 ~]# yum install lsyncd -y
4.创建配置文件
[root@nfs01 ~]# cat /etc/lsyncd.conf settings { logfile = "/var/log/lsyncd/lsyncd.log", statusFile = "/var/log/lsyncd/lsyncd.status", inotifyMode = "CloseWrite", maxProcesses = 8, } sync { default.rsync, source = "/data", target = "rsync_backup@172.16.1.41::data", delete = true, exclude = { ".*" }, delay = 1, rsync = { binary = "/usr/bin/rsync", archive = true, compress = true, verbose = true, password_file = "/etc/rsync.passwd", _extra = {"--bwlimit=200"} } } sync { default.rsync, source = "/backup", target = "rsync_backup@172.16.1.41::backup", delete = true, exclude = { ".*" }, delay = 1, rsync = { binary = "/usr/bin/rsync", archive = true, compress = true, verbose = true, password_file = "/etc/rsync.passwd", _extra = {"--bwlimit=200"} } }
5.配置文件解释
https://www.cnblogs.com/zxci/p/6243574.html
6.启动命令
[root@nfs01 ~]# systemctl start lsyncd
来源:https://www.cnblogs.com/skyy/p/12331642.html