RabbitMQ 集群部署

news2024/9/21 2:36:37

RabbiMQ 是用 Erlang 开发的,集群非常方便,因为 Erlang 天生就是一门分布式语言,但其本身并不支持负载均衡。

RabbitMQ 的集群节点包括内存节点、磁盘节点。RabbitMQ 支持消息的持久化,也就是数据写在磁盘上,最合适的方案就是既有内存节点,又有磁盘节点。

RabbitMQ 模式大概分为以下三种:

  • 单一模式;
  • 普通模式(默认的集群模式);
  • 镜像模式(把需要的队列做成镜像队列,存在于多个节点,属于 RabbiMQ 的 HA 方案,在对业务可靠性要求较高的场合中比较适用)。 要实现镜像模式,需要先搭建一个普通集群模式,在这个模式的基础上再配置镜像模式以实现高可用。

1. 集群架构 #

2. 集群部署规划 #

item node 1 node 2 node 3
listeners.tcp.default 5000 5100 5200
management.tcp.port 5020 5120 5220
mqtt.listeners.tcp.default 5040 5140 5240

3. 安装文件 #

下载文件

请下载 unix generic 版本

  • 以 3.9.11 版本为例: https://github.com/rabbitmq/rabbitmq-server/releases/download/v3.9.11/rabbitmq-server-generic-unix-3.9.11.tar.xz

  • 其他版本下载:https://github.com/rabbitmq/rabbitmq-server/releases

解压文件

xz -d rabbitmq-server-generic-unix-3.9.11.tar.xz

tar xvf rabbitmq-server-generic-unix-3.9.11.tar

复制成功!

4. 集群部署 #

4.1 创建文件目录 #

分别创建三个节点(node)目录,多个以此类推 node-N

cd /data

mkdir -p rabbitmq/dc3/node-01 rabbitmq/dc3/node-02 rabbitmq/dc3/node-03

复制成功!

将解压的 rabbitmq 文件放入到每个节点中,其他节点操作一致

