Enviroment:
– Server01.192.168.30.201
– Server02.192.168.30.202
– Directory to be Sync : “/opt/web/htdocs/prompt and /opt/vxml ”
2.Step Key based authentication Configuration
-Login to Master server & generate the public and Private keys using the following command:
[root@server01 ~]# ssh-keygen -t rsa [root@server01 ~]# ssh-copy-id -i /root/.ssh/id_rsa.pub root@192.168.30.202
2.Step Installation Lsyncd
[root@server01 ~]# yum install epel-release [root@server01 ~]# yum install lsyncd -y
3.Step Lsyncd Configuration
settings { logfile = "/var/log/lsyncd.log", statusFile = "/var/log/lsyncd.stat", statusInterval = 2, } sync{ default.rsync, source="/opt/web/htdocs/prompt", target="192.168.30.103:/opt/web/htdocs/prompt", rsync={rsh ="/usr/bin/ssh -l appadmin -i /home/appadmin/.ssh/id_rsa",} } sync{ default.rsync, source="/opt/vxml", target="192.168.30.103:/opt/vxml", rsync={rsh ="/usr/bin/ssh -l appadmin -i /home/appadmin/.ssh/id_rsa",} }
Start and enable the lsyncd service using the following commands:
[root@server01 ~]# systemctl enable lsyncd [root@server01 ~]# systemctl start lsyncd
Finally check the lsyncd status Report to control the synchronization and the replication of the directory
[appadmin@ebcm_app1 ~]$ tail -f /var/log/lsyncd.log / Tue Dec 4 16:06:36 2018 Normal: Finished a list after exitcode: 0 Tue Dec 4 16:07:18 2018 Normal: Calling rsync with filter-list of new/modified files/dirs /camp_12.vxml / Tue Dec 4 16:07:18 2018 Normal: Finished a list after exitcode: 0 Wed Dec 5 11:05:13 2018 Normal: Calling rsync with filter-list of new/modified files/dirs /camp_13.vxml /
We hope this tutorial was enough Helpful. If you need more information, or have any questions, just comment below and we will be glad to assist you!