Dledger部署RocketMQ高可用集群(9节点集群)

news2025/1/31 2:58:55

文章目录

  • 🔊博主介绍
  • 🥤本文内容
    • 规划集群
    • 准备工作
    • 节点0配置(ip地址为192.168.80.101的机器)
    • 节点1配置(ip地址为192.168.80.102的机器)
    • 节点2配置(ip地址为192.168.80.103的机器)
    • 在所有节点机器上执行
    • 控制面板
  • 📢文章总结
  • 📥博主目标

🔊博主介绍

🌟我是廖志伟,一名Java开发工程师、Java领域优质创作者、CSDN博客专家、51CTO专家博主、阿里云专家博主、清华大学出版社签约作者、产品软文专业写手、技术文章评审老师、问卷调查设计师、个人社区创始人、开源项目贡献者。🌎跑过十五公里、🚀徒步爬过衡山、🔥有过三个月减肥20斤的经历、是个喜欢躺平的狠人。

📕拥有多年一线研发和团队管理经验,研究过主流框架的底层源码(Spring、SpringBoot、Spring MVC、SpringCould、Mybatis、Dubbo、Zookeeper),消息中间件底层架构原理(RabbitMQ、RockerMQ、Kafka)、Redis缓存、MySQL关系型数据库、 ElasticSearch全文搜索、MongoDB非关系型数据库、Apache ShardingSphere分库分表读写分离、设计模式、领域驱动DDD、Kubernetes容器编排等。

📙有过从0到1的项目高并发项目开发与管理经验,对JVM调优、MySQL调优、Redis调优 、ElasticSearch调优、消息中间件调优、系统架构调优都有着比较全面的实战经验。

📘有过云端搭建服务器环境,自动化部署CI/CD,弹性伸缩扩容服务器(最高200台),了解过秒级部署(阿里云的ACK和华为云的云容器引擎CCE)流程,能独立开发和部署整个后端服务,有过分库分表的实战经验。

🎥经过多年在CSDN创作上千篇文章的经验积累,我已经拥有了不错的写作技巧,与清华大学出版社签下了四本书籍的合约,并将陆续在明年出版。这些书籍包括了基础篇、进阶篇、架构篇的📌《Java项目实战—深入理解大型互联网企业通用技术》📌,以及📚《解密程序员的思维密码–沟通、演讲、思考的实践》📚。具体出版计划会根据实际情况进行调整,希望各位读者朋友能够多多支持!


文章目录

  • 🔊博主介绍
  • 🥤本文内容
    • 规划集群
    • 准备工作
    • 节点0配置(ip地址为192.168.80.101的机器)
    • 节点1配置(ip地址为192.168.80.102的机器)
    • 节点2配置(ip地址为192.168.80.103的机器)
    • 在所有节点机器上执行
    • 控制面板
  • 📢文章总结
  • 📥博主目标

🌾阅读前,快速浏览目录和章节概览可帮助了解文章结构、内容和作者的重点。了解自己希望从中获得什么样的知识或经验是非常重要的。建议在阅读时做笔记、思考问题、自我提问,以加深理解和吸收知识。

💡在这个美好的时刻,本人不再啰嗦废话,现在毫不拖延地进入文章所要讨论的主题。接下来,我将为大家呈现正文内容。

🥤本文内容

CSDN
首先,需要在Docker-Compose中创建两个RocketMQ Broker容器,一个作为主节点,另一个作为从节点。主从节点之间的数据同步可以通过Dledger实现。以下是详细的步骤:

规划集群

准备好三台机器:
节点0:192.168.80.101
节点1:192.168.80.102
节点2:192.168.80.103

准备工作

在所有机器上执行以下操作:
安装配置JDK,根据实际情况选择版本,注意JDK的版本和RocketMQ的版本是否匹配。

节点0配置(ip地址为192.168.80.101的机器)

创建rocket目录,代码如下:

mkdir -p /opt/software/rocketmqcluster

进入到rocketmq目录,代码如下:

cd /opt/software/rocketmqcluster

创建rocket存储、日志、配置目录,代码如下:

mkdir -p /opt/software/rocketmqcluster/data/broker-n{0..2}/store
mkdir -p /opt/software/rocketmqcluster/data/broker-n{0..2}/conf
mkdir -p /opt/software/rocketmqcluster/data/broker-n{0..2}/logs
mkdir -p /opt/software/rocketmqcluster/data/broker-n{0..2}/commitlog

编辑broker-n0的broker属性文件,代码如下:

vi /opt/software/rocketmqcluster/data/broker-n0/conf/broker.properties

添加配置,代码如下:

# broker名,名称一样的节点就是一组主从节点。
brokerName=broker0
# broker对外服务的监听端口
listenPort=30911
# 所属集群名,名称一样的节点就在同一个集群内
brokerClusterName=DefaultCluster
# brokerid,0就表示是Master>0的都是表示Slave
brokerId=0
# 删除文件时间点,默认凌晨4点
deleteWhen=04
# 文件保留时间,默认48 小时
fileReservedTime=48
# broker角色,ASYNC_MASTER异步复制MasterSYNC_MASTER同步双写MasterSLAVE
brokerRole=ASYNC_MASTER
# 刷盘方式,ASYNC_FLUSH异步刷盘,SYNC_FLUSH同步刷盘
flushDiskType=ASYNC_FLUSH
# broker ip多网卡配置,容器配置宿主机网卡ip
brokerIP1=192.168.80.101
# name-server地址,分号间隔
namesrvAddr=192.168.80.101:9876;192.168.80.102:9876;192.168.80.103:9876;
# 存储路径
storePathRootDir=/home/rocketmq/store
# commitLog存储路径
storePathCommitLog=/home/rocketmq/commitlog
# 是否允许broker自动创建Topic
autoCreateTopicEnable=true
# 是否允许broker自动创建订阅组
autoCreateSubscriptionGroup=true
# 是否启动DLedger
enableDLegerCommitLog=true
# DLedger Raft Group的名字,建议和brokerName保持一致
dLegerGroup=broker0
# DLedger Group内各节点的端口信息,同一个Group内的各个节点配置必须要保证一致
dLegerPeers=n0-192.168.80.101:40911;n1-192.168.80.102:40911;n2-192.168.80.103:40911
# 节点id, 必须属于dLegerPeers中的一个;同Group内各个节点要唯一
dLegerSelfId=n0

