Unison优点有很多,支持跨平台,同步的算法和Rsync算法类似,唯一震撼我的是可双向同步文件的这个功能,还可以本地两个文件夹的同步。
1.安装编译器Ocaml
下载地址:http://caml.inria.fr/pub/distrib/ocaml-3.10
cd ocaml-3.10 ./configure make world opt make install
2.安装unison
下载地址:http://www.seas.upenn.edu/~bcpierce/unison//download.html
tar -xzvf unison-2.48.4.tar.gz cd unison-2.48.4.tar.gz/src make UISTYPE=text make install cp ./unison /usr/local/bin/
3.配置互信
node1: [[email protected]~]# mkdir ~/.ssh [[email protected]~]# chmod 700 ~/.ssh [[email protected]~]# ssh-keygen -t rsa [[email protected]~]# ssh-keygen -t dsa node2: [[email protected] node2 ~]# mkdir ~/.ssh [[email protected] node2 ~]# chmod 700 ~/.ssh [[email protected] node2 ~]# ssh-keygen -t rsa [[email protected] node2 ~]# ssh-keygen -t dsa 切换回 node1,接着执行: [[email protected] node1~]# cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys [[email protected] node1~]# cat ~/.ssh/id_dsa.pub >> ~/.ssh/authorized_keys 提示:下列命令会提示你输入node2的 root 密码,按照提示输入即可,如果,失败可重新尝试执行命令。 node1: [[email protected] node1~]# scp ~/.ssh/authorized_keys node2:~/.ssh/authorized_keys
node2: [[email protected] node2 ~]# cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys [[email protected] node2 ~]# cat ~/.ssh/id_dsa.pub >> ~/.ssh/authorized_keys [[email protected] node2 ~]# scp ~/.ssh/authorized_keys bzfgdb1:~/.ssh/authorized_keys 确保 2 个 node 都有相互的结点信息。两机相互执行(以下红色部分非常重要必须执行) node1: [[email protected] node1~]# ssh node1date [[email protected] node1~]# ssh node2 date node2: [[email protected] node2 ~]# ssh node1date [[email protected] node2 ~]# ssh node2 date
4.Unison 使用
a)
unison /opt/html/ ssh://[email protected]//opt/html
本地的/opt/html和对端/opt/html作比较并进行同步
b)
unison /opt/html/ ssh://[email protected]//opt/html -batch
-batch参数全自动模式,不需要与客户端作答
c)
unison /opt/html/ /opt/src/
支持本地两个文件夹的双向同步
时间: 2024-10-29 00:59:07