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

文章目录

  • 🔊博主介绍
  • 🥤本文内容
    • 规划集群
    • 准备工作
    • 节点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: alwaysimage: apache/rocketmq:4.9.4container_name: namesrvports:- 9876:9876environment:- 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/Shanghaivolumes:- /opt/software/rocketmqcluster/data/namesrv/logs:/home/rocketmq/logs/rocketmqlogs/rocketmqlogscommand: sh mqnamesrvbroker-n0:restart: alwaysimage: apache/rocketmq:4.9.4container_name: broker-n0ports:- 30911:30911- 40911:40911environment:- 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/Shanghaivolumes:- /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.propertiescommand: sh mqbroker -c /home/rocketmq/conf/broker.propertiesbroker-n1:restart: alwaysimage: apache/rocketmq:4.9.4container_name: broker-n1ports:- 30912:30912- 40912:40912environment:- 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/Shanghaivolumes:- /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.propertiescommand: sh mqbroker -c /home/rocketmq/conf/broker.propertiesbroker-n2:restart: alwaysimage: apache/rocketmq:4.9.4container_name: broker-n2ports:- 30913:30913- 40913:40913environment:- 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/Shanghaivolumes:- /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.propertiescommand: 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: alwaysimage: apache/rocketmq:5.1.3container_name: namesrvports:- 9876:9876environment:- 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/Shanghaivolumes:- /opt/software/rocketmqcluster/data/namesrv/logs:/home/rocketmq/logs/rocketmqlogscommand: sh mqnamesrvbroker-n0:restart: alwaysimage: apache/rocketmq:5.1.3container_name: broker-n0ports:- 30911:30911- 40911:40911environment:- 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/Shanghaivolumes:- /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.propertiescommand: sh mqbroker -c /home/rocketmq/conf/broker.propertiesbroker-n1:restart: alwaysimage: apache/rocketmq:5.1.3container_name: broker-n1ports:- 30912:30912- 40912:40912environment:- 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/Shanghaivolumes:- /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.propertiescommand: sh mqbroker -c /home/rocketmq/conf/broker.propertiesbroker-n2:restart: alwaysimage: apache/rocketmq:5.1.3container_name: broker-n2ports:- 30913:30913- 40913:40913environment:- 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/Shanghaivolumes:- /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.propertiescommand: 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: alwaysimage: apache/rocketmq:5.1.3container_name: namesrv ports:- 9876:9876environment:- 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/Shanghaivolumes:- /opt/software/rocketmqcluster/data/namesrv/logs:/home/rocketmq/logs/rocketmqlogscommand: sh mqnamesrvbroker-n0:restart: alwaysimage: apache/rocketmq:5.1.3container_name: broker-n0ports:- 30911:30911- 40911:40911environment:- 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/Shanghaivolumes:- /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.propertiescommand: sh mqbroker -c /home/rocketmq/conf/broker.propertiesbroker-n1:restart: alwaysimage: apache/rocketmq:5.1.3container_name: broker-n1ports:- 30912:30912- 40912:40912environment:- 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/Shanghaivolumes:- /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.propertiescommand: sh mqbroker -c /home/rocketmq/conf/broker.propertiesbroker-n2:restart: alwaysimage: apache/rocketmq:5.1.3container_name: broker-n2ports: - 30913:30913- 40913:40913environment:- 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/Shanghaivolumes:- /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.propertiescommand: sh mqbroker -c /home/rocketmq/conf/broker.propertiesconsole:restart: alwaysimage: apacherocketmq/rocketmq-dashboardcontainer_name: consoleports:- 19081:8080environment: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: alwaysimage: apacherocketmq/rocketmq-dashboardcontainer_name: consoleports:- 19081:8080environment: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.hqwc.cn/news/495604.html

如若内容造成侵权/违法违规/事实不符,请联系编程知识网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

DDP(DistributedDataParallel) 分布式训练1——入门上手

DistributedDataParallel(DDP)是一个支持多机多卡、分布式训练的深度学习工程方法。 在分类上,DDP属于Data Parallel。简单来讲,就是通过提高batch size来增加并行度。DDP通过Ring-Reduce的数据交换方法提高了通讯效率&#xff0…