编辑broker-n1的broker属性文件,代码如下:

vi /opt/software/rocketmqcluster/data/broker-n1/conf/broker.properties

添加配置,代码如下:

brokerName=broker1
listenPort=30912
brokerClusterName=DefaultCluster
brokerId=1
deleteWhen=04
fileReservedTime=48
brokerRole=ASYNC_MASTER
flushDiskType=ASYNC_FLUSH
brokerIP1=192.168.80.101
namesrvAddr=192.168.80.101:9876;192.168.80.102:9876;192.168.80.103:9876;
storePathRootDir=/home/rocketmq/store
storePathCommitLog=/home/rocketmq/commitlog
autoCreateTopicEnable=true
autoCreateSubscriptionGroup=true
enableDLegerCommitLog=true
dLegerGroup=broker1
dLegerPeers=n0-192.168.80.101:40912;n1-192.168.80.102:40912;n2-192.168.80.103:40912
dLegerSelfId=n0

编辑broker-n2的broker属性文件,代码如下:

vi /opt/software/rocketmqcluster/data/broker-n2/conf/broker.properties

添加配置,代码如下:

brokerName=broker2
listenPort=30913
brokerClusterName=DefaultCluster
brokerId=2
deleteWhen=04
fileReservedTime=48
brokerRole=ASYNC_MASTER
flushDiskType=ASYNC_FLUSH
brokerIP1=192.168.80.101
namesrvAddr=192.168.80.101:9876;192.168.80.102:9876;192.168.80.103:9876;
storePathRootDir=/home/rocketmq/store
storePathCommitLog=/home/rocketmq/commitlog
autoCreateTopicEnable=true
autoCreateSubscriptionGroup=true
enableDLegerCommitLog=true
dLegerGroup=broker2
dLegerPeers=n0-192.168.80.101:40913;n1-192.168.80.102:40913;n2-192.168.80.103:40913
dLegerSelfId=n0

创建docker-compose.yaml文件,代码如下:

vi /opt/software/rocketmqcluster/docker-compose.yaml

添加配置,代码如下:

