[root@nfs ~]# inotifywait --help inotifywait 3.14 Wait for a particular event on a file or set of files. Usage: inotifywait [ options ] file1 [ file2 ] [ file3 ] [ ... ] Options: -h|--help Show this help text. @<file> Exclude the specified file from being watched. --exclude <pattern> Exclude all events on files matching the extended regular expression <pattern>. --excludei <pattern> Like --exclude but case insensitive. ###排除文件或目录,不区分大小写 -m|--monitor Keep listening for events forever. Without this option, inotifywait will exit after one event is received. -d|--daemon Same as --monitor, except run in the background logging events to a file specified by --outfile. Implies --syslog. -r|--recursive Watch directories recursively. ###递归查询目录 --fromfile <file> Read files to watch from <file> or `-' for stdin. -o|--outfile <file> Print events to <file> rather than stdout. -s|--syslog Send errors to syslog rather than stderr. -q|--quiet Print less (only print events). ###打印很少的信息,仅仅打印监控事件的信息,安静的 -qq Print nothing (not even events). --format <fmt> Print using a specified printf-like format ###打印指定输出类似格式字符串 string; read the man page for more details. --timefmt <fmt> strftime-compatible format string for use with %T in --format string. ###指定时间输出的格式 -c|--csv Print events in CSV format. -t|--timeout <seconds> When listening for a single event, time out after waiting for an event for <seconds> seconds. If <seconds> is 0, inotifywait will never time out. -e|--event <event1> [ -e|--event <event2> ... ] Listen for specific event(s). If omitted, all events are listened for. ###通过次参数可以指定需要监控的事件 Exit status: 0 - An event you asked to watch for was received. 1 - An event you did not ask to watch for was received (usually delete_self or unmount), or some error occurred. 2 - The --timeout option was given and no events occurred in the specified interval of time. Events: access file or directory contents were read ###文件或目录被读取 modify file or directory contents were written ###文件或目录被修改 attrib file or directory attributes changed ###文件或目录属性被改变 close_write file or directory closed, after being opened in writeable mode ###文件或目录封闭,无论读/写模式 close_nowrite file or directory closed, after being opened in read-only mode close file or directory closed, regardless of read/write mode open file or directory opened ###文件目录被打开 moved_to file or directory moved to watched directory ###文件或目录被移动到另一个目录 moved_from file or directory moved from watched directory move file or directory moved to or from watched directory create file or directory created within watched directory ###文件或目录被创建在当前目录 delete file or directory deleted within watched directory ###文件或目录被删除 delete_self file or directory was deleted unmount file system containing file or directory unmounted ###文件系统被卸载
[root@nfs /opt/server]# ./sersync2 -n 20 -dro confxml.xml set the system param execute:echo 50000000 > /proc/sys/fs/inotify/max_user_watches execute:echo 327679 > /proc/sys/fs/inotify/max_queued_events parse the command param option: -n thread num is: 20 option: -d run as a daemon option: -r rsync all the local files to the remote servers before the sersync work option: -o config xml name: confxml.xml parse xml config file host ip : localhost host port: 8008 daemon start,sersync run behind the console use rsync password-file : user is rsynd_backup passwordfile is /etc/rsyncd.conf config xml parse success please set /etc/rsyncd.conf max connections=0 Manually sersync working thread 22 = 1(primary thread) + 1(fail retry thread) + 20(daemon sub threads) Max threads numbers is: 42 = 22(Thread pool nums) + 20(Sub threads) please according your cpu ,use -n param to adjust the cpu rate ------------------------------------------ rsync the directory recursivly to the remote servers once working please wait... execute command: cd /data && rsync -az -R --delete ./ --timeout=100 rsynd_backup@172.16.1.42::/data --password-file=/etc/rsyncd.conf >/dev/null 2>&1 run the sersync: watch path is: /data
3.6 测试数据同步传输
nfs服务器生成数据
1 2
[root@nfs ~]# cd /data [root@nfs /data]# for i in {1..1000};do echo "${i}"; echo "${i}" > ${i}.txt;sleep 0.1;done
backup备份服务器查看
1 2
[root@backup ~]# cd /data [root@backup /data]# while true ;do ls |wc -l;sleep 0.1;done