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.rhkb.cn/news/265084.html

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

相关文章

【Java多线程】对线程池的理解并模拟实现线程池

目录 1、池 1.1、线程池 2、ThreadPoolExecutor 线程池类 3、Executors 工厂类 4、模拟实现线程池 1、池 “池”这个概念见到非常多,例如常量池、数据库连接池、线程池、进程池、内存池。 所谓“池”的概念就是:(提高效率) 1…

ABBYY FineReader16文档转换、PDF管理与文档比较功能介绍

ABBYY FineReader 16作为一款OCR和PDF一体化程序,其强大的功能使得文档处理变得简单高效。在众多功能中,文档转换、PDF管理和文档比较这三大功能尤为突出,成为了众多企业和个人用户的首选工具。 ABBYY Finereader 16-安装包下载如下&#xff…

Python习题详解

练习&#xff1a; 1&#xff0c;计算100以内奇数的和 #计算100以内所有奇数的和 sum 0 # n 1 # while n < 100: # # sum sum n # sum n # # n n 2 # n 2 # print(sum) n 99 #求偶数时n 100 while n > 0:sum n# n n - 2n - 2 print(sum)2&#xff0c;打印直…

Python 鼠标模拟

鼠标模拟即&#xff1a;通过python 进行模拟鼠标操作 引入类库 示例如下&#xff1a; import win32api import win32con import time 设置鼠标位置 设置鼠标位置为窗口中的回收站。 示例如下&#xff1a; # 设置鼠标的位置 win32api.SetCursorPos([30, 40]) 双击图标 设置…

计算机设计大赛 深度学习实现语义分割算法系统 - 机器视觉

文章目录 1 前言2 概念介绍2.1 什么是图像语义分割 3 条件随机场的深度学习模型3\. 1 多尺度特征融合 4 语义分割开发过程4.1 建立4.2 下载CamVid数据集4.3 加载CamVid图像4.4 加载CamVid像素标签图像 5 PyTorch 实现语义分割5.1 数据集准备5.2 训练基准模型5.3 损失函数5.4 归…

【c++leetcode】1382. Balance a Binary Search Tree

