centos配置ocaml及unison进行双向文件同步搭建

前言

网站如何从一个服务器上传到另一个服务器总归是一个问题,有幸接触到这个问题。这里就推荐用ocaml及unison吧。

ocaml

ocaml的配置

我用的是centos7,然而,这个似乎是fedora的分支,所以直接用yum install ocaml安装了。

这里写图片描述

配置unison

这里重点说一说unison,你可以直接用yum install unison,可以成功的。。然而,当你执行同步脚本时候【同步脚本稍后给出来,免得没办法测试】
可能会出现这个问题:
这里写图片描述

两台机器的unison版本不一致。。我们的服务器版本是2.4.8,而yum install的比较旧,所以只能手动编译了。
首先请找到适合你自己版本的unison。地址如下:
unison地址

稳定版本地址:
这里写链接内容

这里写图片描述

而我需要的刚好就是稳定版本的,所以直接用这个来安装了:

http://www.seas.upenn.edu/~bcpierce/unison//download/releases/stable/unison-2.48.4.tar.gz
wget http://www.seas.upenn.edu/~bcpierce/unison//download/releases/stable/unison-2.48.4.tar.gz

tar -zxvf unison-2.48.4.tar.gz
cd unison-2.48.4
make UISTYLE=text
make install

大家按照下面来做吧

Install unison

1 Requirements

To install unison you will need the following:

a installed and supported operating system (e.g. CentOS 7.x)
root-access
access to http://www.seas.upenn.edu
a fast internet connection
2 Preliminary note

most of this is taken from

https://www.digitalocean.com/community/questions/install-unison-in-centos-7
you may consult the official homepage

http://www.cis.upenn.edu/~bcpierce/unison
3 Install

As of 2015-01-12 unison isn't listed in any CentOS-7 repository we build it from source

yum install ocaml ocaml-camlp4-devel ctags ctags-etags

cd ~
wget http://www.seas.upenn.edu/~bcpierce/unison//download/releases/stable/unison-2.48.3.tar.gz
tar xvfz unison-2.48.3.tar.gz
cd unison-2.48.3
make

sudo cp -v unison /usr/bin

cd ~
rm -fr unison*
4 Usage

Basic usage:

unison /mnt/dat /media/ext_HDD
if there is some Microsoft-Filesystem involved you maybe won't sync the file-permissions

unison /mnt/dat /media/ext_HDD -perms 0

总结

//--先安装这些
yum install ocaml ocaml-camlp4-devel ctags ctags-etags

然后

wget http://www.seas.upenn.edu/~bcpierce/unison//download/releases/stable/unison-2.48.4.tar.gz

tar -zxvf unison-2.48.4.tar.gz
cd unison-2.48.4
``

接着:
make

## 附带-同步脚本 ##

!/bin/bash 同步前端nodejs - 测试库上面

src=”本机的项目源码地址”
target=”远程目标目录”
ips=(服务器ip地址)
for ip in ips[]dounison i p s [ ∗ ] d o u n i s o n “ {src}" "ssh://root@ ip:/ i p : 服 务 器 开 发 的 端 口 号 / {target}” \
-force=”${src}” \
-ignore=”Path logs” \
-ignore=”Path statsvn” \
-ignore=”Path node_modules” \
-ignore=”Path uploads” \
-ignore=”Name ServerConf.js” \
-ignore=”Name .svn” \
-ignore=”Name FUpload.swf” \
-ignore=”Name app.js” \
-batch=true \
-owner=false \
-group=false \
-perms=-1 \
-fastcheck=false \
-rsync=false \
-sshargs=-C \
-xferbycopying=true \
-log=true \
-logfile=”/var/log/unison/你的日志文件名字”
done
“`

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值