一、基础安装
# tar xvzf ocaml-4.00.1.tar.gz
# ./configure -prefix /usr/local
# make world.opt
# make install


# tar xvzf unison-2.40.102.tar.gz
# make UISTYLE=text
# cp unison /usr/local/bin


# tar xvzf inotify-tools-3.13.tar.gz
# ./configure -prefix=/usr/local/inotify
# make
# make install


=========================================================================================二、配置ssh key信任


=========================================================================================三、配置参数

# mkdir -p /data/logs/unison
# vim /root/.unison/common.prf
batch = true
group = true
owner = true
#path =
perms = -1

silent = true
times = true

#force =
fastcheck = false
links = true

log = true
logfile = /data/logs/unison/unison.log

ignore = Name *.tmp
ignore = Name .unison.*
ignore = Path .unison.*

#repeat = 1
#retry = 3

rsync = false
servercmd = /usr/local/bin/unison
sshargs = -C
sshcmd = /usr/local/bin/ssh
stream = true
ui = text
xferbycopying = true


=========================================================================================
四、实时同步脚本
# vim /usr/local/inotify/unison.sh
#!/bin/bash

PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/bin:/usr/local/sbin

LOCAL_DIR="/data/unison_test/"
REMOTE_DIR="/data/unison_test/"

REMOTE_USER="root"

INOTIFY="/usr/local/inotify/bin/inotifywait"
UNISION="/usr/local/bin/unison"

IP_LIST_FILE="/usr/local/inotify/iplist.txt"
ATTRIBUTES="modify,delete,create,attrib"


${INOTIFY} -mrq --timefmt '%d/%m/%y %H:%M' --format '%T %w%f' -e ${ATTRIBUTES} ${LOCAL_DIR} | while read files
do
        for IPADDR in `sed '/^$/d' ${IP_LIST_FILE}`
        do
                  ${UNISION} common "${LOCAL_DIR}" "ssh://${REMOTE_USER}@${IPADDR}/${REMOTE_DIR}"
        done
done


# chmod +x /usr/local/inotify/unison.sh
# cd /usr/local/inotify

# nohup ./unison.sh &


下载地址:

http://www.seas.upenn.edu/~bcpierce/unison//download/releases/stable/