zoukankan      html  css  js  c++  java
  • inotify+rsync实时同步服务部署

    环境:服务端 192.168.6.30(安装 rsync) /data/share

      :客户端 192.168.6.38(安装 inotufy+rsync)/nfsbackup

    主流程:https://www.cnblogs.com/clsn/p/7707822.html#auto_id_28

        

    客户端安装 inotify

    下面开始安装inotify-tools
    [root@static-img ~]# yum install make gcc gcc-c++                          #安装编译工具
    [root@static-img ~]# cd /usr/local/src
    [root@static-img src]# wget http://github.com/downloads/rvoicilas/inotify-tools/inotify-tools-3.14.tar.gz
    [root@static-img src]# tar zxvf inotify-tools-3.14.tar.gz
    [root@static-img src]# cd inotify-tools-3.14
    [root@static-img inotify-tools-3.14]# ./configure --prefix=/usr/local/inotify
    [root@static-img inotify-tools-3.14]# make && make install

    发现已经成功安装inotify-tools了
    [root@static-img inotify-tools-3.14]# ll -d /usr/local/inotify/
    drwxr-xr-x 6 root root 4096 Oct 26 12:01 /usr/local/inotify/

    设置系统环境变量
    [root@static-img ~]# vim /etc/profile
    ......
    export PATH=$PATH:/usr/local/inotify/bin
    [root@static-img ~]# source /etc/profile

    添加库文件
    [root@static-img ~]# vim /etc/ld.so.conf
    /usr/local/inotify/lib
    [root@static-img ~]# ldconfig

    修改inotify默认参数(inotify默认内核参数值太小)
    查看系统默认参数值
    [root@static-img ~]# sysctl -a | grep max_queued_events
    fs.inotify.max_queued_events = 16384
    [root@static-img ~]# sysctl -a | grep max_user_watches
    fs.inotify.max_user_watches = 8192
    [root@static-img ~]# sysctl -a | grep max_user_instances
    fs.inotify.max_user_instances = 128

    修改参数:
    [root@static-img ~]# sysctl -w fs.inotify.max_queued_events="99999999"
    [root@static-img ~]# sysctl -w fs.inotify.max_user_watches="99999999"
    [root@static-img ~]# sysctl -w fs.inotify.max_user_instances="65535"

    脚本

    #!/bin/bash
    Path=/data/share
    backup_Server=192.168.6.30
    /usr/local/inotify/bin/inotifywait -mrq --format '%w%f' -e create,close_write,delete /data/share  | while read line  
    do
        if [ -f $line ];then
            rsync -az $line --delete rsync_backup@$backup_Server::nfsbackup --password-file=/etc/rsync.password
        else
            cd $Path &&
            rsync -az ./ --delete rsync_backup@$backup_Server::nfsbackup --password-file=/etc/rsync.password
        fi
    done
  • 相关阅读:
    laravel 安装完成后安装 vendor 目录
    requires php ~7.1 -> your PHP version (7.0.18) does not satisfy that requirement
    查看laravel版本
    git update-index --assume-unchanged
    Git 取消跟踪已版本控制的文件(亲测可行)
    git把某个文件去除版本控制
    git如何移除某文件夹的版本控制
    git如何移除某文件的版本控制
    git 教程
    Git branch && Git checkout常见用法
  • 原文地址:https://www.cnblogs.com/shiina-ringo/p/9963231.html
Copyright © 2011-2022 走看看