环境 rhel6.5 64位
wget https://github.com/axkibe/lsyncd/archive/release-2.2.2.tar.gz
2.3版本编译报错
依赖
lua5.14
lua-devel-5.14
cmake version 2.8.12.2
编译安装
tar xvf lsyncd-release-2.2.2.tar.gz
cd lsyncd-release-2.2.2
cmake -DCMAKE_INSTALL_PREFIX=/data/lsync2.2.2
make
make install
lsyncd主配置文件
settings {
nodaemon = false,
logfile = "/var/log/lsyncd.log",
statusFile = "/var/log/lsyncd.status",
inotifyMode = "CloseWrite",
maxProcesses = 8
}
-- 可以有多个sync,各自的source,各自的target,各自的模式,互不影响。
sync {
default.rsyncssh,
source = "/home/wwwroot/web1/",
host = "111.222.333.444",
targetdir = "/home/wwwroot/web1/",
-- 忽略文件路径规则,可用table也可用外部配置文件
-- excludeFrom = "/etc/lsyncd_exclude.lst",
exclude = {
".svn",
"Runtime/**",
"Uploads/**",
},
-- maxDelays = 5,
delay = 0,
-- init = false,
rsync = {
binary = "/usr/bin/rsync",
archive = true,
compress = true,
verbose = true,
_extra = {"--bwlimit=2000"},
},
}
忽略规则
需要忽略同步的文件或文件夹,excludeFrom 选项才配置该文件,exclude 类型的配置不用该配置文件。假设配置文件放在/etc/lsyncd_exclude.lst。
.svn
Runtime/**
Uploads/**
免密登录
为避免每次都需要手动输入密码,可设置为 SSH 免密登录。
启动
lsyncd -log Exec /etc/lsyncd.conf