zoukankan      html  css  js  c++  java
  • linux 配置 Sersync

    [root@SERSYNC sersync]# cp conf/confxml.xml conf/confxml.xml.bak.$(date +%F)

    [root@SERSYNC sersync]# ls

    bin  conf  logs

    [root@SERSYNC sersync]# ls conf/

    confxml.xml  confxml.xml.bak.2014-06-04

    初始化的配置文件内容如下:

    [root@SERSYNC sersync]# cat conf/confxml.xml -n

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

    2<head version="2.5">

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

    4    <debug start="false"/>

    5    <fileSystem xfs="false"/>

    6    <filter start="false">

    7<exclude expression="(.*).svn"></exclude>

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

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

    11    </filter>

    12    <inotify>

    13<delete start="true"/>

    14<createFolder start="true"/>

    15<createFile start="false"/>

    16<closeWrite start="true"/>

    17<moveFrom start="true"/>

    18<moveTo start="true"/>

    19<attrib start="false"/>

    20<modify start="false"/>

    21    </inotify>

    23    <sersync>

    24<localpath watch="/opt/tongbu">

    25    <remote ip="127.0.0.1" name="tongbu1"/>

    26    <!--<remote ip="192.168.8.39" name="tongbu"/>-->

    27    <!--<remote ip="192.168.8.40" name="tongbu"/>-->

    28</localpath>

    29<rsync>

    30    <commonParams params="-artuz"/>

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

    32    <userDefinedPort start="false" port="874"/><!-- port=874 -->

    33    <timeout start="false" time="100"/><!-- timeout=100 -->

    34    <ssh start="false"/>

    35</rsync>

    36<failLog path="/tmp/rsync_fail_log.sh" timeToExecute="60"/><!--default every 60mi ns execute once-->

    38    <crontabfilter start="false">

    39<exclude expression="*.php"></exclude>

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

    41    </crontabfilter>

    42</crontab>

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

    44    </sersync>

    46    <plugin name="command">

    47<param prefix="/bin/sh" suffix="" ignoreError="true"/><!--prefix /opt/tongbu/mm

    m.sh suffix-->

    48<filter start="false">

    49    <include expression="(.*).php"/>

    50    <include expression="(.*).sh"/>

    51</filter>

    52    </plugin>

    54    <plugin name="socket">

    55<localpath watch="/opt/tongbu">

    56    <deshost ip="192.168.138.20" port="8009"/>

    57</localpath>

    58    </plugin>

    59    <plugin name="refreshCDN">

    60<localpath watch="/data0/htdocs/cms.xoyo.com/site/">

    61    <cdninfo domainname="ccms.chinacache.com" port="80" username="xxxx" pass wd="xxxx"/>

    62    <sendurl base="http://pic.xoyo.com/cms"/>

    es"/>

    64</localpath>

    65    </plugin>

    66</head>

    为了满足我们的需求,我们需要修改如下几处设置:

    1 修改 24-28 行的内容,原内容为:

    <localpathwatch="/opt/tongbu">        #定义本地要同步的目录

    <remoteip="127.0.0.1" name="tongbu1"/>  #

    <!--<remoteip="192.168.8.39" name="tongbu"/>-->     #同步到哪个机器,,同步到

    机器的哪个模块

    <!--<remoteip="192.168.8.40" name="tongbu"/>-->

    </localpath>

    修改后内容为:

    <localpathwatch="/data/web">

    <remoteip="172.16.100.1" name="web"/>     #这里取掉了两旁的注释

    <remoteip="172.16.100.2" name="web"/>     #这里取掉了两旁的注释

    </localpath>

    该文件中分隔符形式为:<!--###########################-->

    2 修改 31-34 行,认证相关部分:

    <commonParamsparams="-artuz"/>

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

    <userDefinedPortstart="false" port="874"/><!-- port=874 -->

    <timeoutstart="false" time="100"/><!-- timeout=100 -->

    <sshstart="false"/>

    修改后内容为:

    <commonParamsparams="-aruz"/>

    <userDefinedPortstart="false" port="874"/><!-- port=874 -->

    <timeoutstart="true" time="100"/><!-- timeout=100 -->

    <sshstart="false"/> 提示:上面的几个配置就是在拼接

    rsync -aruz --timeout=100 /data/web

    rsync_bak@172.16.100.1::www/

    --password-file=/etc/rsync.password

    3)修改 36-37 行

    <failLogpath="/tmp/rsync_fail_log.sh"timeToExecute="60"/><!--default every 60mins exe

    cute once-->

    修改后内容为

    <failLog path="/usr/local/sersync/logs/rsync_fail_log.sh "timeToExecute="60"/><!--defau

    lt every 60mins execute once-->

    当同步失败后,日志记录到/usr/local/sersync/logs/rsync_fail_log.sh,并且每 60 分钟对失败的

    log 进行重新同步。

    修改后的完整配置文件为:

    [root@SERSYNC sersync]# cat -n /usr/local/sersync/conf/confxml.xml

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

    2<head version="2.5">

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

    4    <debug start="false"/>

    5    <fileSystem xfs="false"/>

    6    <filter start="false">

    7<exclude expression="(.*).svn"></exclude>

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

    10<exclude expression="^static/*"></exclude>

    11    </filter>

    12    <inotify>

    13<delete start="true"/>

    14<createFolder start="true"/>

    15<createFile start="false"/>

    16<closeWrite start="true"/>

    17<moveFrom start="true"/>

    18<moveTo start="true"/>

    19<attrib start="false"/>

    20<modify start="false"/>

    21    </inotify>

    23    <sersync>

    24<localpath watch="/data/web">

    25    <remote ip="172.16.100.1" name="web"/>

    26    <remote ip="172.16.100.2" name="web"/>

    27</localpath>

    28<rsync>

    29    <commonParams params="-aruz"/>

    30    <auth start="true" users="rsync_bak" passwordfile="/etc/rsync.password"/>

    31    <userDefinedPort start="false" port="874"/><!-- port=874 -->

    32    <timeout start="true" time="100"/><!-- timeout=100 -->

    33    <ssh start="false"/>

    34</rsync>

    35<failLog path="/usr/local/logs/rsync_fail_log.sh" timeToExecute="60"/><!--default e very 60mins execute once-->

    37    <crontabfilter start="false">

    38<exclude expression="*.php"></exclude>

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

    40    </crontabfilter>

    41</crontab>

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

    43    </sersync>

    45    <plugin name="command">

    46<param prefix="/bin/sh" suffix="" ignoreError="true"/><!--prefix /opt/tongbu/mm

    m.sh suffix-->

    47<filter start="false">

    48    <include expression="(.*).php"/>

    49    <include expression="(.*).sh"/>

    50</filter>

    51    </plugin>

    53    <plugin name="socket">

    54<localpath watch="/opt/tongbu">

    55    <deshost ip="192.168.138.20" port="8009"/>

    56</localpath>

    57    </plugin>

    58    <plugin name="refreshCDN">

    59<localpath watch="/data0/htdocs/cms.xoyo.com/site/">

    60    <cdninfo domainname="ccms.chinacache.com" port="80" username="xxxx" pass wd="xxxx"/>

    61    <sendurl base="http://pic.xoyo.com/cms"/>

    es"/>

    63</localpath>

    64    </plugin>

    65</head>

    以上的配置文件,我们仅仅配置了针对 SWEB1 和 SWEB2 上 web 这个模块,即/data/web

    目录的自动同步。由于我们还有一个 download 模块,即/data/download 目录需要进行自动

    同步。因此这就意味着,我们需要配置多实例了。

    Sersync 的多实例和往常的 apache,nginx 一样,你只需要把配置文件拷贝一份出来,然后针

    对不同的实例做不同的修改,然后在最后开启 sersync 服务的时候指定不同的配置文件做启动

    即可!

    配置针对 download 的实例配置文件:

    [root@SERSYNC sersync]# cp /usr/local/sersync/conf/confxml.xml /usr/local/sersync/con

    1

    f/download_confxml.xml

    修改方法如上,这里仅贴出和上个实例之间不一样的地方:

    23    <sersync>

    24<localpath watch="/data/download">

    25    <remote ip="172.16.100.1" name="download"/>

    26    <remote ip="172.16.100.2" name="download"/>

    27</localpath>

    28<rsync>

  • 相关阅读:
    从头开始搭建分布式日志平台的docker环境
    spring mvc+ELK从头开始搭建日志平台
    两个与spring事务相关的问题
    shiro realm 注解失败问题解决过程
    如何解决CRUD操作中与业务无关的字段赋值
    通过angularjs的directive以及service来实现的列表页加载排序分页
    项目中应用eventbus解决的问题
    统一配置中心
    java枚举与.net中的枚举区别
    列表页的动态条件搜索
  • 原文地址:https://www.cnblogs.com/fanweisheng/p/11327450.html
Copyright © 2011-2022 走看看