• centos6.5-rsync+inotify


    一、目的

       通过监控192.168.3.10的目录,实现实时同步。

    实验环境

    centos1       192.168.3.10

    centos2       192.168.3.11

     

    二、配置

    centos1

    service iptables stop

     

    创建监控目录

    mkdir /abc

    1.安装intoify

    tar xf inotify-tools-3.14.tar.gz

    cd inotify-tools-3.14

    ./configure

    make && make install

    2.调整系统文件

    vim /etc/sysctl.conf

    增加以下几行内容

    fs.inotify.max_queued_events = 16384

    fs.inotify.max_user_instances = 1024

    fs.inotify.max_user_watches = 1048576

    sysctl -p    #生效配置

    3.编写触发脚本

    vim rsync.sh

    #!/bin/bash
    inotify_cmd="inotifywait -mrq -e modify,create,move,attrib,delete /abc/"
    rsync_cmd="rsync -avzP --delete /abc/ rsync://192.168.3.11/wwwroot"
    $inotify_cmd | while read DIRECTORY EVENT FILE
    do
        $rsync_cmd &> /dev/null
    done

    4、配置centos2

    service iptables stop

     

    创建同步目录

    mkdir /abc

    chmod -R  777 /abc

     

    创建rsync配置文件

    vim /etc/rsyncd.conf

    uid = nobody

    gid = nobody

    use chroot = no

    address = 192.168.3.11

    log file = /var/log/rsyncd.log

    pid file = /var/run/rsyncd.pid

    host allow =192.168.3.10

     

    [wwwroot]

    path = /abc

    comment = abc

    read only = no

     

     

    启动rsync

    rsync --daemon

     

    测试

    启动脚本

    sh rsync.sh

     

    在centos1的abc目录下创建目录或是文件,查看centos2的abc目录下是否有文件

     

  • 相关阅读:
    关于jQuery的两对小括号()()的说明
    高效能 DBA 的七个习惯
    Div+CSS网站设计的优点
    .Net上传图片按比例自动缩小或放大
    SEO草根技术基础—DIV+CSS
    asp.net连接Mysql(connector/net 5.0)
    大型网站(高访问、海量数据)技术架构
    ISO Latin1字符集
    CuteEditor学习总结技巧
    Craigslist 的数据库架构
  • 原文地址:https://www.cnblogs.com/pangbing/p/6534519.html
Copyright © 2020-2023  润新知