zoukankan      html  css  js  c++  java
  • 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
  • 相关阅读:
    oracle行转列
    中国软件开发标准各项文档模板下载(附模版)
    熙熙SQLCE类熙熙
    用反射技术实现将泛型集合类中的数据导出成EXCEL
    WinCE 5.0 中文模拟器SDK(VS2005, VS2008)的配置
    OpenFrameworks x kinect x Android
    Ubuntu11.04软件源增强版
    信号量与自旋锁
    android 编写命令行测试程序
    在 Ubuntu 上换用 OSS4 声音系统
  • 原文地址:https://www.cnblogs.com/sharesdk/p/11141783.html
Copyright © 2011-2022 走看看