目标服务器 192.168.50.219
目的:实现源服务器192.168.50.218 /www文件夹文件实时同步到目标服务器192.168.50.219 的/www目录下
#cd /usr/local/src/tarbag/ //切换下载目录
#wget http://www.samba.org/ftp/rsync/rsync-3.0.6.tar.gz //wget下载文件
#tar –xzvf rsync-3.0.6.tar.gz –C ../software/ //解压tar包到指定目录
#cd /usr/local/src/software/ rsync-3.0.6/ //切换到解压目录
#./configure –prefix=/usr/local/rsync –disable-ipv6 //配置
#make && make install //编译安装
#cd /usr/local/rsync
#mkdir /var
#vim /usr/local/rsync/etc/rsyncd.conf
log file = /usr/local/rsync/var/rsyncd.Log
pid file = /usr/local/rsync/var/rsyncd.Pid
lock file = /usr/local/rsync/var/rsyncd.Lock
secrets file = /usr/local/rsync/etc/rsyncd.Pas
motd file = /usr/local/rsync/etc/rsyncd.Motd
hosts allow = 192.168.50.0/24
list = yes
uid = root
gid = root
use chroot = no
max connections = 30
[www]
path = /www
comment = bakup www
read only = no
auth users = root
#chmod 600 rsyncd.conf //修改权限
# vi rsyncd.motd //显示同步信息
welcome
# vim rsyncd.pas //密码文件,客户端也需要
root:123456
# rsync --daemon --config=/usr/local/rsync/etc/rsyncd.conf //启动rsync服务
#cd /usr/local/src/tarbag/ //切换下载目录
#wget http://downloads.sourceforge.net/inotify-tools/inotify-tools-3.13.tar.gz?modtime=1199213676&big_mirror=0//wget下载文件
#tar –xzvf inotify-tools-3.13.tar.gz -C /software //解压tar包到指定目录
#cd /usr/local/src/software/inotify-tools-3.13.tar.gz//切换到解压目录
#./configure –prefix=/usr/local/inotify //配置
#make && make install //编译安装
#vim /usr/local/inotify/rsync.sh
#!/bin/sh
/usr/local/inotify/bin/inotifywait -mrq -e create,move,delete,modify /www | while read file ; do
/usr/bin/rsync -avH --delete --password-file=/etc/rsyncd.pas /www/
#chmod +x rsync.sh
# vim /etc/rsyncd.pas
123456
8192 /proc/sys/fs/inotify/max_user_watches
来统计一下,并保证这个值大于统计结果。
频繁,这个值就应该越大。如果你在日志中看到""** Event Queue Overflow **"
这样的消息,这就意味着"max_queued_events"太小,并且自此之后对于文件系统的监控都是不准确的,你应该在调整参数后重启
另外,它的输出为ls 内容,无法定位变化的文件
结论:此命令虽然挺有用处,但不能替代inotyfy