矩阵的范数 matrix norm Frobenius norm 弗罗贝尼乌斯 范数

1,矩阵范数的定义 矩阵的范数,matrix norm即矩阵的模;它把一个矩阵空间变成为赋范线性空间; 从一个矩阵空间映射到非负实数的函数 满足以下条件: 1,严格的正定性。对于 , 则 ; and if , must ; 2&…

MFC web文件 CHttpFile的使用初探

MFC CHttpFile的使用 两种方式,第一种OpenURL,第二种SendRequest,以前捣鼓过,今天再次整结果发现各种踩坑,好记性不如烂笔头,记录下来。 OpenURL 这种方式简单粗暴,用着舒服。 try {//OpenU…

Netty01NIO

NIO基础 NIO :non-blocking io 非阻塞 IO 笔记 www.zgtsky.top 网课:黑马Netty 三大组件 Channel & Buffer channel 有一点类似于 stream,它就是读写数据的双向通道,可以从 channel 将数据读入 buffer,也可以…

顶顶通呼叫中心中间件-如何使处于机器人话术中的通话手动转接到坐席分机上讲解(mod_cti基于FreeSWITCH)

顶顶通呼叫中心中间件使用httpapi实现电话转接操作过程讲解(mod_cti基于FreeSWITCH) 需要了解呼叫中心中间件可以点以下链接了解顶顶通小孙 1、使用httpapi接口转接 一、打开web版的ccadmin并且找到接口测试 打开web-ccadmin并且登录,登录完成之后点击运维调试-再…

Apache POl

介绍 Apache POl是一个处理Miscrosoft Ofice各种文件格式的开源项目。简单来说就是,我们可以使用 POI 在 Java 程序中对Miscrosoft Office各种文件进行读写操作,一般情况下,POI都是用于操作 Excel 文件。 Apache POl 的应用场景 1.银行网银系统导出交易…

2024年腾讯云4核8G12M配置的轻量服务器同时支持多大访问量?

腾讯云4核8G服务器支持多少人在线访问?支持25人同时访问。实际上程序效率不同支持人数在线人数不同,公网带宽也是影响4核8G服务器并发数的一大因素,假设公网带宽太小,流量直接卡在入口,4核8G配置的CPU内存也会造成计算…

斯元Z-ONE-China Cybersecurity Tech Landscape·中国网络安全全景图-百度网盘下载

面向全球,斯元Z-ONE正式发布首版「China Cybersecurity Tech Landscape中国网络安全全景图」。 为了提升海外市场对中国网络安全行业的全局认识,方便国际客户及合作伙伴了解中国网络安全科技的赛道分布和国内外厂商对标,助力中国网安厂商出海…

Java玩转《啊哈算法》之链表

知道为什么而死,那是了不起的事。到了那个时候,人自然会产生一种力量。 文章目录 由来代码地址数组 vs 链表链表创建遍历插入完整代码 由来 各位小伙伴们好呀!本人最近看了下《啊哈算法》,写的确实不错。 但稍显遗憾的是&#x…

uniapp_微信小程序日历

一、需求要求这样 二、代码实现 <view class"calender" click"showriliall"><text class"lineText">探视日期&#xff1a;</text><text class"middleText">{{timerili}}</text><image src"/s…

【半监督医学图像分割 2021 IEEE】DU-GAN

【半监督医学图像分割 2021 IEEE】DU-GAN 论文题目&#xff1a;DU-GAN: Generative Adversarial Networks with Dual-Domain U-Net Based Discriminators for Low-Dose CT Denoising 中文题目&#xff1a;基于双域U-Net鉴别器的生成对抗网络用于低剂量CT去噪 论文链接&#xff…

LeetCode 热题 100 | 图论(上)

目录 1 200. 岛屿数量 2 994. 腐烂的橘子 2.1 智障遍历法 2.2 仿层序遍历法 菜鸟做题&#xff0c;语言是 C 1 200. 岛屿数量 解题思路&#xff1a; 遍历二维数组&#xff0c;寻找 “1”&#xff08;若找到则岛屿数量 1&#xff09;寻找与当前 “1” 直接或间接连接在…