version: '3.5'
services:
  namesrv:
    restart: always
    image: apache/rocketmq:4.9.4
    container_name: namesrv
    ports:
      - 9876:9876
    environment:
      - JAVA_OPT_EXT=-Duser.home=/home/rocketmq -Xms512m -Xmx512m -Xmn256m -XX:InitiatingHeapOccupancyPercent=30 -XX:+PrintGCDetails -XX:+PrintGCDateStamps -XX:+PrintGCApplicationStoppedTime -XX:+PrintAdaptiveSizePolicy -XX:+UseGCLogFileRotation -XX:NumberOfGCLogFiles=5 -XX:GCLogFileSize=30m -XX:SoftRefLRUPolicyMSPerMB=0 -verbose:gc 
      - TZ=Asia/Shanghai
    volumes:
      - /opt/software/rocketmqcluster/data/namesrv/logs:/home/rocketmq/logs/rocketmqlogs/rocketmqlogs
    command: sh mqnamesrv
  broker-n0:
    restart: always
    image: apache/rocketmq:4.9.4
    container_name: broker-n0
    ports:
      - 30911:30911
      - 40911:40911
    environment:
      - NAMESRV_ADDR=192.168.80.101:9876;192.168.80.102:9876;192.168.80.103:9876;
      - JAVA_OPT_EXT=-Duser.home=/home/rocketmq -Xms512m -Xmx512m -Xmn256m -XX:InitiatingHeapOccupancyPercent=30 -XX:+PrintGCDetails -XX:+PrintGCDateStamps -XX:+PrintGCApplicationStoppedTime -XX:+PrintAdaptiveSizePolicy -XX:+UseGCLogFileRotation -XX:NumberOfGCLogFiles=5 -XX:GCLogFileSize=30m -XX:SoftRefLRUPolicyMSPerMB=0 -verbose:gc 
      - TZ=Asia/Shanghai
    volumes:
      - /opt/software/rocketmqcluster/data/broker-n0/logs:/home/rocketmq/logs/rocketmqlogs
      - /opt/software/rocketmqcluster/data/broker-n0/store:/home/rocketmq/store
      - /opt/software/rocketmqcluster/data/broker-n0/commitlog:/home/rocketmq/commitlog
      - /opt/software/rocketmqcluster/data/broker-n0/conf/broker.properties:/home/rocketmq/conf/broker.properties
    command: sh mqbroker -c /home/rocketmq/conf/broker.properties
  broker-n1:
    restart: always
    image: apache/rocketmq:4.9.4
    container_name: broker-n1
    ports:
      - 30912:30912
      - 40912:40912
    environment:
      - NAMESRV_ADDR=192.168.80.101:9876;192.168.80.102:9876;192.168.80.103:9876;
      - JAVA_OPT_EXT=-Duser.home=/home/rocketmq -Xms512m -Xmx512m -Xmn256m -XX:InitiatingHeapOccupancyPercent=30 -XX:+PrintGCDetails -XX:+PrintGCDateStamps -XX:+PrintGCApplicationStoppedTime -XX:+PrintAdaptiveSizePolicy -XX:+UseGCLogFileRotation -XX:NumberOfGCLogFiles=5 -XX:GCLogFileSize=30m -XX:SoftRefLRUPolicyMSPerMB=0 -verbose:gc 
      - TZ=Asia/Shanghai
    volumes:
      - /opt/software/rocketmqcluster/data/broker-n1/logs:/home/rocketmq/logs/rocketmqlogs
      - /opt/software/rocketmqcluster/data/broker-n1/store:/home/rocketmq/store
      - /opt/software/rocketmqcluster/data/broker-n1/commitlog:/home/rocketmq/commitlog
      - /opt/software/rocketmqcluster/data/broker-n1/conf/broker.properties:/home/rocketmq/conf/broker.properties
    command: sh mqbroker -c /home/rocketmq/conf/broker.properties
  broker-n2:
    restart: always
    image: apache/rocketmq:4.9.4
    container_name: broker-n2
    ports:
      - 30913:30913
      - 40913:40913
    environment:
      - NAMESRV_ADDR=192.168.80.101:9876;192.168.80.102:9876;192.168.80.103:9876;
      - JAVA_OPT_EXT=-Duser.home=/home/rocketmq -Xms512m -Xmx512m -Xmn256m -XX:InitiatingHeapOccupancyPercent=30 -XX:+PrintGCDetails -XX:+PrintGCDateStamps -XX:+PrintGCApplicationStoppedTime -XX:+PrintAdaptiveSizePolicy -XX:+UseGCLogFileRotation -XX:NumberOfGCLogFiles=5 -XX:GCLogFileSize=30m -XX:SoftRefLRUPolicyMSPerMB=0 -verbose:gc 
      - TZ=Asia/Shanghai
    volumes:
      - /opt/software/rocketmqcluster/data/broker-n2/logs:/home/rocketmq/logs/rocketmqlogs
      - /opt/software/rocketmqcluster/data/broker-n2/store:/home/rocketmq/store
      - /opt/software/rocketmqcluster/data/broker-n2/commitlog:/home/rocketmq/commitlog
      - /opt/software/rocketmqcluster/data/broker-n2/conf/broker.properties:/home/rocketmq/conf/broker.properties
    command: sh mqbroker -c /home/rocketmq/conf/broker.properties
# 网络声明
networks:
  rmq:
    name: rmq # 指定网络名称
    driver: bridge # 指定网络驱动程序
# 通用日志设置
x-logging:
    &default-logging
    # 日志大小和数量
    options:
        max-size: "100m"
        max-file: "3"
    # 文件存储类型
    driver: json-file

节点1配置(ip地址为192.168.80.102的机器)

mkdir -p /opt/software/rocketmqcluster

进入到rocketmq目录,代码如下:

cd /opt/software/rocketmqcluster

创建rocket存储、日志、配置目录,代码如下:

mkdir -p /opt/software/rocketmqcluster/data/broker-n{0..2}/store
mkdir -p /opt/software/rocketmqcluster/data/broker-n{0..2}/conf
mkdir -p /opt/software/rocketmqcluster/data/broker-n{0..2}/logs
mkdir -p /opt/software/rocketmqcluster/data/broker-n{0..2}/commitlog

节点1的配置:

