Lsyncd Installation and Configuration

Login on server as a “root” user.

cd /usr/local/
wget http://lsyncd.googlecode.com/files/lsyncd-2.1.5.tar.gz
tar \-xvzf lsyncd-2.1.5.tar.gz
cd lsyncd-2.1.5
yum install gcc-c+\+
yum install lua
yum install lua-devel
./configure
make
make install

Now we need to create Linux daemon which call up our customized lsyncd config file. Daemon script would be like…

. /etc/rc.d/init.d/functions
user=glmstudio
config="<path>/lsyncd.lua"
lsyncd="/usr/local/bin/lsyncd"
lockfile="<lock PATH>/lsyncd"
prog="lsyncd"
RETVAL=0
start() {
        if [ -f $lockfile ]; then
        echo -n $"$prog is already running: "
        echo
        else
        echo -n $"Starting $prog: "
        #su - $user -c "$lsyncd $config -insist"
        daemon --user $user $lsyncd $config -insist
        RETVAL=$?
        echo
        [ $RETVAL = 0 ] && su - $user -c "touch $lockfile"
        return $RETVAL
        fi
    }
stop() {
        echo -n $"Stopping $prog: "
        killproc -d 60 lsyncd
        RETVAL=$?
        echo
        [ $RETVAL = 0 ] && rm -f $lockfile
        return $RETVAL
    }
case "$1" in
        start)
        start
        ;;
        stop)
        stop
        ;;
        restart)
        stop
        start
        ;;
        status)
        status lsyncd
        ;;
        *)
        echo "Usage: lsyncd {start|stop|restart|status}"
        exit 1
    esac
    exit $?

</lock></path>

Lsyncd.lua file would have your sync configuration. Something as follows.

--SETTINGS
settings {
    logfile         = "<path>/lsyncd.log",
    statusFile      = "</path><path>/lsyncd.stat",
    statusInterval  = 300
    }
--ENDSETTINGS
--SERVERS
 serverlist = {"SERVER1:DISTINATION",
"SERVER2:DISTINATION"}
--ENDSERVERS
for _, server in ipairs(serverlist) do
  sync {
    default.rsync,
    source="<source PATH/>",
    target=server,
     delay = 30,
    rsync  = {
        protect_args = false
    }
  }
end

</path>

How to start and stopwatch film King Arthur: Legend of the Sword now

/etc/init.d/lsyncd start

/etc/init.d/lsyncd stop

There might be the issue during start of lsyncd, as some time list of files are more than max user watches. For fixing this we need to change from following file.

/proc/sys/fs/inotify/max_user_watches

//Command 

echo "819211" > /proc/sys/fs/inotify/max_user_watches

Categories: Linux, Website Peformance