sersync2 完全安装配置说明(二) —-可选功能与xml高级配置

六月 13th, 2010 Posted in Rsync | 阅读次数: 218 次

XML配置说明
sersync可选功能是通过xml配置文件来实现的,基本配置文件如下:
—————————————————————————————————————————

<?xml version="1.0" encoding="ISO-8859-1"?>

<head version="2.5">  <host port="8008" hostip="localhost"></host> 

<filter start="false">
<exclude expression="(.*)\.gz"></exclude>
<exclude expression="^info/*"></exclude>
</filter> 

<inotify>
<delete start="true" />
<createfolder start="true" />
<createfile start="true" />
</inotify>

<debug start="false" /> 

<sersync>
<localpath watch="/opt/tongbu">
<remote name="tongbu1" ip="192.168.0.104" />
<!--<remote ip="192.168.8.39" name="tongbu"/>-->
<!--<remote ip="192.168.8.40" name="tongbu"/>-->
</localpath> 

<rsync>
<commonparams params="-artuz" />
<auth start="false" passwordfile="/etc/rsync.pas" users="root" />
<userdefinedport port="874" start="false" /><!-- port=874 -->
<timeout start="false" time="100" /><!-- timeout=100 -->
<ssh start="false" />
</rsync> 

<faillog path="/tmp/rsync_fail_log.sh" timetoexecute="60" />
<crontab start="false" schedule="600"><!--600mins-->
<crontabfilter start="false">
<exclude expression="*.gz"></exclude>
<exclude expression="info/*"></exclude>
</crontabfilter>
</crontab>
<plugin start="false" name="command" />
</sersync>

———————————————————————————————————————

下面做逐行的进行解释说明:

<host hostip="localhost" port="8008"></host>

hostip与port是针对插件的保留字段,对于同步功能没有任何作用,保留默认即可。

 


filter文件过滤功能对于sersync监控的文件,会默认过滤系统的临时文件(以“.”开头,以“~”结尾),除了这些文件外,可以自定义其他需要过滤的文件。

<filter start="true">

<exclude expression="(.*)\.gz"></exclude>

<exclude expression="^info/*"></exclude>

</filter>

