Install and use Lsyncd on CentOS 7 & RHEL 7
- Master Server’s IP = 192.168.1.14
- Slave Server’s IP = 192.168.1.15
- Directory to be Sync = /var/www/html
root@ec:/home/ec# ssh-keygen
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /root/.ssh/id_rsa.
Your public key has been saved in /root/.ssh/id_rsa.pub.
The key fingerprint is:
5f:56:26:70:d4:99:7f:77:87:0a:46:f6:5e:e6:22:df root@ec
The key's randomart image is:
+---[RSA 2048]----+
| ..o. o |
| oo + |
| o .. oo |
| o .++ *|
| S. oo= =|
| ..o+ . |
| .o o |
| . E |
| |
+-----------------+
[root@hackthesec ~]# ssh-copy-id -i /root/.ssh/id_rsa.pub root@192.168.1.15
[root@hackthesec ~]# yum install lua lua-devel pkgconfig gcc asciidoc
[root@hackthesec ~]# rpm -iUvh http://dl.fedoraproject.org/pub/epel/7/x86_64/e/epel-release-7-5.noarch.rpm
[root@hackthesec ~]# yum install lsyncd
[root@hackthesec ~]# cp /usr/share/doc/lsyncd-2.1.5/examples/lrsync.lua /etc/lsyncd.conf
[root@hackthesec ~]# cat /etc/lsyncd.conf
----
-- User configuration file for lsyncd.
--
-- Simple example for default rsync.
--
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",}
}
[root@hackthesec ~]#
[root@hackthesec ~]# systemctl start lsyncd [root@hackthesec ~]# systemctl enable lsyncd ln -s '/usr/lib/systemd/system/lsyncd.service' '/etc/systemd/system/multi-user.target.wants/lsyncd.service'
[root@hackthesec ~]# tail -10 /var/log/lsyncd.log
Sun Jul 26 12:53:04 2015 Normal: recursive startup rsync: /var/www/html/ -> 192.168.1.15:/var/www/html/
Sun Jul 26 12:53:56 2015 Normal: Startup of "/var/www/html/" finished.
[root@hackthesec ~]#
[root@hackthesec ~]# more /var/log/lsyncd.stat
Lsyncd status report at Sun Jul 26 12:53:58 2015
Sync1 source=/var/www/html/
There are 0 delays
Excluding:
nothing.
Inotify watching 849 directories
1: /var/www/html/
2: /var/www/html/catalog/
3: /var/www/html/catalog/controller/
4: /var/www/html/catalog/controller/module/
5: /var/www/html/catalog/controller/checkout/
6: /var/www/html/catalog/controller/api/
7: /var/www/html/catalog/controller/payment/
8: /var/www/html/catalog/controller/tool/
9: /var/www/html/catalog/controller/product/
---------------------
848: /var/www/html/system/library/db/
849: /var/www/html/system/modification/
[root@hackthesec ~]#
Hack The Sec
Hack The Sec Twitter
Our Another Website
I am a Linux Administrator and Security Expert with this site i can help lot's of people about linux knowladge and as per security expert i also intersted about hacking related news.TwitterFacebook
Find files containing specific text in Linux Find files containing specific text using grep comma...Read more »
oVirt is an open-source distributed virtualization solution, designed to manage your entire enterpr...Read more »
How to Enable exec() in PHP-FPM? Sometimes the exec() function is not working after turning on the...Read more »
Install Go 1.7 on Ubuntu 16.04 / 14.04 / CentOS 7 / Fedora 24 Go (often referred to as golang) is ...Read more »
Install and Configure Nextcloud on CentOS / RHEL 7 Nextcloud is functionally very similar to the w...Read more »