4、 配置confxml.xml文件(×××是需要修改的部份)
<head version="2.5">
<host hostip="localhost" port="8008"></host>
<debug start="false"/>
<fileSystem xfs="false"/>
<filter start="false">
<exclude expression="(.).svn"></exclude>
<exclude expression="(.).gz"></exclude>
<exclude expression="^info/"></exclude>
<exclude expression="^static/"></exclude>
</filter>
<inotify>
<delete start="true"/>
<createFolder start="true"/>
<createFile start="false"/>
<closeWrite start="true"/>
<moveFrom start="true"/>
<moveTo start="true"/>
<attrib start="false"/>
<modify start="false"/>
</inotify>
<sersync>
<localpath watch="/data/web">
/data/web就是rsync客户端的目录
<remote ip="192.168.239.133" name="web"/>
192.168.239.133就是rsync服务器的IP地址
Name=web 这个web就是在rsyncd.conf配置文件里面定义的模块
<!--<remote ip="192.168.8.39" name="tongbu"/>--> 这个注释
<!--<remote ip="192.168.8.40" name="tongbu"/>--> 这个注释
</localpath>
<rsync>
<commonParams params="-artuz"/>
-artuz就是rsync 后面对应的参数选项,例如rsync -avzR
<auth start="true" users="rsync_backup" passwordfile="/etc/rsync.passwd"/>
Users=虚拟用户 passwordfile=虚拟用户的密码文件所在的位置
<userDefinedPort start="false" port="874"/><!-- port=874 -->
<timeout start="false" time="100"/><!-- timeout=100 -->
<ssh start="false"/>
</rsync>
#目标服务器传输失败时会重新传输,再次失败会写入rsync_fail_log中,每隔一段时间(timeToExecute)执行脚本再次传输
<failLog path="/usr/local/sersync/logs/rsync_fail_log.sh" timeToExecute="60"/><!--default every 60mins execute once-->
<crontab start="false" schedule="600"><!--600mins-->
<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>
5、 启动sersync
启动方法 /usr/local/sersync/bin/sersync2 -r -d -o /usr/local/sersync/conf/confxml.xml
-d daemon方式启动
-n 启用线程数量
-o 指定配置文件
-r 递归同步目录数据
原文地址:http://blog.51cto.com/2179600/2095253