• unison 双向镜像同步


    unison 双向镜像同步   需要 ocaml 依赖工具(3.0.7)

    而且需要机器ssh双向互信

    ssh 开启互信 # vi in.sh  直接执行 in.sh 就可以了

    mkdir ~/.ssh
    chmod 700 .ssh/
    /usr/bin/ssh-keygen -t rsa
    cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys
    chmod 600 ~/.ssh/authorized_keys

     然后拷贝  .ssh/authorized_keys 中秘钥到各自的 .ssh/authorized_keys 文件中。

    这样都可以进行无密码验证登陆。

    示例:
    ssh -p 2233 root@172.16.2.26
    测试文件传输:
    scp -P 2233 /data/in.sh root@172.16.2.16:/data

    下载安装

    wget http://www.seas.upenn.edu/~bcpierce/unison//download/releases/unison-2.32.52/unison-2.32.52.tar.gz
    wget http://caml.inria.fr/pub/distrib/ocaml-3.10/ocaml-3.10.2.tar.gz
    解压缩 编译
    tar -xf ocaml-3.10.2.tar.gz 
    mv ocaml-3.10.2 /usr/local/ocaml
    /usr/local/ocaml/
    ./configure 
    make world opt
    make install
    
    tar
    -xf unison-2.32.52.tar.gz mv unison-2.32.52 /usr/local/unison cd ../unison/ make UISTYLE=text cp unison /usr/local/bin 拷贝执行文件到 系统默认执行目录 cp unison /usr/local/bin

    配置同步策略文件 test.prf 测试;

    default.prf   默认在 /root/.unison/default.prf 

    (默认同步策略文件是 default.prf  ;直接执行 unison 命令 默认是加载 default.prf 

    [root@localhost ~]# vi test.prf
    
    root = /data/wwwroot/img
    root = ssh://root@172.16.2.26//data/wwwroot/upload
    # path = upload
    # 指定同步目录
    # path = log
    # igonre = 
    # 排除目录
    batch = true
    owner = true
    group = true
    perms = -1
    maxthreads = 100
    # 最大线程
    fastcheck = true
    # true 是通过时间同步
    fastcheck = false
    # false 通过内容
    rsync = false
    sshargs = -C
    xferbycopying = true
    confirmbigdel = false
    log = true
    logfile = /var/log/unison/unison.log
    # 日记记录文件

    同步执行 

    直接执行  unison test  本机16和同步机器26 便可以进行目录同步

    注意如果单方服务进行新增删除,则也会进行同步删除。

    定时同步:


    cat 1
    .sh #!/bin/bash # unison /root/.unison/test.prf /usr/local/bin/unison 添加定时任务 每5秒进行同步 crontab -e # * * * * * sleep 5; sh /opt/1.sh &> /dev/null
  • 相关阅读:
    iOS实时查看App运行日志
    Jmeter-使用Ultimate Thread Group插件来设置负载场景
    Flask使用Flask-SQLAlchemy操作MySQL数据库
    使用requests库提交multipart/form-data 格式的请求
    spark 性能调优(一) 性能调优的本质、spark资源使用原理、调优要点分析
    一、spark错误
    sqoop 补充
    Hbase—— rowkey 过滤器(rowfilter)
    spark 调优——基础篇
    scala 的安装 与 IDEA安装使用
  • 原文地址:https://www.cnblogs.com/sharesdk/p/11141783.html
Copyright © 2020-2023  润新知