环境如下:
mysql 服务器192.168.0.25
discus 服务器 192.168.0.24和192.168.0.26 ,两台discus之间做rsync+innotify实现数据同步
lvs服务器192.168.0.22 ,VIP 192.168.0.19
效果如下
discus 服务器安装好lamp 环境,
192.168.0.24 配置如下 yum install rsync
[root@node3 ~]# cat /etc/rsyncd.conf
uid = nobody
gid = nobody
use chroot = no
max connections = 10
strict modes = yes
pid file = /var/run/rsyncd.pid
log file = /var/log/rsyncd.lock
[web]
path = /web
ignore errors
read only = no
write only = no
hosts allow = 192.168.0.0/24
hosts deny = *
uid = root
gid = root
list = false
192.168.0.26安装rsync 客户端工具inotify-tools-3.13 ,配置脚本
[root@node5 ~]# cat rsync.sh
#/bin/bash
#
#
rsyncServer=192.168.0.24
src=/web/
dst=web
rsync -azrtopg --delete $src $rsyncServer::$dst
/usr/local/bin/inotifywait -mrq -e create,move,delete,modify $src | while read files;do
rsync -azrtopg --delete $src $rsyncServer::$dst
done
增加计划任务,这个的坏处就是不能实时同步,不过对于论坛形式的网站要求不高也无所谓了。
crontab -e
*/1 * * * * /usr/bin/rsync -aptgoz 192.168.0.24::web /web
安装好discus 测试是否同步成功,LVS 安装参照另外lvs NAT 模式或 DR模式篇