RabbitMQ系列之高可用集群

为了实现高可用,我采用LVS+双节点RabbitMq , 架构图如下:

在RabbitMQ之前放了LVS, LVS 采用 rr 轮询算法 , 目的是将请求平均分配到两个真实节点,并配置5672端口监控,异常时转移到另外的节点。

在 ,做完之后测试发现,用上LVS之后,测试会报错,服务器端的队列名称都是一致的,但是队列内容却并不是一致,看来需要做同步。

Rabbit提供镜像功能,需要基于rabbitmq策略来实现,政策是用来控制和修改群集范围的某个vhost队列行为和Exchange行为 : 

set_policy [-p vhostpath] {name} {pattern} {definition} [priority]

eg. 

1 rabbitmqctl set_policy ha-allqueue "^" '{"ha-mode":"all"}'

pattern 是匹配队列名称的正则表达式 , 进行区分哪些队列使用哪些策略

definition 其实就是一些arguments, 支持如下参数:

  1. ha-modeOne of allexactly or nodes (the latter currently not supported by web UI).
  2. ha-paramsAbsent if ha-mode is all, a number if ha-mode is exactly, or an array of strings if ha-mode is nodes.
  3. ha-sync-modeOne of manual or automatic. //如果不指定该参数默认为manual,这个在高可用集群测试的时候详细分析 
  4. federation-upstream-setA string; only if the federation plugin is enabled.

ha-mode 的参数:

ha-modeha-paramsResult
all(absent)Queue is mirrored across all nodes in the cluster. When a new node is added to the cluster, the queue will be mirrored to that node.
exactlycountQueue is mirrored to count nodes in the cluster. If there are less than count nodes in the cluster, the queue is mirrored to all nodes. If there are more than countnodes in the cluster, and a node containing a mirror goes down, then a new mirror will not be created on another node. (This is to prevent queues migrating across a cluster as it is brought down.)
nodesnode namesQueue is mirrored to the nodes listed in node names. If any of those node names are not a part of the cluster, this does not constitute an error. If none of the nodes in the list are online at the time when the queue is declared then the queue will be created on the node that the declaring client is connected to.

在管理policy的时候WebUI是非常不错:

Definition加入两项:

ha-mode:all 

ha-sync-mode:automatic 

到这里配置已经完成,接下来进行测试。

两个节点之间就会开始同步消息了。

这时借助前面的LVS / HA 就可以使用高可用了 。

 

 

 

转载于:https://www.cnblogs.com/DanielChow/p/3373518.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
经导师精心指导并认可、获 98 分的毕业设计项目!【项目资源】:微信小程序。【项目说明】:聚焦计算机相关专业毕设及实战操练,可作课程设计与期末大作业,含全部源码,能直用于毕设,经严格调试,运行有保障!【项目服务】:有任何使用上的问题,欢迎随时与博主沟通,博主会及时解答。 经导师精心指导并认可、获 98 分的毕业设计项目!【项目资源】:微信小程序。【项目说明】:聚焦计算机相关专业毕设及实战操练,可作课程设计与期末大作业,含全部源码,能直用于毕设,经严格调试,运行有保障!【项目服务】:有任何使用上的问题,欢迎随时与博主沟通,博主会及时解答。 经导师精心指导并认可、获 98 分的毕业设计项目!【项目资源】:微信小程序。【项目说明】:聚焦计算机相关专业毕设及实战操练,可作课程设计与期末大作业,含全部源码,能直用于毕设,经严格调试,运行有保障!【项目服务】:有任何使用上的问题,欢迎随时与博主沟通,博主会及时解答。 经导师精心指导并认可、获 98 分的毕业设计项目!【项目资源】:微信小程序。【项目说明】:聚焦计算机相关专业毕设及实战操练,可作课程设计与期末大作业,含全部源码,能直用于毕设,经严格调试,运行有保障!【项目服务】:有任何使用上的问题,欢迎随时与博主沟通,博主会及时解答。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值