• 非常好用的sersync同步工具


      作者:邓聪聪

      常用同步工具sync的进阶软件

      服务端的配置:

    uid = rsync
    gid = rsync
    port = 873
    use chroot = on
    max connections = 200
    timeout = 120
    lock file = /var/run/rsyncd.lock
    log file = /var/log/rsyncd.log
    read only = false
    list = false
    fake super = yes
    hosts allow = 172.16.16.0/24
    hosts deny = 0.0.0.0/32
    secrets file = /etc/rsyncd.password
    auth users = rsync
    
    [backup]
    path = /data

     客户端在推送时,有这样一个报错,但不影响文件的传输:

    [root@172 data]# rsync -avzP a.txt backup@172.16.16.10::backup
    Password: 
    sending incremental file list
    a.txt
                  8 100%    0.00kB/s    0:00:00 (xfr#1, to-chk=0/1)
    rsync: chgrp "/.a.txt.llMDKO" (in backup) failed: Operation not permitted (1)    ###无法操作
     
    sent 100 bytes  received 125 bytes  90.00 bytes/sec
    total size is 8  speedup is 0.04
    rsync error: some files/attrs were not transferred (see previous errors) (code 23) at main.c(1178) [sender=3.1.2]

    解决后:

    [root@172 data]# rsync -avzP /root/data/b.txt rsync@172.16.16.10::backup
    Password: 
    sending incremental file list
    b.txt
                  6 100%    0.00kB/s    0:00:00 (xfr#1, to-chk=0/1)
    
    sent 98 bytes  received 43 bytes  56.40 bytes/sec
    total size is 6  speedup is 0.04

     源同步服务器上,同步本端目录内容到目标服务器,用sersync:

      将 sersync2.5.4_64bit_binary_stable_final.tar.gz 文件解压后(主要用sersync、inotify)

    [root@ansible-server ~]# cd sersync/
    [root@ansible-server sersync]# ll
    total 1960
    drwxr-xr-x.  2 root  root       6 Mar  8 03:07 GNU-Linux-x86
    drwxrwxrwx.  5 rsync rsync   4096 Mar 14  2010 inotify-tools-3.14
    -rw-r--r--.  1 root  root  358772 Mar  7 10:31 inotify-tools-3.14.tar.gz
    -rw-r--r--.  1 root  root   10838 Mar  7 10:31 README.md
    drwxrwxr-x. 10 root  root    4096 Mar  7 11:16 rsync-3.1.1
    -rw-r--r--.  1 root  root  890124 Mar  7 10:31 rsync-3.1.1.tar.gz

      为了方便管理调整目录结构:

    [root@ansible-server sersync]# tree /usr/local/sersync/
    /usr/local/sersync/
    ├── bin
    │   └── sersync
    ├── conf
    │   ├── conf-www.xml
    │   ├── confxml.xml
    │   └── confxml.xml-bak
    └── log
        ├── rsync_fail_log
        └── rsync_fail_log-www
    mv GNU-Linux-x86/sersync /usr/local/sersync/bin/
    mv GNU-Linux-x86/confxml.xml /usr/local/sersync/conf
    [root@ansible-server sersync]# cat /usr/local/sersync/conf/confxml.xml
    <?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">
            <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>
    
        <sersync>
            <localpath watch="/tmp">   #需要监听的本地目录
                <remote ip="172.16.16.10" name="backup"/>  #目标及目标路径的模块
                <!--<remote ip="192.168.8.39" name="tongbu"/>-->
                <!--<remote ip="192.168.8.40" name="tongbu"/>-->
            </localpath>
            <rsync>
                <commonParams params="-artuz"/>
                <auth start="true" users="rsync" passwordfile="/etc/rsync.pwd"/>  #目标服务器的rsync认证用户及密码,本端保存的认证密码文件
                <userDefinedPort start="true" port="873"/><!-- port=874 -->  #监听端口
                <timeout start="false" time="100"/><!-- timeout=100 -->
                <ssh start="false"/>
            </rsync>
            <failLog path="/usr/local/sersync/log/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>
    
        <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>
    
        <plugin name="socket">
            <localpath watch="/opt/tongbu">
                <deshost ip="192.168.138.20" port="8009"/>
            </localpath>
        </plugin>
        <plugin name="refreshCDN">
            <localpath watch="/data0/htdocs/cms.xoyo.com/site/">
                <cdninfo domainname="ccms.chinacache.com" port="80" username="xxxx" passwd="xxxx"/>
                <sendurl base="http://pic.xoyo.com/cms"/>
                <regexurl regex="false" match="cms.xoyo.com/site([/a-zA-Z0-9]*).xoyo.com/images"/>
            </localpath>
        </plugin>
    </head>
  • 相关阅读:
    大型网站技术架构(八)--网站的安全架构(转)
    大型网站技术架构(七)--网站的可扩展性架构(转)
    大型网站技术架构(六)--网站的伸缩性架构(转)
    大型网站技术架构(五)--网站高可用架构(转)
    大型网站技术架构(四)--网站的高性能架构(转)
    HTML中的空元素
    jetbrains 全家桶,Pycharm激活码,PHPStorm激活码,WebStorm激活码,Goland激活码,Clion激活码,intellij idea激活码(亲测可用)
    legend3---22、通过html,可以使php、vue、jquery、js达成完美的配合
    IlluminateDatabaseQueryException : SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was too long; max key length is 1000 bytes
    template cannot be keyed. Place the key on real elements instead.
  • 原文地址:https://www.cnblogs.com/dengcongcong/p/10494524.html
Copyright © 2020-2023  润新知