首页 > 代码库 > 双向同步使用unison

双向同步使用unison

1、实现两台服务器的/web目录数据同步(任何一台数据修改两台服务器数据时时保持一致)

 

#双向同步使用unison

 安装unison软件程序

yum install -y ocaml ctags-etags.x86_64 glibc-static glib* inotify-tools

#从官网下载unison

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

  tar zxvf unison-2.48.3.tar.gz    #解压

  make UISTYPLE=text THREADS=true STATIC=true  #安装

  cp unison /usr/local/bin/          #将命令移动到bin下

 

ssh-keygen  #创建信任密钥

ssh-copy-id -i /root/.ssh/id_rsa.pub root@192.168.1.148 #将公钥给目的主机

 

mkdir .unison #注意这个目录在用户家目录下root用户为/root/.unison

在vi default.prf中写

 # Unison preferences file

root = /web

root = ssh://root@192.168.1.148//web

batch = true

sshargs = -C

fastcheck=true

repeat=1

  • owner=true

group=true

perms=-1

logfile = /root/.unison/unison.log

unison default.prf  #执行

 

执行后会一直占用终端。。。解决可以用nohup或者screen。。

 

技术分享

 

技术分享

技术分享

技术分享

 

双向同步使用unison