vi /opt/software/rocketmqcluster/data/broker-n0/conf/broker.properties
brokerName=broker0
listenPort=30911
brokerClusterName=DefaultCluster
brokerId=1
deleteWhen=04
fileReservedTime=48
brokerRole=ASYNC_MASTER
flushDiskType=ASYNC_FLUSH
brokerIP1=192.168.80.102
namesrvAddr=192.168.80.101:9876;192.168.80.102:9876;192.168.80.103:9876
storePathRootDir=/home/rocketmq/store
storePathCommitLog=/home/rocketmq/commitlog
autoCreateTopicEnable=true
autoCreateSubscriptionGroup=true
enableDLegerCommitLog=true
dLegerGroup=broker0
dLegerPeers=n0-192.168.80.101:40911;n1-192.168.80.102:40911;n2-192.168.80.103:40911
dLegerSelfId=n1
vi /opt/software/rocketmqcluster/data/broker-n1/conf/broker.properties
brokerName=broker1
listenPort=30912
brokerClusterName=DefaultCluster
brokerId=0
deleteWhen=04
fileReservedTime=48
brokerRole=ASYNC_MASTER
flushDiskType=ASYNC_FLUSH
brokerIP1=192.168.80.102
namesrvAddr=192.168.80.101:9876;192.168.80.102:9876;192.168.80.103:9876
storePathRootDir=/home/rocketmq/store
storePathCommitLog=/home/rocketmq/commitlog
autoCreateTopicEnable=true
autoCreateSubscriptionGroup=true
enableDLegerCommitLog=true
dLegerGroup=broker1
dLegerPeers=n0-192.168.80.101:40912;n1-192.168.80.102:40912;n2-192.168.80.103:40912
dLegerSelfId=n1
vi /opt/software/rocketmqcluster/data/broker-n2/conf/broker.properties
brokerName=broker2
listenPort=30913
brokerClusterName=DefaultCluster
brokerId=2
deleteWhen=04
fileReservedTime=48
brokerRole=ASYNC_MASTER
flushDiskType=ASYNC_FLUSH
brokerIP1=192.168.80.102
namesrvAddr=192.168.80.101:9876;192.168.80.102:9876;192.168.80.103:9876
storePathRootDir=/home/rocketmq/store
storePathCommitLog=/home/rocketmq/commitlog
autoCreateTopicEnable=true
autoCreateSubscriptionGroup=true
enableDLegerCommitLog=true
dLegerGroup=broker2
dLegerPeers=n0-192.168.80.101:40913;n1-192.168.80.102:40913;n2-192.168.80.103:40913
dLegerSelfId=n1
vi /opt/software/rocketmqcluster/docker-compose.yaml
version: '3.5'
services:
  namesrv:
    restart: always
    image: apache/rocketmq:5.1.3
    container_name: namesrv
    ports:
      - 9876:9876
    environment:
      - JAVA_OPT_EXT=-Duser.home=/home/rocketmq -Xms512m -Xmx512m -Xmn256m -XX:InitiatingHeapOccupancyPercent=30 -XX:+PrintGCDetails -XX:+PrintGCDateStamps -XX:+PrintGCApplicationStoppedTime -XX:+PrintAdaptiveSizePolicy -XX:+UseGCLogFileRotation -XX:NumberOfGCLogFiles=5 -XX:GCLogFileSize=30m -XX:SoftRefLRUPolicyMSPerMB=0 -verbose:gc 
      - TZ=Asia/Shanghai
    volumes:
      - /opt/software/rocketmqcluster/data/namesrv/logs:/home/rocketmq/logs/rocketmqlogs
    command: sh mqnamesrv
  broker-n0:
    restart: always
    image: apache/rocketmq:5.1.3
    container_name: broker-n0
    ports:
      - 30911:30911
      - 40911:40911
    environment:
      - NAMESRV_ADDR=192.168.80.101:9876;192.168.80.102:9876;192.168.80.103:9876
      - JAVA_OPT_EXT=-Duser.home=/home/rocketmq -Xms512m -Xmx512m -Xmn256m -XX:InitiatingHeapOccupancyPercent=30 -XX:+PrintGCDetails -XX:+PrintGCDateStamps -XX:+PrintGCApplicationStoppedTime -XX:+PrintAdaptiveSizePolicy -XX:+UseGCLogFileRotation -XX:NumberOfGCLogFiles=5 -XX:GCLogFileSize=30m -XX:SoftRefLRUPolicyMSPerMB=0 -verbose:gc 
      - TZ=Asia/Shanghai
    volumes:
      - /opt/software/rocketmqcluster/data/broker-n0/logs:/home/rocketmq/logs/rocketmqlogs
      - /opt/software/rocketmqcluster/data/broker-n0/store:/home/rocketmq/store
      - /opt/software/rocketmqcluster/data/broker-n0/commitlog:/home/rocketmq/commitlog
      - /opt/software/rocketmqcluster/data/broker-n0/conf/broker.properties:/home/rocketmq/conf/broker.properties
    command: sh mqbroker -c /home/rocketmq/conf/broker.properties
  broker-n1:
    restart: always
    image: apache/rocketmq:5.1.3
    container_name: broker-n1
    ports:
      - 30912:30912
      - 40912:40912
    environment:
      - NAMESRV_ADDR=192.168.80.101:9876;192.168.80.102:9876;192.168.80.103:9876
      - JAVA_OPT_EXT=-Duser.home=/home/rocketmq -Xms512m -Xmx512m -Xmn256m -XX:InitiatingHeapOccupancyPercent=30 -XX:+PrintGCDetails -XX:+PrintGCDateStamps -XX:+PrintGCApplicationStoppedTime -XX:+PrintAdaptiveSizePolicy -XX:+UseGCLogFileRotation -XX:NumberOfGCLogFiles=5 -XX:GCLogFileSize=30m -XX:SoftRefLRUPolicyMSPerMB=0 -verbose:gc 
      - TZ=Asia/Shanghai
    volumes:
      - /opt/software/rocketmqcluster/data/broker-n1/logs:/home/rocketmq/logs/rocketmqlogs
      - /opt/software/rocketmqcluster/data/broker-n1/store:/home/rocketmq/store
      - /opt/software/rocketmqcluster/data/broker-n1/commitlog:/home/rocketmq/commitlog
      - /opt/software/rocketmqcluster/data/broker-n1/conf/broker.properties:/home/rocketmq/conf/broker.properties
    command: sh mqbroker -c /home/rocketmq/conf/broker.properties
  broker-n2:
    restart: always
    image: apache/rocketmq:5.1.3
    container_name: broker-n2
    ports:
      - 30913:30913
      - 40913:40913
    environment:
      - NAMESRV_ADDR=192.168.80.101:9876;192.168.80.102:9876;192.168.80.103:9876
      - JAVA_OPT_EXT=-Duser.home=/home/rocketmq -Xms512m -Xmx512m -Xmn256m -XX:InitiatingHeapOccupancyPercent=30 -XX:+PrintGCDetails -XX:+PrintGCDateStamps -XX:+PrintGCApplicationStoppedTime -XX:+PrintAdaptiveSizePolicy -XX:+UseGCLogFileRotation -XX:NumberOfGCLogFiles=5 -XX:GCLogFileSize=30m -XX:SoftRefLRUPolicyMSPerMB=0 -verbose:gc 
      - TZ=Asia/Shanghai
    volumes:
      - /opt/software/rocketmqcluster/data/broker-n2/logs:/home/rocketmq/logs/rocketmqlogs
      - /opt/software/rocketmqcluster/data/broker-n2/store:/home/rocketmq/store
      - /opt/software/rocketmqcluster/data/broker-n2/commitlog:/home/rocketmq/commitlog
      - /opt/software/rocketmqcluster/data/broker-n2/conf/broker.properties:/home/rocketmq/conf/broker.properties
    command: sh mqbroker -c /home/rocketmq/conf/broker.properties
