Inotify+rsync Real-time synchronization tool combat

Source: Internet
Author: User

Inotify+rsync Real-time synchronization tool combat

Separate machines:server-178/24,client-b-179/24,client-c-180/24

Hub Distribution server Master:client-c-180/24

Backup servers:client-b-179/24 and server-178/24

Based on the rsync--daemon provided by the backup server, the INotify is configured on the central distributor (rsync client) , The monitored Directory is set to /www/

1. Check whether the current system supports inotify

Ls-l/proc/sys/fs/inotify/

[Email protected] tools]# ls-l/proc/sys/fs/inotify/

Total 0

-rw-r--r--1 root root 0 Oct 03:34 max_queued_events

-rw-r--r--1 root root 0 Oct 03:34 max_user_instances

-rw-r--r--1 root root 0 Oct 03:34 max_user_watches

# showing these three files proves the support

2. Download inotify Source Package

UseSecureCRTof theRZfunction toinotify-tools-3.13.tar.gz, upload the hub distribution serverMaster:client-c-180/24of the/toolsdirectory.

[Email protected] tools]# pwd

/tools

[[email protected] tools]# ls

Inotify-tools-3.13.tar.gz

Sersync2.5_32bit_binary_stable_final.tar.gz

Sersync2.5.4_64bit_binary_stable_final.tar.gz

3. compile and install inotify

[Email protected] tools]# tar zxf inotify-tools-3.13.tar.gz

[Email protected] tools]# CD inotify-tools-3.13

[Email protected] inotify-tools-3.13]#/configure--prefix=/usr/local/inotify-tools-3.13

[[email protected] inotify-tools-3.13]# make &&make Install

4. after the installation is completed in the /server/scripts directory to write a script default does not exist, named:inotify_rsync.sh, need to write their own, The following format:

A simple script:

#!/bin/sh

# Define Variables

src=/www/

[Email protected]::www/# to IP Address host 178

[Email protected]::www/# to IP Address host 179

Pass=/etc/rsync.password

Inwt=/usr/local/inotify-tools-3.13/bin/inotifywait

Rsync=/usr/bin/rsync

$INWT-mrq-e create,move,delete,modify $SRC | While read D E f;do

Rsync-aruz--delete $SRC ${dst178}--password-file=${pass} >/dev/null 2>&1

Rsync-aruz--delete $SRC ${dst179}--password-file=${pass} >/dev/null 2>&1

Done

5. execute the script command:

SH inotify_rsync.sh & # This is put in the background to do "&

6. Enter the monitoring directory to test if it can be synchronized successfully

cd/www/



This article is from the "Crazy Days" blog, be sure to keep this source http://crazyday.blog.51cto.com/9974109/1715720

Inotify+rsync Real-time synchronization tool combat

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.