Debian6.0 squeeze
Server1:192.168.1.104
Server2:192.168.1.105

安装之前需要Server1与Server2之间SSH互相信任 请参考以下文章:
http://www.secblog.cn/article/928.html

Server1
#vi /etc/apt/sources.list
deb http://mirrors.163.com/debian squeeze main non-free contrib
deb http://mirrors.163.com/debian squeeze-proposed-updates main contrib non-free
deb http://mirrors.163.com/debian-security squeeze/updates main contrib non-free
deb-src http://mirrors.163.com/debian squeeze main non-free contrib
deb-src http://mirrors.163.com/debian squeeze-proposed-updates main contrib non-free
deb-src http://mirrors.163.com/debian-security squeeze/updates main contrib non-free
deb http://http.us.debian.org/debian squeeze main contrib non-free
deb http://non-us.debian.org/debian-non-US squeeze/non-US main contrib non-free
deb http://security.debian.org squeeze/updates main contrib non-free
#apt-get update
#apt-get install unison //两台Server都需要安装unison
#usr/bin/unison

#vi /root/.unison/default.prf 
root = /root/test/
root = ssh://192.168.1.105//root/test/

#force =/root/test/

# Paths to synchronize
#path = bbs/p_w_uploads
#path = uc/data/avatar
#path = uchome/p_w_upload

# Some regexps specifying names and paths to ignore
#ignore = Path bbs/p_w_uploads/swfupload
#ignore = Name temp.*
#ignore = Name *~
#ignore = Name .*~
#ignore = Name *.mp3

auto = true
batch = true
maxthreads = 500
owner = true
group = true
perms = -1
repeat = 1
retry = 3
sshargs = -C 
xferbycopying = true 
silent = true
fastcheck = true
log = true
logfile = /root/.unison/unixidc_122.1547.log

Server1创建/root/test
#mkdir /root/test

Server2创建/root/test
#mkdir /root/test

#/usr/bin/unison&
推送到后台安静模式运行

如果Server1的/root/test想同步到Server2的/root/test2
需要在Server1创建/root/test Server2创建/root/test2
配置文件为 root = ssh://192.168.1.105//root/test2/

其中要注意的是:
1.force去掉前面的# 那就是Server1单向同步到Server2
2.silent = true 是以安静模式运行 否则一直会有以下提示

root@localhost:~# /usr/bin/unison
Contacting server…
Connected [//localhost//root/test -> //unixidc//root/test]
Looking for changes
  Waiting for changes from server
Reconciling changes
Nothing to do: replicas have not changed since last sync.

Sleeping for 1 seconds…

Looking for changes
  Waiting for changes from server
Reconciling changes
Nothing to do: replicas have not changed since last sync.

3.path 是指定你需要同步的目录,用ignore指定path中需要排除的目录及文件

4.要双向同步的目录都不允许为空 否则unison进程会自动结束 并提示Aborting…

5.如需了解更多参数 请参考http://www.seas.upenn.edu/~bcpierce/unison//download/releases/stable/unison-manual.htm