lvs 负载均衡两台Discuz+rsync+innotify实现数据同步

环境如下:

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模式篇

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值