zoukankan      html  css  js  c++  java
  • 部署inotify 结合rsync

    <pre name="code" class="sql">1.  部署
    
    v-lhb-db01:/usr/local# tar xvf inotify-tools.tar 
    inotify-tools/
    
    或者 源码包安装:
    # tar xzvf inotify-tools-3.14.tar.gz
    # cd inotify-tools-3.13
    # ./configure  --prefix=/usr/local/inotify
    # make
    # make install
    
    2.
    
     /usr/local/inotify-tools/bin/inotifywait -mrq --timefmt %Y/%m/%d %H:%M --format %T %w%f%e -e close_write,create,move,delete,modify /var/www/zjzc-web-frontEnd/news/
    
    
    v-lhb-db01:/usr/local# cat rsync_inotify.sh 
    #!/bin/bash
    
    INOTIFY_RSYNC_LOG_DIR=/var/log/inotify_rsync
    if [ -d "$INOTIFY_RSYNC_LOG_DIR" ]
    then
            :
    else
            mkdir -p $INOTIFY_RSYNC_LOG_DIR
    fi
    
    INOTIFY_RSYNC_LOG_FILE=$INOTIFY_RSYNC_LOG_DIR/inotify_rsync_contract.log
    echo >$INOTIFY_RSYNC_LOG_FILE
    
    INWT=/usr/local/inotify-tools/bin/inotifywait
    RSYNC=/usr/local/rsync/bin/rsync
    
    SRC_FS1=/var/www/zjzc-web-frontEnd/news/
    
    DES_HOST1=192.168.32.119
    DES_USER=root
    
    DES_MODULE1=contract
    
    $INWT -mrq --timefmt '%Y/%m/%d %H:%M' --format '%T %w%f%e' -e close_write,create,move,delete,modify $SRC_FS1 | while read FILES 
    do
            $RSYNC -avz  --password-file=/etc/rsyncd.secrets  $SRC_FS1 ${DES_USER}@${DES_HOST1}::${DES_MODULE1} 
            echo "$FILES  was rsynced"  >>$INOTIFY_RSYNC_LOG_FILE 2>&1
    done
    v-lhb-db01:/usr/local# mkdir -p /var/log/inotify_rsync
    
    
    
    v-lhb-db01:/usr/local# sh ./rsync_inotify.sh 
    sending incremental file list
    ./
    4
    
    sent 114 bytes  received 30 bytes  288.00 bytes/sec
    total size is 96  speedup is 0.67
    sending incremental file list
    
    sent 66 bytes  received 8 bytes  49.33 bytes/sec
    total size is 96  speedup is 1.30
    sending incremental file list
    
    sent 66 bytes  received 8 bytes  13.45 bytes/sec
    total size is 96  speedup is 1.30
    sending incremental file list
    4
    
    sent 111 bytes  received 33 bytes  288.00 bytes/sec
    total size is 93  speedup is 0.65
    sending incremental file list
    
    sent 66 bytes  received 8 bytes  148.00 bytes/sec
    total size is 93  speedup is 1.26
    sending incremental file list
    
    sent 66 bytes  received 8 bytes  148.00 bytes/sec
    total size is 93  speedup is 1.26
    


    
                                        
    
  • 相关阅读:
    获取股票行情API 接口
    使用百度地图来展示自定义的GPS点,用pyechart 框架实例
    C 语言基础笔记
    GPS 测试汇总和python GPS 导航地图实现
    用python 来炒股二 BeautifulSoup爬虫信息新闻文章
    Python tkinter 笔记 [pack,place,grid 布局管理]
    RSS 订阅精选 2020
    用python来炒股<三> 炒股交易系统(法则)
    使用python 来实现炒股
    鼠须管输入法的配置介绍
  • 原文地址:https://www.cnblogs.com/hzcya1995/p/13351693.html
Copyright © 2011-2022 走看看