5-04 2,369 views
官方文档:
https://axkibe.github.io/lsyncd/download/
1.安装
$ yum install lsyncd
$ yum install rsync
$ yum install libtermcap-devel ncurses-devel libevent-devel readline-devel
实现2个文件夹之间实时同步
2.参数配置
参考:https://www.cnblogs.com/jiangzhaowei/p/8298416.html
#做实施同步的时候,主机和备机之间必须已经做好了ssh免密登录
$ vim /etc/lsyncd.conf
settings {
logfile = "/var/log/lsyncd/lsyncd.log",
statusFile = "/var/log/lsyncd/lsyncd.status"
}
sync {
default.rsyncssh,
source = "/aaa/aaa/aaa", --源目录
host = "xx.xx.xx.xx", --目的主机
targetdir = "/bbb/bbb/bbb", --远程目录
delete = true,
delay = 1,
rsync = {
binary = "/usr/bin/rsync",
archive = true, --归档
compress = true, --压缩
verbose = true,
owner = true, --属主
perms = true, --权限
_extra = {"--bwlimit=2000"},//限制文件同步速度,2mb/s
},
ssh = {
port = 22
}
}
#重启服务
$ systemctl restart lsyncd
#开机启动
$ systemctl enalbe lsyncd
#查看同步状态
$ systemctl status lsyncd