标签:unison
此项目是一个中小型APP类应用,服务器是运营商分配的两台公网IP的虚拟机,后面无共用存储等设备。由于前端要采用负载均衡技术,为了保证数据一致性和安全性,采用两台服务器网站文件之间实时同步,外加一台远程备份用服务器,共三台。所以选择Rsync+sersync 负责主服务器到远程服务器单向(参考之前文章),UNISON+inotify实现主备服务器之间实时相互同步。
一、安装过程:yum -y install ocaml
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
cd unison-2.48.3
yum -y install ctags-etags
make UISTYLE=text
mkdir /root/bin
cp unison /root/bin/
cp unison /root/bin/unison-2.48
cp unison /usr/local/bin/unison
make install
1026 tar zxvf inotify-tools-3.13.tar.gz
1027 cd inotify-tools-3.13
1028 ./configure --prefix=/usr/local/inotify
1029 make && make install
1030 echo "PATH=/usr/local/inotify/bin:$PATH" >/etc/profile.d/inotify.sh
1031 chmod +x /etc/profile.d/inotify.sh
1032 source /etc/profile
1033 echo "/usr/local/inotify/lib" >/etc/ld.so.conf.d/inotify.conf
1034 ldconfig -v | grep inotify
1035 ln -sv /usr/local/inotify/include/ /usr/include/inotify
1036 history
二、设置SSH互信 略
三、编写运行脚本 ,放置后台运行
#!/bin/bash
/usr/local/inotify/bin/inotifywait -mrq -e create,delete,modify,move /wqdata/mofi/ | while read line
do
/root/bin/unison -servercmd=/root/bin/unison -batch /wqdata/mofi/ ssh://root@223.100.98.83:8022//wqdata/mofi/
echo "`date `sync successful" >> /wqdata/sync.log
done
手工同步命令:/root/bin/unison -servercmd=/root/bin/unison -batch /wqdata/mofi/ ssh://root@223.100.98.83:8022//wqdata/mofi/
标签:unison
原文地址:http://024mj.blog.51cto.com/10252785/1692820