# 网络声明
networks:
  rmq:
    name: rmq # 指定网络名称
    driver: bridge # 指定网络驱动程序
# 通用日志设置
x-logging:
    &default-logging
    # 日志大小和数量
    options:
        max-size: "100m"
        max-file: "3"
    # 文件存储类型
    driver: json-file

节点2配置(ip地址为192.168.80.103的机器)

mkdir -p /opt/software/rocketmqcluster

进入到rocketmq目录,代码如下:

cd /opt/software/rocketmqcluster

创建rocket存储、日志、配置目录,代码如下:

mkdir -p /opt/software/rocketmqcluster/data/broker-n{0..2}/store
mkdir -p /opt/software/rocketmqcluster/data/broker-n{0..2}/conf
mkdir -p /opt/software/rocketmqcluster/data/broker-n{0..2}/logs
mkdir -p /opt/software/rocketmqcluster/data/broker-n{0..2}/commitlog

节点2的配置:

vi /opt/software/rocketmqcluster/data/broker-n0/conf/broker.properties
brokerName=broker0
listenPort=30911
brokerClusterName=DefaultCluster
brokerId=2
deleteWhen=04
fileReservedTime=48
brokerRole=ASYNC_MASTER
flushDiskType=ASYNC_FLUSH
brokerIP1=192.168.80.103
namesrvAddr=192.168.80.101:9876;192.168.80.102:9876;192.168.80.103:9876
storePathRootDir=/home/rocketmq/store
storePathCommitLog=/home/rocketmq/commitlog
autoCreateTopicEnable=true
autoCreateSubscriptionGroup=true
enableDLegerCommitLog=true
dLegerGroup=broker0
dLegerPeers=n0-192.168.80.101:40911;n1-192.168.80.102:40911;n2-192.168.80.103:40911
dLegerSelfId=n2
vi /opt/software/rocketmqcluster/data/broker-n1/conf/broker.properties
brokerName=broker1
listenPort=30912
brokerClusterName=DefaultCluster
brokerId=1
deleteWhen=04
fileReservedTime=48
brokerRole=ASYNC_MASTER
flushDiskType=ASYNC_FLUSH
brokerIP1=192.168.80.103
namesrvAddr=192.168.80.101:9876;192.168.80.102:9876;192.168.80.103:9876
storePathRootDir=/home/rocketmq/store
storePathCommitLog=/home/rocketmq/commitlog
autoCreateTopicEnable=true
autoCreateSubscriptionGroup=true
enableDLegerCommitLog=true
dLegerGroup=broker1
dLegerPeers=n0-192.168.80.101:40912;n1-192.168.80.102:40912;n2-192.168.80.103:40912
dLegerSelfId=n2
vi /opt/software/rocketmqcluster/data/broker-n2/conf/broker.properties
brokerName=broker2
listenPort=30913
brokerClusterName=DefaultCluster
brokerId=0
deleteWhen=04
fileReservedTime=48
brokerRole=ASYNC_MASTER
flushDiskType=ASYNC_FLUSH
brokerIP1=192.168.80.103
namesrvAddr=192.168.80.101:9876;192.168.80.102:9876;192.168.80.103:9876
storePathRootDir=/home/rocketmq/store
storePathCommitLog=/home/rocketmq/commitlog
autoCreateTopicEnable=true
autoCreateSubscriptionGroup=true
enableDLegerCommitLog=true
dLegerGroup=broker2
dLegerPeers=n0-192.168.80.101:40913;n1-192.168.80.102:40913;n2-192.168.80.103:40913
dLegerSelfId=n2
vi /opt/software/rocketmqcluster/docker-compose.yaml
version: '3.5'
services:
  namesrv:
    restart: always
    image: apache/rocketmq:5.1.3
    container_name: namesrv 
    ports:
      - 9876:9876
    environment:
      - JAVA_OPT_EXT=-Duser.home=/home/rocketmq -Xms512m -Xmx512m -Xmn256m -XX:InitiatingHeapOccupancyPercent=30 -XX:+PrintGCDetails -XX:+PrintGCDateStamps -XX:+PrintGCApplicationStoppedTime -XX:+PrintAdaptiveSizePolicy -XX:+UseGCLogFileRotation -XX:NumberOfGCLogFiles=5 -XX:GCLogFileSize=30m -XX:SoftRefLRUPolicyMSPerMB=0 -verbose:gc 
      - TZ=Asia/Shanghai
    volumes:
      - /opt/software/rocketmqcluster/data/namesrv/logs:/home/rocketmq/logs/rocketmqlogs
    command: sh mqnamesrv
  broker-n0:
    restart: always
    image: apache/rocketmq:5.1.3
    container_name: broker-n0
    ports:
      - 30911:30911
      - 40911:40911
    environment:
      - NAMESRV_ADDR=192.168.80.101:9876;192.168.80.102:9876;192.168.80.103:9876
      - JAVA_OPT_EXT=-Duser.home=/home/rocketmq -Xms512m -Xmx512m -Xmn256m -XX:InitiatingHeapOccupancyPercent=30 -XX:+PrintGCDetails -XX:+PrintGCDateStamps -XX:+PrintGCApplicationStoppedTime -XX:+PrintAdaptiveSizePolicy -XX:+UseGCLogFileRotation -XX:NumberOfGCLogFiles=5 -XX:GCLogFileSize=30m -XX:SoftRefLRUPolicyMSPerMB=0 -verbose:gc 
      - TZ=Asia/Shanghai
    volumes:
      - /opt/software/rocketmqcluster/data/broker-n0/logs:/home/rocketmq/logs/rocketmqlogs
      - /opt/software/rocketmqcluster/data/broker-n0/store:/home/rocketmq/store
      - /opt/software/rocketmqcluster/data/broker-n0/commitlog:/home/rocketmq/commitlog
      - /opt/software/rocketmqcluster/data/broker-n0/conf/broker.properties:/home/rocketmq/conf/broker.properties
    command: sh mqbroker -c /home/rocketmq/conf/broker.properties
  broker-n1:
    restart: always
    image: apache/rocketmq:5.1.3
    container_name: broker-n1
    ports:
      - 30912:30912
      - 40912:40912
    environment:
      - NAMESRV_ADDR=192.168.80.101:9876;192.168.80.102:9876;192.168.80.103:9876
      - JAVA_OPT_EXT=-Duser.home=/home/rocketmq -Xms512m -Xmx512m -Xmn256m -XX:InitiatingHeapOccupancyPercent=30 -XX:+PrintGCDetails -XX:+PrintGCDateStamps -XX:+PrintGCApplicationStoppedTime -XX:+PrintAdaptiveSizePolicy -XX:+UseGCLogFileRotation -XX:NumberOfGCLogFiles=5 -XX:GCLogFileSize=30m -XX:SoftRefLRUPolicyMSPerMB=0 -verbose:gc 
      - TZ=Asia/Shanghai
    volumes:
      - /opt/software/rocketmqcluster/data/broker-n1/logs:/home/rocketmq/logs/rocketmqlogs
      - /opt/software/rocketmqcluster/data/broker-n1/store:/home/rocketmq/store
      - /opt/software/rocketmqcluster/data/broker-n1/commitlog:/home/rocketmq/commitlog
      - /opt/software/rocketmqcluster/data/broker-n1/conf/broker.properties:/home/rocketmq/conf/broker.properties
    command: sh mqbroker -c /home/rocketmq/conf/broker.properties
  broker-n2:
    restart: always
    image: apache/rocketmq:5.1.3
    container_name: broker-n2
    ports: 
      - 30913:30913
      - 40913:40913
    environment:
      - NAMESRV_ADDR=192.168.80.101:9876;192.168.80.102:9876;192.168.80.103:9876
      - JAVA_OPT_EXT=-Duser.home=/home/rocketmq -Xms512m -Xmx512m -Xmn256m -XX:InitiatingHeapOccupancyPercent=30 -XX:+PrintGCDetails -XX:+PrintGCDateStamps -XX:+PrintGCApplicationStoppedTime -XX:+PrintAdaptiveSizePolicy -XX:+UseGCLogFileRotation -XX:NumberOfGCLogFiles=5 -XX:GCLogFileSize=30m -XX:SoftRefLRUPolicyMSPerMB=0 -verbose:gc 
      - TZ=Asia/Shanghai
    volumes:
      - /opt/software/rocketmqcluster/data/broker-n2/logs:/home/rocketmq/logs/rocketmqlogs
      - /opt/software/rocketmqcluster/data/broker-n2/store:/home/rocketmq/store
      - /opt/software/rocketmqcluster/data/broker-n2/commitlog:/home/rocketmq/commitlog
      - /opt/software/rocketmqcluster/data/broker-n2/conf/broker.properties:/home/rocketmq/conf/broker.properties
    command: sh mqbroker -c /home/rocketmq/conf/broker.properties
  console:
    restart: always
    image: apacherocketmq/rocketmq-dashboard
    container_name: console
    ports:
      - 19081:8080
    environment:
        TZ: "Asia/Shanghai"
        JAVA_OPTS: "-Drocketmq.namesrv.addr=192.168.80.101:9876;192.168.80.102:9876;192.168.80.103:9876 -Dcom.rocketmq.sendMessageWithVIPChannel=false"
    depends_on:
      - namesrv
