Inotify+rsync real-time synchronization origin and introduction
INotify Service mechanism
INotify Implementation Preparation
The INotify configuration is based on the rsync service
Inotify,sersync,lsyncd
Sersync function More, can do a variety of filtering, but from a performance perspective, through the test results inotify higher performance, can sync good hundreds of images per second, inotify 150 can not be real-time
Check rsync daemon before implementation is normal
[[email protected] oldboy]# ps-ef |grep daemonroot 1261 1 0 Dec11? 00:00:04/usr/bin/rsync--daemonroot 13942 1945 0 02:57 pts/0 00:00:00 grep daemon
And can be pushed normally
[Email protected] scripts]# rsync-avz/data/[email protected]::d ATA--password-file=/etc/rsync.password Sending Incremental file list./1010011sent 4345 Bytes received 1893 bytes 4158.67 bytes/sectotal size is 0 speedup is 0.00
Work scenario
Installation of INotify
inotifywait Command Common parameters
inotify.sh Script Configuration Parameters
[[email protected] data]# cat/server/scripts/inotify1.sh#!/bin/bash#parahost01= 192.168.129.128src=/datadst=oldboyuser=rsync_backuprsync_passfile=/etc/rsync.passwordinotify_home=/usr/local/ #judge #if [ ! -e "$SRC"] #| | [ ! -e "${rsync_passfile}" ] #| | [ ! -e "${inotify_home}/bin/inotifywait" ] #| | [ ! -e "/usr/bin/rsync" ] ; #then # echo "Check file and folder "# exit 9#fi ${inotify_home}/bin/inotifywait -mrq --timefmt '%d/%m/% Y %h:%m ' --format '%t %w%f ' -e close_write,delete,create,attrib $src | while read file #读前一段代码输出的 Documents do #rsync-avzp --delete --timeout=100 -- password-file=${rsync_passfile} $src [email protected] $hostIn:: $dst >/dev/null 2>&1 cd $SRC && rsync -aruz -r --delete ./--timeout=100 [email protected] $host 01 :: $dst--password-file=${rsync_passfile}>/dev/null 2>&1 doneexit 0
CentOS 6.5 Inotify+rsync Do real-time synchronization-Enterprise Instance (1.0)