Lsyncd on CentOS 7

Master Server’s IP = 192.168.1.14
Slave Server’s IP = 192.168.1.15
Directory to be Sync = /var/www/html


*** First Enable Key based authentication between Master and Slave Server.
#ssh-keygen

*** Now Copy the public key using ssh-copy-id command to slave server
#ssh-copy-id -i /root/.ssh/id_rsa.pub root@192.168.1.15

*** Install the lsyncd dependency packages using below yum command.
#yum install lua lua-devel pkgconfig gcc asciidoc
#rpm -iUvh http://dl.fedoraproject.org/pub/epel/7/x86_64/e/epel-release-7-5.noarch.rpm
#yum install lsyncd

*** Set up Configuration File of Lsyncd
Copy the sample Configuration to /etc/lsyncd.conf
	#cp /usr/share/doc/lsyncd-2.1.5/examples/lrsync.lua /etc/lsyncd.conf

*** Add the following Lines to the config file.
#vi /etc/lsyncd.conf
Modify
settings = {
 logfile = "/var/log/lsyncd.log",
 statusFile = "/var/log/lsyncd.stat",
 statusInterval = 2,
}
sync{
 default.rsync,
 source="/var/www/html",
 target="192.168.1.15:/var/www/html",
 rsync={rsh ="/usr/bin/ssh -l root -i /root/.ssh/id_rsa",}
}


*** Start the Service and enable it at reboot
# systemctl start lsyncd
# systemctl enable lsyncd

Lsyncd on CentOS 7

By Chadchai Praphasanobol

Lsyncd on CentOS 7

  • 778