1. 下载软件
    wget http://github.com/downloads/rvoicilas/inotify-tools/inotify-tools-3.14.tar.gz

2.验证Rsync
rsync -avz -e ssh /home/wwwroot/default/images/ root@140.143.*.*:/home/wwwroot/default/images/

3安装软件
tar zxvf inotify-tools-3.14.tar.gz
./configure --prefix=/usr/local/share/inotify-tool
make && make install
echo $?

4.命令简介
Rsync+inotify实现数据实时同步

5.同步脚本
#!/bin/bash
host=140.143.128.231
src=/home/wwwroot/default/images/
/usr/local/inotify/bin/inotifywait -mrq --format '%w%f' -e create,delete,close_write $src \
| while read file
do
/usr/bin/rsync -az "$file" --delete -e ssh /home/wwwroot/default/images/ root@$host:$src
done

6执行脚本
sh +x inotify.sh &

  1. 缺点
    10-100k 并发200-300 极限