# 网络声明
networks:
  rmq:
    name: rmq # 指定网络名称
    driver: bridge # 指定网络驱动程序
# 通用日志设置
x-logging:
    &default-logging
    # 日志大小和数量
    options:
        max-size: "100m"
        max-file: "3"
    # 文件存储类型
    driver: json-file

在所有节点机器上执行

以下命令:
进入/opt/software/rocketmqcluster目录

cd /opt/software/rocketmqcluster

给data目录赋可读可写可执行权限

chmod -R 777 ./data
chmod -R 777 ./docker-compose.yaml

在后台启动docker-compose服务

docker-compose up -d

显示所有docker-compose管理的容器状态

docker-compose ps

查看日志输出

docker-compose logs

停止并移除容器

docker stop namesrv broker-n2 broker-n1 broker-n0 && docker rm namesrv broker-n2 broker-n1 broker-n0 && rm -rf data/
docker stop namesrv broker-n2 broker-n1 broker-n0 console && docker rm namesrv broker-n2 broker-n1 broker-n0 console && rm -rf data/

防火墙端口需要注意开放:
在这里插入图片描述

控制面板

如果需要在单独服务器上部署一个控制面板,观察MQ集群情况,则添加以下docker-compose.yaml配置文件:

version: '3.5'
services:
  console:
    restart: always
    image: apacherocketmq/rocketmq-dashboard
    container_name: console
    ports:
      - 19081:8080
    environment:
        TZ: "Asia/Shanghai"
        JAVA_OPTS: "-Drocketmq.namesrv.addr=192.168.80.101:9876;192.168.80.102:9876;192.168.80.103:9876 -Dcom.rocketmq.sendMessageWithVIPChannel=false"

