linux双向同时传输文件程序,linux文件双向同步(unison)

Linux文件双向同步

1、        下载unison,跟ocaml编译器,下载地址:

http://caml.inria.fr/pub/distrib/ocaml-3.10/;http://www.seas.upenn.edu/~bcpierce/unison//download/releases/stable/

2、安装ocaml:

tar -xzvf ocaml-3.10.0.tar.gz

cd ocaml-3.09.3./configuremakeworld optmakeinstall

检查ocaml是否安装成功:

Ocaml -version

3、安装unison:

tar -xzvf unison-2.40.63.tar.gz

cd unison-2.40.63

make UISTYLE=text

mkdir /root/bin/

cp unison /root/bin/

cp ./unison /usr/bin/

查看unison是否安装成功:

Unison –version

4、配置default.prf文件(/root/.unison/):

# Unison preferences file

root = /opt/unison/test/

root = ssh://root@10.108.74.234//opt/unison/test/

#force =

#ignore =

batch = true

#repeat = 1

#retry = 3

owner = true

group = true

perms = -1

fastcheck = false

rsync = false

sshargs = -C

xferbycopying = true

log = true

logfile = /opt/unison/unison.log

5、配置双机信任(登录对方,不用密码)

/root/增加目录.ssh:

Mkdir .ssh

Chmod 700 .ssh

ssh-keygen -t rsa

Generating public/private rsa key pair.

Enter file in which to save the key (/root/.ssh/id_rsa):

Enter passphrase (empty for no passphrase):

Enter same passphrase again:

Your identification has been saved in /root/.ssh/id_rsa.

Your public key has been saved in /root/.ssh/id_rsa.pub.

The key fingerprint is:

17:e4:7c:79:8d:a0:00:3b:d9:f7:7a:56:f3:ac:54:4d oracle@gsgatzhapp1

在提示保存私钥(key)和公钥(public key)的位置时,使用默认值。

如果需要私钥密码(passphrase),则输入一个私钥密码(如果使用私钥密码,使用 ssh 执行远程命令时需要输入私钥密码,因此,本案例中未使用私钥密码),因此,直接回车即可。

cd ~/.ssh

ssh 10.178.1.132 cat /root/.ssh/id_rsa.pub >> authorized_keys

6、安装inotify(http://inotify-tools.sourceforge.net)tar xvf inotify-tools-3.14.tar.gz

cdinotify-tools-3.14

./configure

Make

make install

7、(运行脚本inotify.sh)inotify脚本:

#/bin/bash

UNISON=`ps -ef |grep -v grep|grep -c inotifywait`

if [ ${UNISON} -lt 1 ]

then

/usr/bin/inotifywait -mrq -e create,delete,modify,move $src2 |while read line

do

/usr/bin/unison -batch

echo -n "$line " >> /var/log/inotify/inotify$(date+%u).log

echo ` date +%F\ %T " " -f1-4` >>/var/log/inotify/inotify$(date +%u).log

done

fi

6、另外一台linux安装同样的步骤安装。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值