RabbitMQ系列之高可用集群
为了实现高可用,我采用LVS+双节点RabbitMq , 架构图如下:

在RabbitMQ之前放了LVS, LVS 采用 rr 轮询算法 , 目的是将请求平均分配到两个真实节点,并配置5672端口监控,异常时转移到另外的节点。
在 ,做完之后测试发现,用上LVS之后,测试会报错,服务器端的队列名称都是一致的,但是队列内容却并不是一致,看来需要做同步。
Rabbit提供镜像功能,需要基于rabbitmq策略来实现,政策是用来控制和修改群集范围的某个vhost队列行为和Exchange行为 :
set_policy [-p vhostpath] {name} {pattern} {definition} [priority]
eg.
rabbitmqctl set_policy ha-allqueue "^" '{"ha-mode":"all"}'
pattern 是匹配队列名称的正则表达式 , 进行区分哪些队列使用哪些策略
definition 其实就是一些arguments, 支持如下参数:
ha-mode:One ofall,exactlyornodes(the latter currently not supported by web UI).ha-params:Absent ifha-modeisall, a number ifha-modeisexactly, or an array of strings ifha-modeisnodes.ha-sync-mode:One ofmanualorautomatic. //如果不指定该参数默认为manual,这个在高可用集群测试的时候详细分析federation-upstream-set:A string; only if the federation plugin is enabled.
ha-mode 的参数:
| ha-mode | ha-params | Result |
|---|---|---|
| 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. |
| exactly | count | Queue 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.) |
| nodes | node names | Queue 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 就可以使用高可用了 。
RabbitMQ系列之高可用集群的更多相关文章
- (十)RabbitMQ消息队列-高可用集群部署实战
原文:(十)RabbitMQ消息队列-高可用集群部署实战 前几章讲到RabbitMQ单主机模式的搭建和使用,我们在实际生产环境中出于对性能还有可用性的考虑会采用集群的模式来部署RabbitMQ. Ra ...
- rabbitmq+ keepalived+haproxy高可用集群详细命令
公司要用rabbitmq研究了两周,特把 rabbitmq 高可用的研究成果备下 后续会更新封装的类库 安装erlang wget http://www.gelou.me/yum/erlang-18. ...
- rabbitmq安装与高可用集群配置
rabbitmq版本:3.6.12 rabbitmq安装 1.安装openssl wget http://www.openssl.org/source/openssl-1.0.0a.tar.gz &a ...
- rabbitmq+haproxy+keepalived高可用集群环境搭建
1.先安装centos扩展源: # yum -y install epel-release 2.安装erlang运行环境以及rabbitmq # yum install erlang ... # yu ...
- Redis总结(五)缓存雪崩和缓存穿透等问题 Web API系列(三)统一异常处理 C#总结(一)AutoResetEvent的使用介绍(用AutoResetEvent实现同步) C#总结(二)事件Event 介绍总结 C#总结(三)DataGridView增加全选列 Web API系列(二)接口安全和参数校验 RabbitMQ学习系列(六): RabbitMQ 高可用集群
Redis总结(五)缓存雪崩和缓存穿透等问题 前面讲过一些redis 缓存的使用和数据持久化.感兴趣的朋友可以看看之前的文章,http://www.cnblogs.com/zhangweizhon ...
- RabbitMQ学习系列(六): RabbitMQ 高可用集群
前面讲过一些RabbitMQ的安装和用法,也说了说RabbitMQ在一般的业务场景下如何使用.不知道的可以看我前面的博客,http://www.cnblogs.com/zhangweizhong/ca ...
- RabbitMQ从零到集群高可用(.NetCore5.0) -高可用集群构建落地
系列文章: RabbitMQ从零到集群高可用(.NetCore5.0) - RabbitMQ简介和六种工作模式详解 RabbitMQ从零到集群高可用(.NetCore5.0) - 死信队列,延时队列 ...
- rabbitmq+haproxy+keepalived实现高可用集群搭建
项目需要搭建rabbitmq的高可用集群,最近在学习搭建过程,在这里记录下可以跟大家一起互相交流(这里只是记录了学习之后自己的搭建过程,许多原理的东西没有细说). 搭建环境 CentOS7 64位 R ...
- 搭建 RabbitMQ Server 高可用集群
阅读目录: 准备工作 搭建 RabbitMQ Server 单机版 RabbitMQ Server 高可用集群相关概念 搭建 RabbitMQ Server 高可用集群 搭建 HAProxy 负载均衡 ...
随机推荐
- Tomcat权威指南-读书摘要系列2
2. 配置Tomcat 2.1. 重定向Web应用程序的目录 将工程文件与Tomcat分离 复制conf和webapps文件夹到分离目录: 配置CATALINA_BASE环境变量,值为分离目录: 2. ...
- (转) 经典功率谱估计及Matlab仿真
原文出自:http://www.cnblogs.com/jacklu/p/5140913.html 功率谱估计在分析平稳各态遍历随机信号频率成分领域被广泛使用,并且已被成功应用到雷达信号处理.故障诊断 ...
- PHP基础知识之————匿名函数(Anonymous functions)
匿名函数(Anonymous functions),也叫闭包函数(closures),允许 临时创建一个没有指定名称的函数.最经常用作回调函数(callback)参数的值.当然,也有其它应用的情况. ...
- Java中创建线程的三种方法以及区别
Java使用Thread类代表线程,所有的线程对象都必须是Thread类或其子类的实例.Java可以用三种方式来创建线程,如下所示: 1)继承Thread类创建线程 2)实现Runnable接口创建线 ...
- psutil-3.4.2才是我的老系统(Windows XP)的菜
psutil-3.4.2才是我的老系统(Windows XP)的菜 psutil 是一款跨平台的查看操作系统和进程信息的工具. 在一次卸载和重装了spyder包之后, spyder升级到了: 2.3. ...
- Java序员的成长之路
对于Java程序猿学习的建议 第一阶段——Java基础 第二阶段——Web开发 这些内容主要是Web开发相关的内容,包括HTML/CSS/JS(前端页面).Servlet/JSP(J2EE)以及MyS ...
- Python入门系列教程(五)函数
全局变量 修改全局变量 a=100 def test(): global a a=200 print a 多个返回值 缺省参数 def test3(a,b=1): print a,b test3(a) ...
- 判别式模型 vs. 生成式模型
1. 简介 生成式模型(generative model)会对\(x\)和\(y\)的联合分布\(p(x,y)\)进行建模,然后通过贝叶斯公式来求得\(p(y|x)\), 最后选取使得\(p(y|x) ...
- 【CodeForces】961 G. Partitions 斯特林数
[题目]G. Partitions [题意]n个数$w_i$,每个非空子集S的价值是$W(S)=|S|\sum_{i\in S}w_i$,一种划分方案的价值是所有非空子集的价值和,求所有划分成k个非空 ...
- 修改elasticsearch5,搜索结果最大10000
一:在Linux服务器中执行如下命令(开启es服务) curl -XPUT http://服务器ip:9200/索引名称/_settings -d '{ "index" : { & ...