数据同步之rsync | 第3篇:sersync+rsync

文章来源:王琦的个人博客-数据同步之rsync | 第3篇:sersync+rsync ,互联网打杂,喜欢多语言编程,记录一些知识碎片,分享一些心得。

前一篇写了inotify+rsync进行实时同步,但是还有些不足。

  • 只能记录下被监听的目录发生了变化,没有记录具体到某个文件和目录。
  • rsync在同步时候,每次都是对整个目录同步,文件多时比较耗时。

sersync是基于inotify开发的。可以具体到某一个文件或者目录的名字,只同步发生变化的文件或目录,因此效率会比前者高很多。

sersync下载地址:https://github.com/wsgzao/sersync

sersync配置文件说明

1、监控相关信息

# 过滤不用的信息
<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>

2、数据配置相关信息

<sersync>
		<!--指定监控目录-->
        <localpath watch="/opt/tongbu">
			<!--指定备份服务器地址和模块信息-->
            <remote ip="172.16.1.41" name="backup"/>	
            <!--<remote ip="192.168.8.39" name="tongbu"/>-->
            <!--<remote ip="192.168.8.40" name="tongbu"/>-->
        </localpath>
        <rsync>
			<!--指定rsync推送时的命令-->
            <commonParams params="-az"/>
			<!--认证用户和密码文件-->
            <auth start="true" users="rsync_backup" passwordfile="/etc/rsync.password"/>
            <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-->
        <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>

启动

./sersync -dro /usr/local/sersync/conf/confxml.xml

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值