• centos 7 安装 rsync 和 安装 rsync inotify


    rsync分为master 和 slave

    1)在master上

    mkdir -p /usr/local/shell/
    cd /usr/local/src
    wget http://download.zhufunin.com/rsync-3.1.2.tar.gz
    tar -zxf rsync-3.1.2.tar.gz
    cd rsync-3.1.2
    ./configure --prefix=/usr/local/rsync
    make && make install

    配置文件rsync.passwd

    cd /usr/local/rsync
    echo "fzz0aocKeJ" > /usr/local/rsync/rsync.passwd
    chmod 600 /usr/local/rsync/rsync.passwd

    下面是主动同步的脚本

    脚本用法/usr/local/rsync/rsync.sh 192.168.1.100

    cd /usr/local/rsync/
    touch rsync.sh
    chmod 755 rsync.sh

    #!/bin/sh
    #脚本路径 /usr/local/rsync/rsync.sh
    host=$1
    src=/usr/local/nginx/conf/autoconfig/
    desc=nginxconfig
    user=root
    /usr/local/rsync/bin/rsync -l --port 8730 --timeout 10 -vzrtopgP --delete --password-file=/usr/local/rsync/rsync.passwd $src $user@$host::$desc

    下面的是设置rsync inotify

    cd /usr/local/rsync/
    touch inotify_rsync.sh
    chmod 755 inotify_rsync.sh

    #!/bin/bash
    
    slavelist=(192.168.1.100 192.168.1.101 192.168.1.102 192.168.1.103)
    src=/usr/local/nginx/conf/autoconfig/
    des=nginxconfig
    user=root
    
    
    /usr/local/inotify/bin/inotifywait -mrq --timefmt '%d/%m/%y %H:%M' --format '%T %w%f%e' -e modify,delete,create,attrib $src | while read files
    do
        for host in `echo ${slavelist[*]}`; do
            /usr/local/rsync/bin/rsync -l --port 8730 --timeout 10  -vzrtopgP --delete --password-file=/usr/local/rsync/rsync.passwd $src $user@$host::$des >/dev/null 2>&1
        done
    done

     后台运行rsync inotify

    nohup /usr/local/rsync/inotify_rsync.sh &

     2)在slave上

    安装rsync

    yum install gcc perl wget -y 
    cd /usr/local/src/
    wget http://download.zhufunin.com/rsync-3.1.2.tar.gz
    tar -zxf rsync-3.1.2.tar.gz
    cd rsync-3.1.2
    ./configure --prefix=/usr/local/rsync
    make && make install

    配置文件 rsyncd.passwd

    cd /usr/local/rsync
    echo "root:fzz0aocKeJ" > /usr/local/rsync/rsyncd.passwd
    chmod 600 /usr/local/rsync/rsyncd.passwd

    配置文件rsyncd.conf

    #文件路径/usr/local/rsync/rsyncd.conf
    uid = root
    gid = root
    use chroot = no
    max connections = 10
    strict modes = yes
    hosts allow = ##_masterIp_##
    port = 8730
    pid file = /var/run/rsyncd.pid
    lock file = /var/run/rsync.lock
    log file = /var/log/rsyncd.log
    ignore errors
    read only = false
    list = false
    auth users = root
    secrets file = /usr/local/rsync/rsyncd.passwd
    
    [nginxconfig]
    path = /usr/local/nginx/conf/autoconfig

    slave需要一直运行等待主控的rsync请求

    /usr/local/rsync/bin/rsync --port 8730 --daemon --config=/usr/local/rsync/rsyncd.conf
  • 相关阅读:
    Hadoop生态圈-Azkaban实战之Command类型执行指定脚本
    Hadoop基础-MapReduce的排序
    Hadoop生态圈-Azkaban实战之Command类型多job工作流flow
    Hadoop生态圈-Azkaban部署实战
    SHELL脚本编程循环篇-until循环
    Hadoop生态圈-Kafka配置文件详解
    Hadoop生态圈-使用Kafka命令在Zookeeper中对应关系
    Hadoop生态圈-Kafka的旧API实现生产者-消费者
    Apache Kafka运维常用命令
    企业级Apache Kafka部署实战篇
  • 原文地址:https://www.cnblogs.com/faberbeta/p/13138695.html
Copyright © 2020-2023  润新知