lsyncd is a live syncing daemon. It offers a near realtime file replication. The daemon watches the source directory on the source host. Once update has been made, it automatically syncs to one or more destinations. It works on top of rsync.
More details are available at: http://code.google.com/p/lsyncd/
To get lsyncd 2.x compiled, you need the Lua package.
((( check section D] below for common error messages and how to resolve them )))
A] Lua install:
1] wget http://www.lua.org/ftp/lua-5.1.4.tar.gz; tar xzf lua-5.1.4.tar.gz; cd lua-5.1.4 2] make linux install 3] cp ./etc/lua.pc /usr/lib/pkgconfig 4] set environment for lsyncd compilation: export PKG_CONFIG_PATH=/usr/lib/pkgconfig export LUA_LIBS=/usr/local/lib/liblua.a
B] Lsyncd 2.0.4 Install:
1] Go to: http://code.google.com/p/lsyncd/downloads/list | This is the location to get the latest version. 2] wget http://lsyncd.googlecode.com/files/lsyncd-2.0.4.tar.gz; tar xzvf lsyncd-2.0.4.tar.gz 4] cd lsyncd-2.0.4; ./configure; make; make install 5] cp lsyncd.conf /etc 6] add the sync directories in the to the /etc/lsyncd.conf. 7] /etc/init.d/lsyncd start 8] tail /var/log/lsyncd # check for error messages.
C] Sample /etc/lsyncd.conf:
/etc/lsyncd.conf:
settings = {
logfile = "/var/log/lsyncd.log",
statusFile = "/var/log/lsyncd.status",
}
-- syncs the local directory to user1@server101. This assumes you have proper ssh key
-- setup to login without password.
sync{
default.rsyncssh, source="/opt/apache/share/",
host="user1@server101",
targetdir="/home/user1/apache",
rsyncOps={"-au"},
}
D] /etc/init.d/lsyncd - lsyncd startup script for CentOS, Redhat, or Fedora:
#!/bin/bash
# startup file for lsyncd
LSYNCD=lsyncd
LSYNCD_PATH=/usr/local/bin
LSYNCD_CONFIG=/etc/lsyncd.conf
. /etc/rc.d/init.d/functions
case "$1" in
start)
echo -n "Starting lsyncd: "
${LSYNCD_PATH}/${LSYNCD} $LSYNCD_CONFIG
echo
touch /var/lock/subsys/lsyncd
;;
stop)
echo -n "Shutting down lsyncd: "
killproc $LSYNCD
echo
rm -f /var/lock/subsys/${LSYNCD}
rm -f /var/run/${LSYNCD}.pid
;;
status)
status $LSYNCD
;;
restart)
$0 stop
$0 start
;;
*)
echo "Usage: $0 {start|stop|restart|status}"
exit 1
esac
exit 0
E] Errors and Warnings:
1] ./configure error message:
checking pkg-config is at least version 0.9.0... yes
checking for LUA... no
checking for LUA... no
checking for LUA... no
checking for LUA... configure: error: Package requirements (lua >= 5.1.3) were not met:
No package 'lua' found
Consider adjusting the PKG_CONFIG_PATH environment variable if you
installed software in a non-standard prefix.
Alternatively, you may set the environment variables LUA_CFLAGS
and LUA_LIBS to avoid the need to call pkg-config.
See the pkg-config man page for more details.
To resolve this issue in CentOS:
a] go back to lua-5.1.4 source directory.
b] cp /tmp/lua-5.1.4/etc/lua.pc /usr/lib/pkgconfig
c] export PKG_CONFIG_PATH=/usr/lib/pkgconfig
d] /tmp/lsyncd-2.0.4/configure
2] make error message:
/usr/local/lib/liblua.a(loadlib.o): In function `ll_loadfunc':
loadlib.c:(.text+0x7d4): undefined reference to `dlsym'
loadlib.c:(.text+0x7e2): undefined reference to `dlerror'
loadlib.c:(.text+0x8ad): undefined reference to `dlopen'
loadlib.c:(.text+0x8c3): undefined reference to `dlerror'
/usr/local/lib/liblua.a(loadlib.o): In function `gctm':
loadlib.c:(.text+0xdbc): undefined reference to `dlclose'
collect2: ld returned 1 exit status
make[1]: *** [lsyncd] Error 1
make[1]: Leaving directory `/tmp/lsy/lsyncd-2.0.4'
make: *** [all] Error 2
To resolve this issue in CentOS:
1] vi Makefile
2] Change:
CFLAGS = -g -O2 -Wall $(LUA_CFLAGS)
3] To:
CFLAGS = -ldl -lm -g -O2 -Wall $(LUA_CFLAGS)