192.168.0.1 CM
192.168.0.2 CX
1.ssh无密码访问打通(步骤略)
2. 安装 ocaml
wget http://caml.inria.fr/pub/distrib/ocaml-3.12/ocaml-3.12.1.tar.gz
tar -zxvf ocaml-3.12.1.tar.gz
cd ocaml-3.12.1
./configure
make world opt
make install
3.安装Unison
tar -zxvf unison-2.40.63.tar.gz
cd unison-2.40.63
make UISTYLE=text
make install
安装过程中出现以下错误提示:
make[1]: Leaving directory `/usr/local/src/unison-2.40.63'
mv /root/bin//unison /tmp/unison-10558
mv: 无法 stat “/root/bin//unison”: 没有那个文件或目录
make: [doinstall] 错误 1 (忽略)
cp unison /root/bin/
cp: 无法创建一般文件“/root/bin/”: 是一个目录
make: *** [doinstall] 错误 1
解决办法:
创建 /root/bin 目录并将unison拷贝过去
cp unison /root/bin/
4.在两台机器上分别执行:
unison /usr/test/ ssh://admin@对方IP:ssh端口 //usr/test/
5.分别都修改配置文件:
vim /home/admin/.unison/default.prf
#Unison preferences file
root = /usr/test
root = ssh://root@对方IP:ssh端口 //home/admin/test/
#force =
#ignore =
batch = true
#repeat = 1
#retry = 3
owner = true
group = true
perms = -1
fastcheck = false
rsync = false
sshargs = -C
xferbycopying = true
6.测试是否成功:
在CM机器test目录下创建一个文件 执行unison命令 在CX机器的test目录下也出现该文件 成功
7.设置crontab每隔一秒执行一次同步命令
在CM机器上的/usr/shell 目录下 vim crontab.sh
#!/bin/bash
step=1
for (( i = 0; i < 60; i=(i+step) )); do
$(/usr/local/bin/unison)
sleep $step
done
exit 0
保存退出后 在该机器上执行 crontab -e 输入:
# m h dom mon dow command
* * * * * /usr/shell/crontab.sh
保存退出
8.搭建完成 进行测试(PS:效率没有达到想象中那样高,不过用于网站的1M以下的缩略图同步还可以)
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/29754888/viewspace-1613350/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/29754888/viewspace-1613350/