`
sillycat
  • 浏览: 2542869 次
  • 性别: Icon_minigender_1
  • 来自: 成都
社区版块
存档分类
最新评论

RabbitMQ(11)Mirror HA with Cluster

 
阅读更多
RabbitMQ(11)Mirror HA with Cluster
 
We can set up that from command line with rabbitmqctl.
We can also do that from the rabbitMQ client.
We can also do that on the UI console.
 
There are several policy.
ha-mode——————ha-params ————— Result
all           ——————(absent)     ————— Queue is mirrored, if we add one node, the system will mirror all data to that.
exactly   ——————count  ———————We will only keep certain count of mirror nodes
nodes ———————node names ———— List the mirror nodes in the parameters part
 
Let’s try to implement it in scala.
 
Lyra, High Availability RabbitMQ Client
It will helps us to achieve high availability in our services by embracing failure, allowing for AMQP resources such as connections, channels and consumers to be automatically recovered when the server or network failures occur.
 
 
msgpack 
 
or 
 
msgpack4s
 
 
Some example
Project Configuration
For RabbitMQ load balance and cluster solution. I read some documents. Actually, there are several levels.
1. Cluster
We can have a cluster of nodes which can have duplicated routing and exchange in every node.
So the client can producer to any nodes. But the persist queue information is stored in one node, so if
that node is down, we need to wait until that node recover.

2. HA based on cluster
If we have configured mirrors in the cluster, then we will have the persist queue information in all the nodes.
We will lost some performance here. But the good things is that when one node is down, we can go on serving from
other nodes.

3. Sharding based on Cluster
From the document, it is said, we will not just mirror all the queue information to all the nodes, the more nodes
we have, we will lost more performance.
Instead of simple mirror, we will sharding different data into different queues in different nodes.

I did not read more about that since we are using mirror on production. I will begin from there.

Set up RabbitMQ Cluster
details here
http://sillycat.iteye.com/blog/2066116

>chmod 400 ~/.erlang.cookie
>sudo chown -R carl ~/.erlang.cookie
>sudo chgrp -R staff ~/.erlang.cookie

enable the plugin
>sudo rabbitmq-plugins enable rabbitmq_management

Start the first node as rabbitmq1 on local MAC
>sudo RABBITMQ_NODE_PORT=5672 RABBITMQ_SERVER_START_ARGS="-rabbitmq_management listener [{port,15672}]" RABBITMQ_NODENAME=rabbit1 sbin/rabbitmq-server -detached

Start the second node
>sudo RABBITMQ_NODE_PORT=5673 RABBITMQ_SERVER_START_ARGS="-rabbitmq_management listener [{port,15673}]" RABBITMQ_NODENAME=rabbit2 sbin/rabbitmq-server -detached

Check the status of these 2 nodes, make sure they are running fine separately.
>sbin/rabbitmqctl -n rabbit2 cluster_status
>sbin/rabbitmqctl -n rabbit1 cluster_status

Stop the second node, and make the second node join the first node as a cluster
>sudo sbin/rabbitmqctl -n rabbit2 stop_app
>sbin/rabbitmqctl -n rabbit2 join_cluster rabbit1@sparkworker1
>sudo sbin/rabbitmqctl -n rabbit2 start_app

Check the status again, it will be a running cluster.
 
In the basic class, we will do that
def setPolicy(): Unit = {
  val auth = "Basic " + DatatypeConverter.printBase64Binary((username + ":" + password).getBytes)
  rabbitAdmin.split(",").map(h => new URL("http://" + h.trim + "/api/policies/%2f/high-availability")).
    foreach { url =>
      logger.debug("setting policy for " + url)
      val conn = url.openConnection().asInstanceOf[HttpURLConnection]
      conn.setDoOutput(true)
      conn.setRequestMethod("PUT")
      List(
        "Content-Type" -> "application/json",
        "Content-Length" -> haDefinition.length.toString,
        "Authorization" -> auth
      ).foreach(t => conn.setRequestProperty(t._1, t._2))
      val os = conn.getOutputStream
      os.write(haDefinition.getBytes)
      os.close
      logger.debug("response " + conn.getResponseCode + conn.getResponseMessage)
    }
}
 
 
 
 
References:
old blog
 
sharding
 
HA
 
cluster
 

 

 

 

分享到:
评论

相关推荐

    RabbitMQ_Mirror机制分析

    "RabbitMQ Mirror机制分析" RabbitMQ Mirror机制是RabbitMQ中的一种高可用性机制,旨在提供消息队列的高可用性和持久化。Mirror机制的核心是镜像队列(Mirror Queue),它是一个特殊的Backing Queue,内部包裹了一...

    rabbitmq 3.9.11 + Erlang 23.2

    本话题主要涉及两个核心部分:RabbitMQ 3.9.11的安装与Erlang 23.2环境的搭建,这两个都是在Windows 64位操作系统上进行的。 首先,我们需要了解Erlang环境。Erlang提供了轻量级进程、分布式计算、热代码升级等特性...

    RabbitMQ Cluster.docx

    新节点加入时,通常需要使用`rabbitmq-cluster join`命令来指定现有的集群节点,而移除节点则需要使用`rabbitmqctl`工具,这可能涉及数据迁移和状态更新。如果节点出现故障并需要重新加入集群,它必须先被正确地停止...

    k8s部署rabbitmq-cluster集群配置文件和docker镜像文件

    k8s部署rabbitmq-cluster集群配置文件和docker镜像文件,配合文章学习用,有需要可以下载,无需修改直接部署即可

    docker-rabbitmq-cluster集群搭建

    docker-rabbitmq-cluster集群搭建docker-rabbitmq-cluster集群搭建

    chef-rabbitmq-cluster:厨师食谱,用于配置rabbitmq-cluster。 (Opscode Rabbitmq食谱的包装食谱。)

    ubuntu / trusty64 ubuntu / precise64 厨师/centos-6.5 主厨/debian-7.7属性钥匙类型描述默认['rabbitmq'] ['cluster'] 布尔型['rabbitmq'] ['cluster'] = true,并且需要['rabbitmq'] ['erlang_cookie']来配置...

    rabbitmq集群环境搭建

    Eshell V7.3 (abort with ^G) 1> ``` - **配置Erlang环境变量**:编辑`/etc/profile`文件,添加Erlang的`bin`目录到`PATH`环境变量中,并使修改生效。 ```bash export PATH=$PATH:/kingdee/program/erlang/...

    RabbitMQ安装包,版本:rabbitmq-server-3.9.11.exe

    rabbitmq-server-3.9.11.exe

    rabbitmq_cluster.zip

    使用ansible安装rabbitmq集群 需要预先实现控制节点的免密操作 参数说明 #rabbitmq rabbitmq安装目录 work_home: /data/test erlang_rpm安装文件名(放在files文件夹内) erlang_rpm: erlang-20.3.7-1.el7.centos....

    RabbitMQ in Depth.pdf

    This book is up-to-date with RabbitMQ 3.6.3, so with the erratic release schedule of RabbitMQ itself, by the time this book reaches you there may be newer versions released. Not to fret though, as in...

    kubernetes-rabbitmq-cluster:适用于kubernetes的可部署的Rabbitmq集群

    总结来说,"kubernetes-rabbitmq-cluster"项目提供了一个在Kubernetes中部署和管理RabbitMQ集群的有效方法,利用了Kubernetes的强大力量,实现了RabbitMQ服务的高可用性和可扩展性。通过学习和实践这个项目,开发者...

    rabbitmq windows服务器安装文档.doc

    **RabbitMQ Windows服务器安装详解** RabbitMQ是一款开源的消息队列系统,基于AMQP(Advanced Message Queuing Protocol)协议,被广泛应用于分布式系统中,用于处理异步任务、消息传递和负载均衡。本文将详细介绍...

    rabbitmq 3.10.2 window安装包

    RabbitMQ是一个开源的消息代理和队列服务器,广泛用于分布式系统中的消息传递。它基于AMQP(Advanced Message Queuing Protocol)标准,允许应用程序之间异步通信,并提供了高可用性、可扩展性和容错性。RabbitMQ的...

    rabbitmq配置文件 rabbitmq.config

    rabbitmq配置文件,用于rabbitmq管理

    RabbitMQ消息中间件面试专题.pdf

    首先,我们来探究RabbitMQ中的broker与cluster的含义。broker指的是一组或多个Erlang节点的逻辑分组,在这些节点上运行着RabbitMQ应用程序。简而言之,broker就是运行RabbitMQ服务的服务器或者服务集群。而cluster...

    rabbitmq基础+springboot集成rabbitmq

    Spring Boot提供了`@RunWith(SpringRunner.class)`和`@SpringBootTest`注解,便于在测试环境中启动和配置RabbitMQ。 **文档说明** 项目中的`RabbitMq.docx`可能包含RabbitMQ和SpringBoot集成的详细教程,包括如何...

    Rabbitmq 默认配置文件模板

    - `cluster_nodes`: 配置集群节点的信息,包括节点类型(ram或disc)和节点名称。 - `disk_free_limit`: 设置磁盘空间阈值,当剩余空间低于该值时,RabbitMQ会触发磁盘警告。 - `vm_memory_high_watermark`: 内存...

    rabbitmq-server-windows-3.6.12.zip

    RabbitMQ 3.6.12 is a maintenance release. Upgrades and Compatibility See the "Upgrading clusters" section of the ...To upgrade a RabbitMQ cluster, follow the instructions in RabbitMQ documentation.

    rabbitmq-c-master.rar_RabbitMQ c lib_cmake编译_rabbitmq_rabbitmq-c

    `rabbitmq-c`是RabbitMQ的一个C语言客户端库,它使得在C程序中与RabbitMQ服务器进行交互变得更加简单。本文将详细介绍如何使用CMake编译`rabbitmq-c-master`源码,并讨论相关知识点。 首先,我们需要了解CMake,这...

Global site tag (gtag.js) - Google Analytics