zoukankan      html  css  js  c++  java
  • 安装Inotify-tools

    Inotify-tools 可以帮助Liunx快速实现文件同步。

    1. 安装Inotify-tools

    mkdir /soft
    
    chmod 775 /soft
    
    cd /soft
    
    wget http://github.com/downloads/rvoicilas/inotify-tools/inotify-tools-3.14.tar.gz
    
    tar zxvf inotify-tools-3.14.tar.gz
    
    cd inotify-tools-3.14 
    
    ./configure --prefix=/usr && make && su -c 'make install'

    2. 设置系统环境变量,添加软连接

    echo "PATH=/usr/local/inotify/bin:$PATH" >>/etc/profile.d/inotify.sh
    
    source /etc/profile.d/inotify.sh  #使设置立即生效
    
    echo "/usr/local/inotify/lib" >/etc/ld.so.conf.d/inotify.conf
    
    ln -s /usr/local/inotify/include  /usr/include/inotify

    3. 修改系统参数,提高队列性能

    sysctl -a | grep max_queued_events
    
    结果是:fs.inotify.max_queued_events = 16384
    
    sysctl -a | grep max_user_watches
    
    结果是:fs.inotify.max_user_watches = 8192
    
    sysctl -a | grep max_user_instances
    
    结果是:fs.inotify.max_user_instances = 128
    
    修改参数:
    
    sysctl -w fs.inotify.max_queued_events="99999999"
    
    sysctl -w fs.inotify.max_user_watches="99999999"
    
    sysctl -w fs.inotify.max_user_instances="65535"

    4 创建Shell脚本

    rsync -az --delete /data/ test@172.16.120.252::ftp --password-file=/etc/passwd.txt
    
    
    /usr/local/inotify/bin/inotifywait -mrq --timefmt '%d/%m/%y %H:%M' --format '%T %w%f%e' -e close_write,modify,delete,create,attrib,move /data | while read file
    
    do
    
    rsync -az --delete /data/ test@172.16.120.252::ftp --password-file=/etc/passwd.txt
    
    echo "  ${file} was rsynced" >> /tmp/rsync.log 2>&1
    
    done
    ~      

    5 设置同步密码:

    vim /etc/passwd.tx
    
    #写入同步密码

    6 设置同步日志

    vim /tmp/rsync.log
    chmod 775 rsync.log

    7 设置系统启动执行脚本

    vim /etc/rc.d/rc.local  #编辑,在最后添加一行
    
    sh /usr/local/inotify/rsync.sh & #设置开机自动在后台运行脚本
    
    :wq!  #保存退出
  • 相关阅读:
    ie下常见的css兼容问题
    jQuery Easing 使用方法及其图解
    数组中常用的15个方法
    js按位运算符及其妙用
    图片格式知多少
    Linux top命令的用法详解
    Another app is currently holding the yum lock; waiting for it to exit...
    ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this S tatem
    Gitlab与Jenkins结合构成持续集成(CI)环境
    cobbler无人值守安装
  • 原文地址:https://www.cnblogs.com/flyfish2012/p/9244692.html
Copyright © 2011-2022 走看看