将start设置为 true,在exclude标签中,填写正则表达式,默认给出两个例子分别是过滤以".gz"结尾的文件与过滤监控目录下的info路径(监控路径/info/*),可以根据需要添加,但开启的时候,自己测试一下,正则表达式如果出现错误,控制台会有提示。相比较使用rsync 的exclude功能,被过滤的路径,不会加入监控,大大减少rsync的通讯量。


inotify监控参数设定(优化)

对于inotify监控参数可以进行设置,根据您项目的特点优化srsync。

<inotify>

<delete start="true"/>

<createFolder start="true"/>

<createFile start="true"/>

</inotify>

对于大多数应用,可以尝试把createFile(监控文件事件选项)设置为false来提高性能,减少 rsync通讯。因为拷贝文件到监控目录会产生create事件与close_write事件,所以如果关闭create事件,只监控文件拷贝结束时的事 件close_write,同样可以实现文件完整同步。 注意:强将createFolder保持为 true,如果将createFolder设为false,则不会对产生的目录进行监控,该目录下的子文件与子目录也不会被监控。所以除非特殊需要,请开启。默认情况下对创建文件(目录)事件与删除文件(目录)事件都进行监控,如果项目中不需要删除远程目标服务器的文件(目录),则可以将delete 参数设置为false,则不对删除事件进行监控。

 


Debug开启

<debug start="false"/>

设置为true,开启debug模式,会在sersync正在运行的控制台,打印inotify事件与rsync同步命令。




XFS文件系统

<fileSystem xfs="false"/>

对于xfs文件系统的用户,需要将这个选项开启,才能使sersync正常工作


文件监控与远程同步设置

<sersync>

<localpath watch="/opt/tongbu">

<remote ip="192.168.0.104" name="tongbu1"/>

<!–<remote ip="192.168.8.39" name="tongbu"/>–>

<!–<remote ip="192.168.8.40" name="tongbu"/>–>

</localpath>



Rsync参数配置

<rsync>

<commonParams params="-artuz"/>

<auth start="false" users="root" passwordfile="/etc/rsync.pas"/>

<userDefinedPort start="false" port="874"/><!– port=874 –>

<timeout start="false" time="100"/><!– timeout=100 –>

<ssh start="false"/>

</rsync>

commonParams 可以用户自定义rsync参数,默认是-artuz

auth start="false" 设置为true的时候,使用rsync的认证模式传送,需要配置user与passwrodfile(–password-file=/etc /rsync.pas),来使用。userDefinedPort  当远程同步目标服务器的rsync端口不是默认端口的时候使用 (–port=874)。timeout设置rsync的timeout时间(–timeout=100)。ssh 使用rsync -e ssh的方式进行传输。

 


失败日志脚步配置

<failLog path="/tmp/rsync_fail_log.sh" timeToExecute="60"/><!–default every 60min

对于失败的传输,会进行重新传送,再次失败就会写入rsync_fail_log,然后每隔一段时间(timeToExecute进行设置)执行该脚本再次重新传送,然后清空该脚本。可以通过path来设置日志路径。

 


Crontab定期整体同步功能

<crontab start="false" schedule="600"><!–600mins–>

<crontabfilter start="false">

<exclude expression="*.gz"></exclude>

<exclude expression="info/*"></exclude>

</crontabfilter>

</crontab>

crontab可以对监控路径与远程目标主机每隔一段时间进行一次整体同步,可能由于一些原因两次失败重传都失败了,这个时候如果开启了crontab功能,还可以进一步保证各个服务器文件一致,如果文件量比较大,crontab的时间间隔要设的大一些,否则可能增加通讯开销。schedule这个参数是设置 crontab的时间间隔,默认是600分钟

如果开启了filter文件过滤功能,那么crontab整体同步也需要设置过滤,否则虽然实时同步的时候文件被过滤了,但crontab整体同步的时候如果不单独设置crontabfilter,还会将需过滤的文件同步到远程,crontab的过滤正则与filter过滤的不同,也给出了两个实例分别对应与过滤文件与目录。总之如果同时开启了filter与crontab,则要开启crontab的crontabfilter,并按示例设置使其与 filter的过滤一一对应。

 


插件设置

<plugin start="false" name="command"/>

当设置为true的时候,将文件同步到远程服务器后会调用name参数指定的插件。

 

完成!

 

原文:http://hi.baidu.com/johntech/blog/item/f88fef2868203196033bf6a2.html

相关日志:

Tags:

6 Responses to “sersync2 完全安装配置说明(二) —-可选功能与xml高级配置”

  1. ngmtupsg Says:

    JGu5Tm xixsorphrroo, [url=http://kyeoejokzqex.com/]kyeoejokzqex[/url], [link=http://pybfrhbopavi.com/]pybfrhbopavi[/link], http://yonndkgtqvol.com/


  2. acai ultra lean Says:

    I couldn’t agree more great stuff here.


  3. 1&1 Says:

    nbktlkpwfipujgdrchzx, 1&1, wBFkySX.


  4. affiliate programs Says:

    Hello…

    Nice share. I think your blog should come up much higher in the search results than where it is showing up right now….


  5. Cure Hemorrhoids Says:

    Recommended Sites…

    [...]below you’ll find my links page http://www.hemorrhoidtreatmentcurerelief.com/my-favourite-sites/ with some excellent websites that I think you should go visit[...]…


  6. Get Rid of Yeast Infection Says:

    Recent Favourite Sites…

    [...]below you’ll see my links page http://www.yeastinfectiontreatmentcure.net/links/ with some very good websites that I think you should definitely go visit[...]…


留下您的脚印