拓扑图如下:
[root@server10 ~]#wget http://rsync.samba.org/ftp/rsync/src/rsync-3.0.9.tar.gz
[root@server10 ~]#tar xzf rsync-3.0.9.tar.gz
[root@server10 ~]#cd rsync-3.0.9
[root@server10 rsync-3.0.9]#./configure
[root@server10 rsync-3.0.9]#make && make install
默认会安装到/usr/local/bin/rsync ,所以我们要把/usr/bin下面的rsync备份一次删除或重命名,然后做一个软连接到/usr/local/bin/rsync
[root@server10 rsync-3.0.9]#ln -s /usr/local/bin/rsync rsync
查看版本,即为升级后的版本
[root@server10 book]# rsync --version
rsync version 3.0.9 protocol version 30
Copyright (C) 1996-2011 by Andrew Tridgell, Wayne Davison, and others.
Web site: http://rsync.samba.org/
Capabilities:
64-bit files, 64-bit inums, 32-bit timestamps, 64-bit long ints,
socketpairs, hardlinks, symlinks, IPv6, batchfiles, inplace,
append, ACLs, xattrs, iconv, no symtimes
rsync comes with ABSOLUTELY NO WARRANTY. This is free software, and you
are welcome to redistribute it under certain conditions. See the GNU
General Public Licence for details.
confxml.xml sersync2
<head version="2.5">
<host hostip="localhost" port="9090"></host>
<debug start="false"/>
<fileSystem xfs="false"/>
<filter start="false"> #请根据实际情况启用
<exclude expression="^((?!original\.).*)$"></exclude>
<exclude expression="image"></exclude>
<exclude expression="txt"></exclude>
<exclude expression="xml"></exclude>
<exclude expression="*"></exclude>
-->
</filter>
<inotify>
<delete start="false"/> #不监控文件或目录的删除
<createFolder start="true"/> #监控目录的创建
<modify start="true"/> #监控文件的修改
<createFile start="true"/>
<closeWrite start="true"/> #监控创建新文件
<moveFrom start="false"/>
<moveTo start="false"/>
<attrib start="false"/>
</inotify>
<sersync>
<localpath watch="/data/bookfm/doc/book"> #设置监控的目录
<remote ip="192.168.100.250" name="book"/>
<!--<remote ip="192.168.8.39" name="tongbu"/>-->
<!--<remote ip="192.168.8.40" name="tongbu"/>-->
</localpath>
<rsync>
<commonParams params="-au" --include='*original.*' --exclude='bin' --exclude='image' --exclude 'xml' --exclude='txt' --include='*/' --exclude='*'"/>
<auth start="true" users="bookbackup" passwordfile="/usr/local/GNU-Linux-x86/rsyncd.secrets"/>
<userDefinedPort start="false" port="874"/><!-- port=874 -->
<timeout start="false" time="100"/><!-- timeout=100 -->
<ssh start="false"/>
</rsync>
<failLog path="/tmp/rsync_fail_log.sh" timeToExecute="60"/><!--default every 60mins execute once-->
<crontabfilter start="false">
<exclude expression="*.php"></exclude>
<exclude expression="info/*"></exclude>
</crontabfilter>
</crontab>
<plugin start="false" name="command"/>
</sersync>
<plugin name="command">
<param prefix="/bin/sh" suffix="" ignoreError="true"/> <!--prefix /opt/tongbu/mmm.sh suffix-->
<filter start="false">
<include expression="(.*)\.php"/>
<include expression="(.*)\.sh"/>
</filter>
</plugin>
<plugin name="socket">
<localpath watch="/opt/tongbu">
<deshost ip="192.168.138.20" port="8009"/>
</localpath>
</plugin>
<plugin name="refreshCDN">
<localpath watch="/data0/htdocs/cms.xoyo.com/site/">
<cdninfo domainname="ccms.chinacache.com" port="80" username="xxxx" passwd="xxxx"/>
<sendurl base="http://pic.xoyo.com/cms"/>
<regexurl regex="false" match="cms.xoyo.com/site([/a-zA-Z0-9]*).xoyo.com/images"/>
</localpath>
</plugin>
</head>
uid = root
#系统中存在的用户,这个用户要能对备份的路径有写入权限
gid = root
#系统中存在的用户组,用户组要能对备份的路径有写入权限
max connections = 100 #最大连接数
use chroot = no
log file = /var/rsync/rsync.log #指定同步日志
pid file = /var/rsync/rsyncd.pid #指定运行时PID文件
lock file = /var/rsync/rsyncd.lock
[book]
path = /backup/bookfm #指定备份的路径
read only=no #可写入
ignore errors = yes #忽略错误
secrets file =/etc/rsyncd/rsyncd.secrets
#指定rsync自身的密码文件(非系统用户)
auth users = bookbackup #指定这个共享名验证的用户名
hosts allow = 192.168.100.246/24 #只允许这个IP地址