安裝lua關聯包:css
yum install lua lua-static lua-develgit
安裝lsyncd:github
wget https://lsyncd.googlecode.com/files/lsyncd-2.1.5.tar.gzvim
tar -xzvf lsyncd-2.1.5.tar.gz服務器
cd lsyncd-2.1.5ssh
./configure -prefix=/usr/local/lsyncdide
make&&make install測試
ln -s /usr/local/lsyncd/bin/lsyncd /usr/bin/lsyncdgoogle
配置lsyncd:lua
本地模式:
mkdir /usr/local/lsyncd/etc
cd /usr/local/lsyncd/etc
vim lsyncd.conf.lua
settings{
logfile ="/var/log/lsyncd.log",
statusFile ="/var/log/lsyncd-status.log",
pidfile ="/var/run/lsyncd.pid",
statusInterval =20,
nodaemon =false, --測試能夠開啓
inotifyMode ="CloseWrite",
maxProcesses =4,
maxDelays =1,
}
sync{
default.rsync,
source ="/data/test1",
target ="/data/test2",
maxDelays = 5,
delay = 30,
rsync ={
binary ="/usr/bin/rsync",
archive =true,
compress =true,
owner =true,
perms =true,
_extra ={"--include=*-G.jpg","--exclude=*"},
},
}
參數說明:
--//表示註釋。
nodaemon=true//表示不啓用守護模式。默認是啓用。
sync裏面是定義同步參數,指定默認以直接模式direct運行。
Lsyncd支持rsync、rsyncssh、direct三種模式。
maxDelays 累計到多少所監控的事件激活一次同步,即便後面的delay延遲時間還未到
delay 累計事件,等待rsync同步延時時間,默認15秒(最大累計到1000個不可合併的事件)。
詳細參數說明:
啓動:
lsyncd /usr/local/lsyncd/etc/lsyncd.conf.lua
同步遠程服務器目錄:
遠程目錄有兩種模式,rsync模式和rsyncssh模式。
Rsync模式配置:
settings{
logfile ="/var/log/lsyncd.log",
statusFile ="/var/log/lsyncd-status.log",
pidfile ="/var/run/lsyncd.pid",
statusInterval =20,
nodaemon =false, --測試能夠開啓
maxProcesses =4,
maxDelays =1,
}
sync{
default.rsync,
source ="/data/test1",
target ="rsync@192.168.16.234:/data/test2",
rsync ={
binary ="/usr/bin/rsync",
archive =true,
compress =true,
owner =true,
perms =true,
password_file="/etc/rsyncd/rsyncd.password",
_extra ={"--include=*-G.jpg","--exclude=*"},
},
}