192.168.1.88 有文件 /web 要到 192.168.1.189 /web
===================192.168.1.88==================================================
[root@192.168.1.88]#tar zxvf inotify-tools-3.14.tar.gz
[root@192.168.1.88]#cd inotify-tools-3.14
[root@192.168.1.88 inotify-tools-3.14]# ./configure --prefix=/usr/local/inotify-tools
[root@192.168.1.88 inotify-tools-3.14]# make && make install
vi /etc/rsyncd.secrets
root:123
[root@kk22 ~]# cat inotify.sh
#!/bin/bash
#
host1=192.168.1.189 ##服务器端IP
src=/web/ ##本地数据存放目录
dst=web ##服务端数据的目录
user=root ##主机A允许推送拉取数据的用户
/usr/local/inotify-tools/bin/inotifywait -mrq -e modify,delete,create,attrib $src | while read line ; do
/usr/bin/rsync -vzrtopg --delete --progress --password-file=/etc/rsyncd.passwd $src $user@$host::$dst
done
[root@192.168.1.88 ~]# vi inotify.sh
[root@192.168.1.88 ~]# ./inotify.sh
========================192.168.1.189=============================================
yum install xinetd
service xinetd start
chkconfig rsync on
[root@192.168.1.189]# cat /etc/rsyncd.conf
pid file = /var/run/rsyncd.pid
port = 873
uid = root
gid = root
user chroot = yes
read only = no
write only = no
hosts allow=192.168.1.0/255.255.255.0
host deny=*
mac connections = 2
log file = /var/log/rsync.log
log format = %t %a %m %f %b
timeout = 300
[web]
path = /web
list = yes
ignore error
auth user = root
secrets file = /etc/rsyncd.secrets
exclude = 222/
vi /etc/rsyncd.secrets
root:123
原文地址:http://setup.blog.51cto.com/36721/1556976