inotify+rsync

inotify客户端

安装inotify-tools

写检测脚本

#!/bin/bash

Path=/data

IP=192.168.56.201

inotifywait -mrq --format '%w%f' -e close_write,delete $Path \

| while read file

 do

if [ -f $file ];then

rsync -az $file --delete rsync_backup@$IP::backup --password-file=/etc/rsync.password

else

rsync -avz /data/ --delete rsync_backup@$IP::backup --password-file=/etc/rsync.password

fi

done

优化方法:

在/proc/sys/fs/inotify目录下有三个文件,对inotify机制有一定的限制

max_user_watches #设置inotifywait或inotifywatch命令可以监视的文件数量(单进程)
max_user_instances #设置每个用户可以运行的inotifywait或inotifywatch命令的进程数
max_queued_events #设置inotify实例事件(event)队列可容纳的事件数量
[root@web ~]# echo 50000000>/proc/sys/fs/inotify/max_user_watches -- 把他加入/etc/rc.local就可以实现每次重启都生效
[root@web ~]# echo 50000000>/proc/sys/fs/inotify/max_queued_events
 
 
 

 

posted @ 2018-04-15 17:39  Smile杰丶  阅读(221)  评论(0编辑  收藏  举报