inotify+rsync实时同步起源及简介
inotify服务机制
inotify实施准备
inotify配置是建立在rsync服务的基础上
inotify,sersync,lsyncd
sersync功能更多,可以做各种过滤,但从性能上看,通过测试得出inotify性能更高,每秒钟能同步好几百张图片,inotify 150张就不能实时了
实施前检查rsync daemon是正常
[root@Aoldboy]#ps-ef|grepdaemon root126110Dec11?00:00:04/usr/bin/rsync--daemon root139421945002:57pts/000:00:00grepdaemon
并且可以正常推送
[root@Bscripts]#rsync-avz/data/rsync_backup@192.168.129.128::data--password-file=/etc/rsync.password sendingincrementalfilelist ./ 10 100 11 sent4345bytesreceived1893bytes4158.67bytes/sec totalsizeis0speedupis0.00
工作场景
inotify的安装
inotifywait命令常用参数
inotify.sh脚本配置参数
[root@Bdata]#cat /server/scripts/inotify1.sh #!/bin/bash #para host01=192.168.129.128 src=/data dst=oldboy user=rsync_backup rsync_passfile=/etc/rsync.password inotify_home=/usr/local/ #judge #if[!-e "$src"]\ #||[!-e"${rsync_passfile}"]\ #||[!-e"${inotify_home}/bin/inotifywait"]\ #||[!-e "/usr/bin/rsync"]; #then #echo"CheckFileandFolder" #exit9 #fi ${inotify_home}/bin/inotifywait-mrq--timefmt '%d/%m/%y%H:%M'--format'%T%w%f'-eclose_write,delete,create,attrib$src\ |whilereadfile#读前一段代码输出的文件 do #rsync -avzP--delete--timeout=100--password-file=${rsync_passfile}$src $user@$host01::$dst>/dev/null2>&1 cd$src&&rsync-aruz-R--delete./ --timeout=100$user@$host01::$dst--password-file=${rsync_passfile} >/dev/null2>&1 done exit0原文链接:https://www.f2er.com/centos/379453.html