salve端部署

1、安装rsync服务端
yum install rsync -y
2、修改配置文件(vim /etc/rsyncd.conf),192.168.88.0/24是允许同步的网段
#Rsync server
uid = root
gid = root
use chroot = yes                        
max connections = 20                  
timeout = 900          
pid file =/var/run/rsyncd.pid           
lock file =/var/run/rsync.lock          
log file = /var/log/rsyncd.log
read only = false
list = false
hosts allow = 192.168.88.0/24
hosts deny = *
auth users = rsync_backup
secrets file =/etc/rsync.password

[www] 
path = /data/nginx/conf
comment = conf 

3、设置密码(vim /etc/rsync.password(rsync.password默认没有))
rsync_backup:123456
4、设置权限
chmod 600 /etc/rsync.password

master端部署

1、安装rsync客户端
yum install rsync -y
2、设置密码(vim /etc/rsync.password(rsync.password默认没有))
123456
3、设置权限
chmod 600 /etc/rsync.password
4、部署inotify-tools
tar -zxvf inotify-tools-3.20.2.2.tar.gz
make -j 4
make install
5、编写同步脚本inotify_rsync.sh
#!/bin/bash

inotifywait -mrq -e create,move,close_write,attrib,delete,modify --exclude="(.*.swp)|(.*~$)|(.*.swx)" /data/nginx/conf/  | while read file
do
rsync -azP --delete /data/nginx/conf/ rsync_backup@192.168.0.217::conf --password-file=/etc/rsync.password &>/dev/null
done

6、执行
nohup sh inotify_rsync.sh &>/var/log/rsync.log &