• Rsync+unison双向文件同步


    1.配置RSYNC服务器的同步源:

    • 基于SSH同步源  
      • rsync -avz /server/rsyncd/*  chen@172.16.23.204:/client/rsyncd
    • 基于RSYNC同步源
      • /etc/rsyncd.conf
        • address = 172.16.23.203
          port 873
          pid file = /var/run/rsyncd.pid
          lock file = /var/run/rsync.lock
          log file = /var/log/rsyncd.log
          read only = false
          auth users = chen
          secrets file = /etc/rsync_user.db
          [share]
          comment = soft
          path=/server/rsyncd
      • /etc/rsyncd_user.db
        • 文件的权限必须是600
          chen:123456
        • 上行同步的时候:nobody必须有权限(setfacl -m u:nobody:rwx  /client/rsyncd)
          •  rsyncd -avz chen@172.16.23.203::share  /client/rsyncd/ 
          •    rsyncd -avz  rsyncd://chen@172.16.23.203/share /client/rsyncd
    • 免验证登录
      • 基于ssh秘钥对登录
        • 密钥对ssh-keygen -t rsa
        • 传到对端:ssh-copy-id 172.16.23.204
      • 基于RSYNCD系统变量
        • RSYNC_PASSWORD=123456

    2.inotify+rsyncd

    • 服务端建立脚本
      • #!/bin/bash
        a="/usr/local/bin/inotifywait -mrq -e create,delete /server/rsyncd" b="/usr/bin/rsync -avz /server/rsyncd/* 172.16.23.204:/client/rsyncd" $a | while read diretory event file do $b done

          执行 bash a.sh & 放到后台执行

    3.inotify+unison

      安装软件:inotify-tools-3.14.tar.gz   ocaml-3.10.0.tar.gz  unison-2.13.16.tar.gz

      • tar zxvf inotify-tools-3.14.tar.gz 
        • ./configure && make && make install
      • tar -zxvf ocaml-3.10.0.tar.gz  
        • ./configure
        • make world opt
        • make install
      • tar zxvf   unison-2.13.16.tar.gz
        • cd unison-2.13
        • make UISTYLE=text THREADS=true STATIC=true
        • cp unison /usr/local/bin
      • 建立脚本
        • #!/bin/bash
          a="/usr/local/bin/inotifywait -mrq -e create,delete /server1"
          b="/usr/bin/unison -batch /server1  ssh://172.16.23.204//server2"
          $a | while read diretory event file
          do
                  $b
          done
          

            

  • 相关阅读:
    【Java例题】8.1手工编写加法器的可视化程序
    【Java例题】7.6文件题3-文本文件统计
    【Java例题】7.4 文件题1-学生成绩排序
    【Java例题】7.5 文件题2-学生成绩统计
    【Java例题】7.3 线程题3-素数线程
    Map
    sql常用函数
    面向对象的理解
    attr
    webService之wsdl文档
  • 原文地址:https://www.cnblogs.com/powpoia/p/6789523.html
Copyright © 2020-2023  润新知