sersync:
??sersync类似于inotify,同样用于监控,但它克服了inotify的缺点.
inotify+rsync 缺点:
??一个操作可能会产生重复的事件,这样可能会触发rsync的多次同步。
serync特点:
??基于inotify基础上开发而来的。
sersync的作用:
??用来替代inotify+resync的脚本文件。
-
会对对linux系统文件系统产生的临时文件和重复的文件操作进行过滤,在结合rsync同步的时候,节省了运行时耗和网络资源
-
配置简单,提供了要给xml配置文件和一个二进制可执行文件
-
采用多线程模式
-
自带crontab共呢个
sersync项目地址: https://code.google.com/archive/p/sersync/
sersync下载地址: https://code.google.com/archive/p/sersync/downloads
sersync配置文件说明:
<?xml version="1.0" encoding="ISO-8859-1"?>
<head version="2.5">
<host hostip="localhost" port="8008"></host>
<debug start="false"/> # 是否开启调试模式
<fileSystem xfs="false"/>
<filter start="false"> #不开启文件过滤功能,当为true时,以下类型的文件将不同步
<exclude expression="(.*)\.svn"></exclude> #过滤特定后缀的文件
<exclude expression="(.*)\.gz"></exclude>
<exclude expression="^info/*"></exclude>
<exclude expression="^static/*"></exclude>
</filter>
<inotify> # 监控事件,表示inotify的监控事件 sersync背后调用的就是inotify,
<delete start="true"/>
<createFolder start="true"/>
<createFile start="false"/>
<closeWrite start="true"/>
<moveFrom start="true"/>
<moveTo start="true"/>
<attrib start="false"/> #默认为false,修改此行为true,文件属性变化后也会触发同步。
<modify start="false"/>
</inotify>
<sersync> # rsync命令的配置段,sersync背后会嗲用rsync工具
<localpath watch="/data/www"> #修改此行,设置需要同步的源目录或文件,建议同步目录 后面会监控这个目录的变化
<remote ip="10.0.0.12" name="backup"/> #修改此行,指定备份服务器地址和rsync daemon的 共享模块名(相当于实际目录的别名) ,如果下面开启了ssh start,此时name为远程shell方式运行时的目标目录
<!--<remote ip="192.168.8.39" name="tongbu"/>-->
<!--<remote ip="192.168.8.40" name="tongbu"/>-->
</localpath>
<rsync>
<commonParams params="-artuz"/> # sersync是基于rsync同步的,这里是指定rsync选项
<auth start="true" users="rsyncuser" passwordfile="/etc/rsync.pas"/> #默认为false,表示验证之后才同步。改此行为true,指定备份服务器的rsync配置的用户和密码文件
<userDefinedPort start="false" port="874"/><!-- port=874 --> #指定rsync的非标准端口号
<timeout start="false" time="100"/><!-- timeout=100 -->
<ssh start="false"/> #默认使用rsync daemon运行rsync命令,true为使用远程shell模式
</rsync>
<failLog path="/tmp/rsync_fail_log.sh" timeToExecute="60"/><!--default every 60mins execute once--> #错误重传及日志文件路径
<crontab start="false" schedule="600"><!--600mins--> #不开启crontab功能
<crontabfilter start="false"> #不开启crontab定时传输的筛选功能
<exclude expression="*.php"></exclude>
<exclude expression="info/*"></exclude>
</crontabfilter>
</crontab>
<plugin start="fal