CSDN

📢文章总结

对本篇文章进行总结:

🔔以上就是今天要讲的内容,阅读结束后,反思和总结所学内容,并尝试应用到现实中,有助于深化理解和应用知识。与朋友或同事分享所读内容,讨论细节并获得反馈,也有助于加深对知识的理解和吸收。

以梦为马,不负韶华

🔔如果您需要转载或者搬运这篇文章的话,非常欢迎您私信我哦~

🚀🎉希望各位读者大大多多支持用心写文章的博主,现在时代变了,🚀🎉 信息爆炸,酒香也怕巷子深🔥,博主真的需要大家的帮助才能在这片海洋中继续发光发热🎨,所以,🏃💨赶紧动动你的小手,点波关注❤️,点波赞👍,点波收藏⭐,甚至点波评论✍️,都是对博主最好的支持和鼓励!

  • 💂 博客主页: 我是廖志伟
  • 👉开源项目:java_wxid
  • 🌥 哔哩哔哩:我是廖志伟
  • 🎏个人社区:幕后大佬
  • 🔖个人微信号SeniorRD
  • 🎉微信号二维码SeniorRD

📥博主目标

探寻内心世界,博主分享人生感悟与未来目标

  • 🍋程序开发这条路不能停,停下来容易被淘汰掉,吃不了自律的苦,就要受平庸的罪,持续的能力才能带来持续的自信。我本是一个很普通的程序员,放在人堆里,除了与生俱来的盛世美颜,就剩180的大高个了,就是我这样的一个人,默默写博文也有好多年了。
  • 📺有句老话说的好,牛逼之前都是傻逼式的坚持,希望自己可以通过大量的作品、时间的积累、个人魅力、运气、时机,可以打造属于自己的技术影响力。
  • 💥内心起伏不定,我时而激动,时而沉思。我希望自己能成为一个综合性人才,具备技术、业务和管理方面的精湛技能。我想成为产品架构路线的总设计师,团队的指挥者,技术团队的中流砥柱,企业战略和资本规划的实战专家。
  • 🎉这个目标的实现需要不懈的努力和持续的成长,但我必须努力追求。因为我知道,只有成为这样的人才,我才能在职业生涯中不断前进并为企业的发展带来真正的价值。在这个不断变化的时代,我们必须随时准备好迎接挑战,不断学习和探索新的领域,才能不断地向前推进。我坚信,只要我不断努力,我一定会达到自己的目标。

🔔有需要对自己进行综合性评估,进行职业方向规划,我可以让技术大牛帮你模拟面试、针对性的指导、传授面试技巧、简历优化、进行技术问题答疑等服务。

可访问:https://java_wxid.gitee.io/tojson/

开发人员简历优化、面试突击指导、技术问题解答

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

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

相关文章

Ethernet/IP转Modbus TCP网关

产品功能 1 YC-EIP-TCP工业级EtherNet/IP 网关 2 Modbus TCP 转 EtherNet/IP 3支持ModBus主从站 4 即插即用 无需编程 轻松组态 ,即实现数据交互 5导轨安装 支持提供EDS文件 6 EtherNET/IP与ModBus互转数据透明传输可接入PLC组态 支持CodeSys/支持欧姆龙PLC 支持罗克韦尔(AB) 典…

M.2接口 KEY A、B、E、M介绍

参考:M.2、mSATA、NGFF、miniPCI-e接口引脚定义_m.2接口定义-CSDN博客 https://www.mouser.com/datasheet/2/418/9/ENG_DS_1_1773702_1NGFFQRG_EN_0214_1_1773702_1NGFF_-3328389.pdf 抖动的声音:dilo_Abel 视频号:dilo_Abel的个人空间-di…

【MATLAB】小波 MFE_SVM_LSTM 神经网络时序预测算法

