linux下实现web数据同步的四种方式(性能比较)

2019-10-14 21:56:16于海丽

        <exclude expression="*.php"></exclude>
        <exclude expression='#'" /*"></exclude>
        </crontabfilter>
    </crontab>
  #设置sersync传输后调用name指定的插件脚本,默认关闭
    <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>
</head>
#######################################################################

验证实现同步:



###sersync客户端的,开启同步机制,进行监控,然后创建文件
[root@jie3 website]# sersync2 -r -d &
[root@jie3 ~]# cd /website/
[root@jie3 website]# touch index.html  testdb.php  test.html  test.php
###rsync服务器端,查看可以来着sersync客户端的同步文件
[root@jie1 ~]# cd /web/htdocs/
[root@jie1 htdocs]# ls
index.html  testdb.php  test.html  test.php
[root@jie1 htdocs]#

四、unison+inotify实现web数据双向同步

Unison是一款跨平台的文件同步对象,不仅支撑本地对本地同步,也支撑经由过程SSH、RSH和Socket等收集和谈进行同步。
Unison支撑双向同步操纵,你既可以从A同步到B,也可以从B同步到A,这些都不须要额外的设定。

1)、两个服务器都编译安装这三个源码包:(在此我只写一台服务器的编译安装过程)


[root@jie1 ~]#wget ftp://distro.ibiblio.org/slitaz/sources/packages-2.0/o/ocaml-3.10.2.tar.gz
[root@jie1~]#wget  http://freebsd.ntu.edu.tw/FreeBSD/ports/distfiles/unison-2.32.52/unison-2.32.52.tar.gz
[root@jie1~]#wget http://cloud.github.com/downloads/rvoicilas/inotify-tools/inotify-tools-3.14.tar.gz
[root@jie1 ~]# ls
anaconda-ks.cfg            install.log         ocaml-3.10.2.tar.gz
inotify-tools-3.14.tar.gz  install.log.syslog  unison-2.32.52.tar.gz
[root@jie1 ~]# tar xf inotify-tools-3.14.tar.gz
[root@jie1 ~]# tar xf ocaml-3.10.2.tar.gz
[root@jie1 ~]# tar xf unison-2.32.52.tar.gz
##编译安装inotify
[root@jie1 ~]# cd inotify-tools-3.14
[root@jie1 inotify-tools-3.14]# ./configure --prefix=/usr/local/inotify && make && make install