cp -r rabbitmq-server/* rabbitmq/dc3/node-01/

# pwd
# /data/rabbitmq/dc3/node-01

# ls
# escript  etc  plugins  sbin  share

复制成功!

为每个节点创建配置和 keys 目录,其他节点操作一致

cd node-N

mkdir -p etc/rabbitmq keys

复制成功!

4.2 配置文件 #

在每个节点的 etc/rabbitmq 下添加配置文件 advanced.configrabbitmq.confrabbitmq-env.confenabled_plugins

4.2.1 advanced.config #
[


 %% ----------------------------------------------------------------------------
 %% Advanced Erlang Networking/Clustering Options.
 %%
 %% See https://www.rabbitmq.com/clustering.html for details
 %% ----------------------------------------------------------------------------
 %% Sets the net_kernel tick time.
 %% Please see http://erlang.org/doc/man/kernel_app.html and
 %% https://www.rabbitmq.com/nettick.html for further details.
 %%
 %% {kernel, [{net_ticktime, 60}]},
 %% ----------------------------------------------------------------------------
 %% RabbitMQ Shovel Plugin
 %%
 %% See https://www.rabbitmq.com/shovel.html for details
 %% ----------------------------------------------------------------------------

 {rabbitmq_shovel,
  [{shovels,
    [%% A named shovel worker.
     %% {my_first_shovel,
     %%  [

     %% List the source broker(s) from which to consume.
     %%
     %%   {sources,
     %%    [%% URI(s) and pre-declarations for all source broker(s).
     %%     {brokers, ["amqp://user:password@host.domain/my_vhost"]},
     %%     {declarations, []}
     %%    ]},

     %% List the destination broker(s) to publish to.
     %%   {destinations,
     %%    [%% A singular version of the 'brokers' element.
     %%     {broker, "amqp://"},
     %%     {declarations, []}
     %%    ]},

     %% Name of the queue to shovel messages from.
     %%
     %% {queue, <<"your-queue-name-goes-here">>},

     %% Optional prefetch count.
     %%
     %% {prefetch_count, 10},

     %% when to acknowledge messages:
     %% - no_ack: never (auto)
     %% - on_publish: after each message is republished
     %% - on_confirm: when the destination broker confirms receipt
     %%
     %% {ack_mode, on_confirm},

     %% Overwrite fields of the outbound basic.publish.
     %%
     %% {publish_fields, [{exchange,    <<"my_exchange">>},
     %%                   {routing_key, <<"from_shovel">>}]},

     %% Static list of basic.properties to set on re-publication.
     %%
     %% {publish_properties, [{delivery_mode, 2}]},

     %% The number of seconds to wait before attempting to
     %% reconnect in the event of a connection failure.
     %%
     %% {reconnect_delay, 2.5}

     %% ]} %% End of my_first_shovel
    ]}
   %% Rather than specifying some values per-shovel, you can specify
   %% them for all shovels here.
   %%
   %% {defaults, [{prefetch_count,     0},
   %%             {ack_mode,           on_confirm},
   %%             {publish_fields,     []},
   %%             {publish_properties, [{delivery_mode, 2}]},
   %%             {reconnect_delay,    2.5}]}
  ]},

  {rabbitmq_auth_backend_ldap, [
    %%
    %% Authorisation
    %% =============
    %%

    %% The LDAP plugin can perform a variety of queries against your
    %% LDAP server to determine questions of authorisation. See
    %% https://www.rabbitmq.com/ldap.html#authorisation for more
    %% information.

    %% Set the query to use when determining vhost access
    %%
    %% {vhost_access_query, {in_group,
    %%                       "ou=${vhost}-users,ou=vhosts,dc=example,dc=com"}},

    %% Set the query to use when determining resource (e.g., queue) access
    %%
    %% {resource_access_query, {constant, true}},

    %% Set queries to determine which tags a user has
    %%
    %% {tag_queries, []}
  ]}
].

复制成功!

4.2.2 rabbitmq.conf #
## This example configuration file demonstrates various settings
## available via rabbitmq.conf. It primarily focuses core broker settings
## but some tier 1 plugin settings are also covered.
##
## This file is AN EXAMPLE. It is NOT MEANT TO BE USED IN PRODUCTION. Instead of
## copying the entire (large!) file, create or generate a new rabbitmq.conf for the target system
## and populate it with the necessary settings.
##
## See https://rabbitmq.com/configure.html to learn about how to configure RabbitMQ,
## the ini-style format used by rabbitmq.conf, how it is different from `advanced.config`,
## how to verify effective configuration, and so on.
##
## See https://rabbitmq.com/documentation.html for the rest of RabbitMQ documentation.
##
## In case you have questions, please use RabbitMQ community Slack and the rabbitmq-users Google group
## instead of GitHub issues.

# ======================================
# Core broker section
# ======================================


## Networking
## ====================
##
## Related doc guide: https://rabbitmq.com/networking.html.
##
## By default, RabbitMQ will listen on all interfaces, using
## the standard (reserved) AMQP 0-9-1 and 1.0 port.
##
listeners.tcp.default = 5000


## To listen on a specific interface, provide an IP address with port.
## For example, to listen only on localhost for both IPv4 and IPv6:
##
# IPv4
# listeners.tcp.local    = 127.0.0.1:5672
# IPv6
# listeners.tcp.local_v6 = ::1:5672

## You can define multiple listeners using listener names
# listeners.tcp.other_port = 5673
# listeners.tcp.other_ip   = 10.10.10.10:5672


## TLS listeners are configured in the same fashion as TCP listeners,
## including the option to control the choice of interface.
##
# listeners.ssl.default = 5030

## It is possible to disable regular TCP (non-TLS) listeners. Clients
## not configured to use TLS and the correct TLS-enabled port won't be able
## to connect to this node.
# listeners.tcp = none

## Number of Erlang processes that will accept connections for the TCP
## and TLS listeners.k
##
# num_acceptors.tcp = 10
# num_acceptors.ssl = 10

## Socket writer will force GC every so many 

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/802554.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

低成本32位单片机空调内风机方案

空调内风机方案主控芯片采用低成本32位单片机MM32SPIN0230&#xff0c;内部集成了具有灵动特色的电机控制功能&#xff1a;高阶4路互补PWM、注入功能的高精度ADC、轨到轨运放、轮询比较器、32位针对霍尔传感器的捕获时钟、以及硬件除法器和DMA等电机算法加速引擎。 该方案具有…

二分

二分法&#xff1a;二分搜索法 不断缩小解可能存在的范围&#xff0c;从而求得问题最优解的方法 二分法的时间复杂度为O(logn) 二分题目主要分为二分查找、二分答案&#xff0c;二分类型分为整数二分、实数域上二分 整数二分 在闭区间[left,right]之间&#xff0c;不断二分…

【信号去噪】基于马氏距离和EDF统计(IEE-TSP)的基于小波的多元信号去噪方法研究(Matlab代码实现)

&#x1f4a5;&#x1f4a5;&#x1f49e;&#x1f49e;欢迎来到本博客❤️❤️&#x1f4a5;&#x1f4a5; &#x1f3c6;博主优势&#xff1a;&#x1f31e;&#x1f31e;&#x1f31e;博客内容尽量做到思维缜密&#xff0c;逻辑清晰&#xff0c;为了方便读者。 ⛳️座右铭&a…

Python解码张三的法外狂徒之旅,揭秘视频背后的真相!【含jS逆向解密】

前言 嗨喽&#xff0c;大家好呀~这里是爱看美女的茜茜呐 传说中&#xff0c;有人因为只是远远的看了一眼法外狂徒张三就进去了&#x1f602; 我现在是获取他视频&#xff0c;岂不是直接终生了&#x1f929; 网友&#xff1a;赶紧跑路吧 &#x1f60f; 好了话不多说&#xff…

独立站是如何打造品牌形象的?

当你决定做独立站的时候&#xff0c;一切都是从0开始&#xff0c;用户的信任也需要一点点建立。这就涉及到一个老生常谈的问题&#xff1a;如何为你的独立站打造一个更好的品牌形象&#xff1f; 无论你的产品是大众款还是小众商品&#xff0c;品牌所体现出的专业度&#xff0c…

【点选验证码】生成点选验证码图片

生成点选验证码图片 参考博客&#xff1a;https://blog.csdn.net/sinat_39629323/article/details/121989609 from tqdm import tqdm from PIL import Image, ImageDraw, ImageFont, ImageOps import shutil,os import numpy as np import cv2 import math import random fil…

python-异常处理

# try : # print(name) # except NameError: # print("有问题")# # try: # 1 / 0 # except ZeroDivisionError as ze: # print("xxxx", ze) # except NameError as ne: # print("666",ne) # else: # print("123&qu…

Domain Cluster Model

Introduction Domain Cluster Model 3.0 Background of Domain Management  领域管理背景 Common Framework 通用框架Architecture & Synergy Analysis 体系结构与协同分析Demand & Project Support 需求和项目支持Same Understanding between BU & IT BU和IT之间…

2 halcon ROI技术

文章目录 ROI 技术代码 ROI 技术 ROI 技术允许你在图像中定义一个特定的区域&#xff0c;并将该区域应用于后续的图像处理和分析任务。以下是使用 Halcon 实现 ROI 技术的一般步骤&#xff1a; 创建 ROI 对象&#xff1a;首先&#xff0c;你需要创建一个 ROI 对象来定义感兴趣…

使用 Python 自动备份 SQL 数据库

◆ 背景 在本文中&#xff0c;我们将深入探讨如何利用Python实现自动备份SQL数据库&#xff0c;以达到备份过程更加高效、简便和低出错率的目的。借助Python自动备份SQL数据库的方法&#xff0c;您能够节省时间、降低错误风险&#xff0c;并且保障数据始终得到有效保护。 定期…

超导体的概念及其用处

目录 1.什么是超导体 2.研究超导体的意义 3.常温超导体 4.韩国超导 1.什么是超导体 超导体是指在低温下具有零电阻和完全排斥磁场的材料。当超导体被冷却到其临界温度以下&#xff0c;电流可以在其内部无阻碍地流动&#xff0c;且磁场被完全排斥出超导体的表面&#xff0c;这…

移动端开发框架mui之源代码及 examples 下载

MUI版本号&#xff1a; v3.7.3 下载地址1&#xff1a; 百度网盘&#xff08;备份&#xff09; 链接&#xff1a;https://pan.baidu.com/s/1jqBNQFNHPbzqUYLJ2Hjgmw?pwdafk9 提取码&#xff1a;afk9 下载地址2&#xff1a; mui.js 及 examples 下载 - 码农之家

STM32 SPI学习

SPI 串行外设设备接口&#xff08;Serial Peripheral Interface&#xff09;&#xff0c;是一种高速的&#xff0c;全双工&#xff0c;同步的通信总线。 SCK时钟信号由主机发出。 SPI接口主要应用在存储芯片。 SPI相关引脚&#xff1a;MOSI&#xff08;输出数据线&#xff…

myBatis报错:Parameter index out of range (3 > number of parameters, which is 2).

【问题描述】&#xff1a; 今天在写mybatis的动态判断语句时&#xff0c;出现报错信息&#xff1a;&#xff08;报错信息从下往上看&#xff09; Parameter index out of range (3 &#xff1e; number of parameters, which is 2). 我们在mapper.xml文件中写动态SQL&#x…

【Terraform学习】Terraform配置变量(Terraform配置语言学习)

配置变量 实验步骤 创建 EC2 IAM 角色 导航到IAM 在左侧菜单中&#xff0c;单击角色 。单击创建角色该按钮以创建新的 IAM 角色。 在创建角色部分&#xff0c;为角色选择可信实体类型&#xff1a; AWS 服务 使用案例:EC2 单击下一步 添加权限&#xff1a;现在&#xff0c…

Rviz2的自定义插件开发基础知识

1. 简介 Rviz中有不同类型的插件&#xff0c;每个插件都必须具有相应的基本类型&#xff0c;才能被RViz识别 plugin typebase typeDisplayrviz_common::DisplayPanelrviz_common::PanelToolrviz_common::ToolFrames transformation libraryrviz_common::transformation::Fram…

有哪些虚拟机好用?并且对电脑没有伤害

在当今数字化时代&#xff0c;虚拟化技术越来越受到人们的关注和使用。虚拟机作为一种强大的工具&#xff0c;可以在一台计算机上模拟多个独立的操作系统环境&#xff0c;为用户提供了灵活性和便利性。然而&#xff0c;有人担心使用虚拟机可能会对电脑造成损害&#xff0c;尤其…

多普勒气泡监测与分级方法

Ultrasound detection of vascular decompression bubbles the influence of new technology and considerations on bubble load 多普勒气泡检测方法&#xff1a; 听觉多普勒超声监测法视觉二维超声成像谐波超声成像&#xff08;2的变种&#xff09; 多普勒气泡分级方法&…

objectarx编译Debug版arx遇到的问题

错误一链接错误 1>pietdoginterface_s.lib(Msg.obj) : error LNK2001: 无法解析的外部符号 “class ATL::CTraceCategory ATL::atlTraceException” (?atlTraceExceptionATL3VCTraceCategory1A) 1>pietdoginterface_s.lib(Msg.obj) : error LNK2001: 无法解析的外部符号…

【洁洁送书第二期】Python机器学习:基于PyTorch和Scikit-Learn

前言 近年来&#xff0c;机器学习方法凭借其理解海量数据和自主决策的能力&#xff0c;已在医疗保健、 机器人、生物学、物理学、大众消费和互联网服务等行业得到了广泛的应用。自从AlexNet模型在2012年ImageNet大赛被提出以来&#xff0c;机器学习和深度学习迅猛发展&#xf…