有意向获取代码,请转文末观看代码获取方式~也可转原文链接获取~ 1 基本定义 小波MFE_SVM_LSTM神经网络时序预测算法是一种结合了小波变换、多尺度特征提取(MFE)、支持向量机(SVM)和长短期记忆神经网络(LST…

Vue3前端实现一个本地消息队列(MQ), 让消息延迟消费或者做缓存

MQ功能实现的具体代码(TsMQ.ts): import { v4 as uuidx } from uuid;import emitter from /utils/mitt// 消息类 class Message {// 过期时间,0表示马上就消费exp: number;// 消费标识,避免重复消费tag : string;// 消息体body : any;constr…

Stable Diffusion 绘画入门教程(webui)-ControlNet(Shuffle)

Shuffle(随机洗牌),这个预处理器会把参考图的颜色打乱搅拌到一起,然后重新组合的方式重新生成一张图,可以想象出来这是一个整体风格控制的处理器。 那么问题来了,官方为啥会设计个这样的处理器呢,主要是给懒人用的&am…

谷歌发布世界模型,能生成可交互虚拟世界;华为发布全球首个 5.5G 智能核心网丨 RTE 开发者日报 Vol.152

开发者朋友们大家好: 这里是「RTE 开发者日报」,每天和大家一起看新闻、聊八卦。我们的社区编辑团队会整理分享 RTE (Real Time Engagement) 领域内「有话题的新闻」、「有态度的观点」、「有意思的数据」、「有思考的文章」、「…

跨越人生的河流,重温读书的时光—社科院与杜兰大学金融管理硕士

我们都曾有过读书的时光,那些曾经的岁月,或许已经远去,但读书带给我们的影响却永远不会消失。它不仅让我们获取了知识,更让我们学会了思考、表达和沟通。这些能力在我们日后的工作和生活中发挥着巨大的作用,让我们更加…

【Android移动开发】Windows10平台安装Android Studio与人工智能算法模型部署案例

目录 一、Android Studio下载地址二、开发环境JDK三、开始安装Android Studio四、案例展示与搭建五、人工智能算法模型移动端部署案例参考 一、Android Studio下载地址 https://developer.android.google.cn/studio/install.html 电脑配置要求: 下载保存在指定文…

【Python笔记-设计模式】命令模式

一、说明 命令模式是一种行为设计模式,旨在对命令的封装,根据不同的请求将方法参数化、延迟请求执行或将其放入队列中,且能实现可撤销操作。 (一) 解决问题 将请求发送者和接受者解耦,请求发送者只需知道如何发送请求&#xff…

P1450 [HAOI2008] 硬币购物 dp 容斥 —— s - c[i]*(d[i]+1)怎么理解

[HAOI2008] 硬币购物 - 洛谷 看了洛谷许多题解,一开始理解不了为什么是 s - c[i]*(d[i]1),为什么要1呢? 其实是dp理解的不好。 这里的意思就是该枚硬币先超过限制,接下来剩下的背包也要填满,4种硬币随便组合的情况数…

Open CASCADE学习|视图

目录 Mainwin.h Mainwin.cpp Mainwin.h ​#pragma once#include <QtWidgets/QMainWindow>#include "Displaywin.h"#include "OCC.h"class Mainwin : public QMainWindow{ Q_OBJECTpublic: Mainwin(QWidget* parent nullptr); ~Mainwin();​pri…

BTC网络 vs ETH网络

设计理念 BTC 网络 比特币是一种数字货币&#xff0c;旨在作为一种去中心化的、不受政府或金融机构控制的电子货币。其主要目标是实现安全的价值传输和储存&#xff0c;比特币的设计强调去中心化和抗审查。 ETH 网络 以太坊是一个智能合约平台&#xff0c;旨在支持分散的应…

深入探究Nginx的使用方法

目录 引言 一、网络状态页 二、Nginx 第三方模块 三、变量 &#xff08;一&#xff09;内置变量 &#xff08;二&#xff09;自定义变量 四、自定义日志 &#xff08;一&#xff09;有关日志的配置信息 &#xff08;二&#xff09;error日志的设置 1.日志的等级 2.自…

RT-Thread 自动初始化

最近的程序设计中用到了RT-Thread中的自动初始化&#xff0c;用起来也非常容易&#xff0c;一个宏就解决了&#xff0c;但是原理是什么呢&#xff1f;下面我们一起来学习&#xff1a; 1.1、一般情况的初始化调用 一般情况下&#xff0c;系统中的初始化会这样做&#xff0c;应该…

如何使用 OpenAI Sora?

Sora - 探索AI视频模型的无限可能 OpenAI 的最新项目名为 Sora&#xff0c;这是一个强大的文本到视频模型&#xff0c;可以根据简单的文本提示生成令人兴奋的视频。这个尖端的人工智能模型允许用户描述一个场景&#xff0c;例如“卡通袋鼠跳迪斯科舞”&#xff0c;Sora将生成与…

交叉编译qt到arm平台

使用pkg-config命令查看xxx包是否存在&#xff1a; pkg-config --print-errors xxx pkg-config的搜索路径可以通过环境变量PKG_CONFIG_PATH指定。需要在运行./configure 之前指定。 ./configure -release -qt-libjpeg -qt-libpng -qt-zlib -qt-pcre -xplatform linux-aarch64-…

主机字节序与网络字节序

大端序和小端序 大端序&#xff08;Big Endian&#xff09;和小端序&#xff08;Little Endian&#xff09;是两种计算机存储数据的方式。 大端序指的是将数据的高位字节存储在内存的低地址处&#xff0c;而将低位字节存储在内存的高地址处。这类似于我们阅读多位数时从左往右…

【HarmonyOS】鸿蒙开发之Stage模型-应用配置文件——第4.2章

Stage模型-应用配置文件 AppScope -> app.json5&#xff1a;应用的全局配置信息entry&#xff1a;OpenHarmony工程模块&#xff0c;编译构建生成一个HAP包 build&#xff1a;用于存放OpenHarmony编译生成的hap包src -> main -> ets&#xff1a;用于存放ArkTS源码src …

kubectl 命令行管理K8S(上)

目录 陈述式资源管理方式 介绍 命令 项目的生命周期 创建 kubectl create命令 发布 kubectl expose命令 更新 kubectl set 回滚 kubectl rollout 删除 kubectl delete 应用发布策略 金丝雀发布 陈述式资源管理方式 介绍 1.kubernetes 集群管理集群资源…

Magento2常见表的作用

1.sales_sequence_profile 更改订单号或者发票号的前缀及最大值