环境介绍:

服务器 IP
Server1 192.168.30.131
Server2 192.168.30.132

 

 

 

1、添加主机互信:

  a、添加host文件(在Server1、Server2分别操作):

    [root@localhost ~]#echo -e "192.168.30.131 Server1\n192.168.30.132 Server2" >> /etc/hosts

  b、更改主机名(在Server1、Server2分别操作):

    [root@localhost ~]# sed -i "s/HOSTNAME=.*/HOSTNAME=Server1/g" /etc/sysconfig/network

    [root@localhost ~]# hostname Server1

  c、退出重新登录就会显示出主机名

  d、添加互信

    d1、在主机Server1上操作:

    [root@Server1 ~]# ssh-keygen -t rsa

    [root@Server1 ~]# ssh-copy-id -i /root/.ssh/id_rsa.pub root@Server2

    d2、在主机Server2上操作:

    [root@Server2 ~]# ssh-keygen -t rsa

    [root@Server2 ~]# ssh-copy-id -i /root/.ssh/id_rsa.pub root@Server1

  

2、Unison安装

    unison各种版本下载地址:
    http://www.seas.upenn.edu/~bcpierce/unison//download.html
    unison编译器下载地址:
    http://caml.inria.fr/pub/distrib/ocaml-3.10

    

    2.1、安装编译工具:Objective Caml compiler

    [root@Server1 soft]# cd ocaml-3.10.2+rc1/

    [root@Server1 ocaml-3.10.2+rc1]# ./configure

    [root@Server1 ocaml-3.10.2+rc1]# make world opt

    [root@Server1 ocaml-3.10.2+rc1]# make install && echo OK

    

    2.2、安装Unison:

    [root@Server1 unison-2.13.16]# cd ../unison-2.13.16

    [root@Server1 unison-2.13.16]# make UISTYLE=text THREADS=true

      此时会产生一个错误:

      /bin/sh: etags: command not found

      make[1]: [tags] Error 127 (ignored)
      make[1]: Leaving directory `/soft/unison-2.13.16'

      解决方法:

      yum -y install ctags-etags

    重新编译:

    [root@Server1 unison-2.13.16]# make UISTYLE=text THREADS=true

    [root@Server1 unison-2.13.16]# make install && echo OK

      此时如果报错:

      mv /root/bin//unison /tmp/unison-10301

      mv: cannot stat `/root/bin//unison': No such file or directory
      make: [doinstall] Error 1 (ignored)
      cp unison /root/bin/
      cp: cannot create regular file `/root/bin/': Is a directory
      make: *** [doinstall] Error 1

      解决方法:

      [root@Server2 unison-2.13.16]# mkdir /root/bin

      [root@Server2 unison-2.13.16]# cp unison /root/bin/

    重新编译:

    [root@Server1 unison-2.13.16]# make install && echo OK

    

    2.3、修改配置文件;

    [root@Server1 data]# cat /root/.unison/default.prf

    # Unison preferences file
    root = /data
    root = ssh://root@Server2//data
    #path = www
    #ignore = Path wp-content/tmp
    ignore = Path wp-config.php #忽略wp-config.php文件 相当于rsync的exclude
    #nodeletion = /data
    batch = true
    maxthreads = 300
    #repeat = 1
    owner = true
    group = true
    perms = -1
    fastcheck = false
    sshargs = -C
    xferbycopying = true
    log = true
    logfile = /tmp/unison.log

    2.4、创建同步目录/data

    [root@Server1 ~]# mkdir /data

    [root@Server1 ~]# echo "aa" >> aa.txt

    

    2.5、在Server2上同样操作之上步骤,此处略过

    

    2.6、测试同步

    [root@Server1 ~]# unison -servercmd

    [root@Server1 data]# unison -servercmd=/root/bin/unison
    Contacting server...
    Looking for changes
    Waiting for changes from server
    Reconciling changes

    local Server2
    new file ----> bb.txt
    local : new file modified on 2015-08-19 at 14:42:45 size 5 rw-r--r-- user=0 group=0
    Server2 : absent
    Propagating updates

    UNISON started propagating changes at 14:43:10 on 19 Aug 2015
    [BGN] Copying bb.txt
    from /data
    to //Server2//data
    [END] Copying bb.txt
    UNISON finished propagating changes at 14:43:10 on 19 Aug 2015

    Saving synchronizer state
    Synchronization complete (1 item transferred, 0 skipped, 0 failures)
    [root@Server1 data]#

CentOS 6.5 部署Unison双向同步服务的更多相关文章

  1. Centos下MySQL数据库主从双向同步配置

    MYSQL支持单向.异步复制,复制过程中一个服务器充当主服务器,而一个或多个其它服务器充当从服务器.主服务器将更新写入二进制日志文件,并维护日志文件的一个索引以跟踪日志循环.当一个从服务器连接到主服务 ...

  2. Linux下 Unison 实现文件双向同步

    原创作品,允许转载,转载时请务必以超链接形式标明文章 原始出处 .作者信息和本声明.否则将追究法律责任.http://hx100.blog.51cto.com/44326/612301 一.Uniso ...

  3. linux web服务器静态资源的处理 unison+inotify双向同步

    linux web服务器静态资源的处理 unison+inotify双向同步 http://monkeyzhu.blog.51cto.com/5764358/1324391 简介 unison可以使两 ...

  4. unison + inotify 实现文件实时双向同步部署步骤

    unison + inotify 实现文件实时双向同步部署步骤 一. Unison简介 Unison是Windows.Linux以及其他Unix平台下都可以使用的文件同步工具,它能使两个文件夹(本地或 ...

  5. CentOS 7.2 部署Rsync + Lsyncd服务实现文件实时同步/备份 (一)

    接收端配置: 1.安装rsync yum -y install rsync 2.配置同步模块 1. 编辑同步配置文件 vi /etc/rsyncd.conf 2. 同步模块配置参数 # any nam ...

  6. unison 双向镜像同步

    unison 双向镜像同步   需要 ocaml 依赖工具(3.0.7) 而且需要机器ssh双向互信 ssh 开启互信 # vi in.sh  直接执行 in.sh 就可以了 mkdir ~/.ssh ...

  7. Centos 配置 Mysql 主从双向同步

    配置之前,请先阅读mysql主从复制: Mysql-主从复制 原:  主从环境: 主服务器:192.168.153.130 从服务器:192.168.153.131 1.从数据库创建同步用户,将主数据 ...

  8. SymmetricDS 数据库双向同步开源软件入门

    一句话概括该软件:SymmetricDS是一个文件和数据库同步软件,开源的,支持多主复制,同步时过滤和在异构的网络环境中进行数据转换传输.它支持单向和双向上的多个订阅者,异步的数据复制. 以下是从CS ...

  9. MySQL Dual-Master 双向同步

    本文介绍的Mysql Dual-Master 复制实施方法可能不是最完美.最强大的.但是在我的应用环境下能很好的满足各项需求. 本文基于我们仅仅使用两台MySQL服务器的情况下,但是你会发现文章中介绍 ...

随机推荐

  1. jsoneditor显示Json data

    Git开源地址:https://github.com/josdejong/jsoneditor/blob/master/docs/api.md 1.引用JS文件 <!-- jsoneditor ...

  2. iOS基础 - Quartz 2D绘图的基本步骤

    一.使用Quartz 2D绘图的基本步骤 1) 获取上下文context(绘制图形的地方) 2) 设置路径(路径是用来描述形状的) 3)  将路径添加到上下文 4)  设置上下文属性(设置颜色,线宽, ...

  3. IP 首部检验和算法

    原创博文,转载请注明出处. 在学习TCP/IP 详解的过程中遇到了不止一次的关于检验和的概念,在吸取了他人理解的前提下,我决定用Wireshark 进行抓包分析. 首先我们得知道IP数据包格式 首先把 ...

  4. MSSQL数据库迁移到Oracle

    MSSQL数据库迁移到Oracle 最近要把一个MSSQL数据库迁移到Oracle上面,打算借助PowerDesigner这个软件来实现;今天简单研究一下这个软件的运用;把一步简单的操作步骤记录下来: ...

  5. 服务端套接字类CxServerSocket的使用

    服务端套接字类CxServerSocket的使用 这是一个精练的服务端套接字类,类名.函数名和变量名均采用匈牙利命名法.小写的x代表我的姓氏首字母(谢欣能),个人习惯而已,如有雷同,纯属巧合. CxS ...

  6. 数据访问模式之Repository模式

    数据访问模式之Repository模式   数据访问层无非就是对数据进行增删改查,其中增.删.改等我们可以抽象出来写一个公共的接口或抽象类来定义这些方法,并采用一个基类实现这些方法,这样该基类派生的子 ...

  7. javascript计算字符串中出现最多的字符和个数

    代码如下: <!DOCTYPE html> <html> <head> <meta charset="utf-8" /> <t ...

  8. Git命令行连Github与TortoiseGit 连Github区别

    如果是用git 通过命令行的方式连接github,那么只需要通过命令 $ ssh-keygen -t rsa -C "your_email@youremail.com" 生成rsa ...

  9. 我是如何理解ThreadLocal

    ThreadLocal的概念 ThreadLocal从英文的角度看,可以看成thread和local的组合,就是线程本地的意思,我们都知道,看过jvm内存分配的人都知道在jvm虚拟机中对每一个线程都分 ...

  10. mapreduce框架详解

    hadoop 学习笔记:mapreduce框架详解 开始聊mapreduce,mapreduce是hadoop的计算框架,我学hadoop是从hive开始入手,再到hdfs,当我学习hdfs时候,就感 ...