问题入口 DSW (DAY, STOUT & WARREN) ALGORITHM 时间复杂度O(n) class Solution { public:int makeVine(TreeNode* grand, int cnt 0){auto n grand->right;while (n ! nullptr){if(n->left ! nullptr){auto old_n n;n n->left;old_n->left n->righ…

【推荐算法系列五】DeepFM 模型

文章目录 参考资料Sparse FeaturesDense EmbeddingsFM LayerHidden LayerOutput Units 优缺点DeepFM 的优点DeepFM 自身的缺点。 参考资料 DeepFM 中关于 整个发展过程&#xff0c; FM, PNN, wide&deep 的描述很给力。 所以FM在其中的含义就是low-order, deep 就是所谓的 …

如何使用ArcGIS Pro为栅格图添加坐标信息

在某些时候&#xff0c;我们从网上获取的资源是一张普通的栅格图&#xff0c;没有任何的坐标信息&#xff0c;如果想要和带坐标信息的数据一起使用就需要先添加坐标信息&#xff0c;在GIS上&#xff0c;我们把这个过程叫做地理配准&#xff0c;这里为大家介绍一下地理配准的方法…

VSCode-更改系统默认路径

修改vscode中的默认扩展路径&#xff1a;"%USERPROFILE%\.vscode" 打开目录C:\用户\电脑用户名&#xff0c;将.vscode文件剪切至D:\VSCode文件夹下 用管理员身份打开cmd.exe命令界面输入mklink /D "%USERPROFILE%\.vscode" "D:\VSCode\.vscode\"…

二次供水物联网:HiWoo Cloud助力城市水务管理升级

随着城市化的快速推进&#xff0c;二次供水系统作为城市基础设施的重要组成部分&#xff0c;其稳定运行和高效管理显得至关重要。然而&#xff0c;传统的二次供水管理方式在应对复杂多变的城市供水需求时&#xff0c;显得力不从心。为了破解这一难题&#xff0c;HiWoo Cloud平台…

Vue3之属性传值的四种情况

文章目录 Vue3之属性传值的四种情况一、引言二、父组件向子组件传值三、子组件向父组件传值四、祖先组件向后代组件传值五、兄弟组件之间传值 Vue3之属性传值的四种情况 一、引言 在vue3中&#xff0c;组件与组件之间是可以传递属性的&#xff0c;包括三种类型&#xff1a; …

电商风控系统(flink+groovy+flume+kafka+redis+clickhouse+mysql)

一.项目概览 电商的防止薅羊毛的风控系统 需要使用 groovy 进行风控规则引擎的编写 然后其它技术进行各种数据的 存储及处理 薅羊毛大致流程 如果单纯使用 if else在业务代码中进行风控规则的编写 那么 维护起来会比较麻烦 并且跟业务系统强绑定不合适 所以一般独立成一个单…

【Python笔记-设计模式】中介者模式

一、说明 中介者模式是一种行为设计模式&#xff0c;减少对象之间混乱无序的依赖关系。该模式会限制对象之间的直接交互&#xff0c;迫使它们通过一个中介者对象进行合作。 (一) 解决问题 降低系统中对象之间的直接通信&#xff0c;将复杂的交互转化为通过中介者进行的间接交…

[Mac软件]Adobe Substance 3D Stager 2.1.4 3D场景搭建工具

应用介绍 Adobe Substance 3D Stager&#xff0c;您设备齐全的虚拟工作室。在这个直观的舞台工具中构建和组装 3D 场景。设置资产、材质、灯光和相机。导出和共享媒体&#xff0c;从图像到 Web 和 AR 体验。 处理您的最终图像 Substance 3D Stager 可让您在上下文中做出创造性…

绝对路径拼接漏洞 [NISACTF 2022]babyupload

打开题目 最开始以为是文件上传的漏洞 结果发现无论我们上传什么文件都会显示bad filename 去网上看了大佬的wp知道 我们直接去看源代码得到提示 /source 那我们去访问一下这个路径看看 得到一个下载文件 用记事本打开得到 源代码如下 from flask import Flask, request, r…

SSL OV证书和DV、EV证书的区别

在网站搭建的过程中和小程序开发过程中&#xff0c;很难免会有需要用到SSL证书的地方&#xff0c;但是目前数字证书种类繁多&#xff0c;该选择什么类型的证书成为了一个令人纠结的问题。 目前在市场上较为常见的证书分为三种&#xff1a;DV域名验证型证书&#xff1b;OV组织验…

iPhone利用文件管理器批量导出语音备忘录和照片到电脑

步骤1&#xff1a;使用文件服务器在 iPhone 和电脑间共享文件 参考文献&#xff1a;苹果官网操作指南 步骤1.1&#xff1a;iPhone上打开文件app&#xff0c;点击右上角三个点&#xff0c;选择“连接服务器” 步骤1.2&#xff1a;输入电脑的登录账号和密码 步骤1.3&#xff1a…

LVGL 环境搭建-基于WSL

背景说明 小白刚开始接触LVGL&#xff0c;前些日子狠心花198元入手了一块堪称LVGL 入门利器~HMI-Board 开发板&#xff0c;虽然有RT-Thread 集成好的LVGL 环境&#xff0c;只需要几个步骤就能成功把lvgl 的示例运行起来&#xff0c;对于爱折腾的我来说&#xff0c;过于简单也并…

【UE 材质】冰冻效果

效果 步骤 1. 打开“Quixel Bridge” 下载冰的纹理 2. 新建一个材质&#xff0c;这里命名为“M_Frozen” 打开“M_Frozen”&#xff0c;添加如下节点&#xff0c;此时我们可以通过控制参数“偏移”来改变边界的偏移 此时预览效果如下 如果增加参数“偏移”的默认值效果如下 3.…

动态规划课堂2-----路径问题

目录 引言&#xff1a; 例题1&#xff1a;不同路径 例题2&#xff1a;不同路径II 例题3&#xff1a;礼物的最⼤价值 例题4&#xff1a;下降路径最⼩和 例题5&#xff1a;最小路径和 结语&#xff1a; 引言&#xff1a; 在学习完动态规划斐波那契数列模型后&#xff0c;…