您的位置:首页 > 运维架构 > Linux

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

2016-12-13 16:16 537 查看

前言

网站如何从一个服务器上传到另一个服务器总归是一个问题,有幸接触到这个问题。这里就推荐用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“{src}" "ssh://root@ip:服务器开发的端口号/{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

“`
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: