CentOS 6.5 部署Unison双向同步服务 环境介绍:
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各种版本下载地址:
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) 解决方法: 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 解决方法: [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
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
local Server2
|