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.mzph.cn/news/707375.shtml

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

相关文章

C语言--- 指针(3)

一.字符指针变量 在指针的类型中&#xff0c;我们知道有一种指针类型为字符指针char * 一般使用&#xff1a; #include<stdio.h> int main() {char ch a;char* p &ch;*p b;printf("%c\n",ch);return 0; } 其实还有一种使用方式 &#xff1a; #inc…

用了这么久的python,这些零碎的基础知识,你还记得多少?

python内置的数据类型 Python3.7内置的关键字 [False, None, True, and, as, assert, async, await, break, class, continue, def, del, elif, else, except, finally, for, from, global, if, import, in, is, lambda,nonlocal, not, or, pass, raise, return, try, while, …

vue专栏总纲

博主个人小程序已经上线&#xff1a;【中二少年工具箱】 小程序二维如下&#xff1a; 正文开始 专栏简介专栏初衷 专栏简介 本系列文章由浅入深&#xff0c;从基础知识到实战开发&#xff0c;非常适合入门同学。 零基础读者也能成功由本系列文章入门&#xff0c;但如果您具…

Unity中字符串拼接0GC方案

本文主要分析C#字符串拼接产生GC的原因&#xff0c;以及介绍名为ZString的库&#xff0c;它可以将字符串生成的内存分配为零。 在C#中&#xff0c;字符串拼接通常有三种方式&#xff1a; 直接使用号连接&#xff1b;string.format;使用StringBuilder&#xff1b; 下面分别细…

新版极狐gitlab安装+配置详细版

这里安装的服务器环境是centos7.9系统&#xff0c;安装极狐版本16.9。 极狐地址&#xff1a;https://gitlab.cn/install/ 1. 安装和配置所需的依赖 在 CentOS 7 上&#xff0c;下面的命令会在系统防火墙中打开 HTTP、HTTPS 和 SSH 访问。这是一个可选步骤&#xff0c;如果您…

Docker部署Portainer图形化管理工具

文章目录 前言1. 部署Portainer2. 本地访问Portainer3. Linux 安装cpolar4. 配置Portainer 公网访问地址5. 公网远程访问Portainer6. 固定Portainer公网地址 前言 Portainer 是一个轻量级的容器管理工具&#xff0c;可以通过 Web 界面对 Docker 容器进行管理和监控。它提供了可…

物业智能水电抄表管理系统

物业智能水电抄表管理系统是物业管理行业的关键技术之一&#xff0c;其结合了智能化、远程监控和数据分析等功能&#xff0c;为物业管理公司和业主提供了高效、精准的水电抄表管理解决方案。该系统具有多项优势&#xff0c;能够提升物业管理效率&#xff0c;降低成本&#xff0…

第五节:Vben Admin权限-前端控制方式

系列文章目录 第一节:Vben Admin介绍和初次运行 第二节:Vben Admin 登录逻辑梳理和对接后端准备 第三节:Vben Admin登录对接后端login接口 第四节:Vben Admin登录对接后端getUserInfo接口 第五节:Vben Admin权限-前端控制方式 文章目录 系列文章目录前言一、Vben Admin权…

py32 link,让PY32单片机开发更容易上手。

py32 link支持PY32系列单片机的调试和烧录&#xff0c;⽀持Keil、IAR等多种开发环境&#xff0c;开发简单易上手。PY32 link使用Type-C接⼝供电&#xff0c;搭载了MH32F103A芯片 LQFP64封装&#xff0c;MH32F103A有着216MHz主频和256KB flash&#xff0c;96KB RAM大资源&#x…

【Python】Code2flow学习笔记

1 Code2flow介绍 Code2flow是一个代码可视化工具库&#xff0c;旨在帮助开发人员更好地理解和分析代码&#xff1a; 可以将Python代码转换为流程图&#xff0c;以直观的方式展示代码的执行流程和逻辑结构。具有简单易用、高度可定制化和美观的特点&#xff0c;适用于各种代码…

Groovy(第九节) Groovy 之单元测试

JUnit 利用 Java 对 Song 类进行单元测试 默认情况下 Groovy 编译的类属性是私有的,所以不能直接在 Java 中访问它们,必须像下面这样使用 setter: 编写这个测试用例余下的代码就是小菜一碟了。测试用例很好地演示了这样一点:用 Groovy 所做的一切都可以轻易地在 Java 程序…

算法--动态规划(线性DP、区间DP)

这里写目录标题 tip数组下标从0开始还是从1开始 线性DP数学三角形介绍算法思想例题代码 最长上升子序列介绍算法思想例题代码 最长公共子序列介绍算法思想例题代码 编辑距离介绍例题代码 区间DP问题石子合并介绍算法思想例题代码 tip 数组下标从0开始还是从1开始 如果代码中涉…

Opencv实战(3)详解霍夫变换

霍夫变换 Opencv实战系列指路前文&#xff1a; Opencv(1)读取与图像操作 Opencv(2)绘图与图像操作 文章目录 霍夫变换1.霍夫线变换1.1 原理1.2 HoughLines() 2.霍夫圆变换2.1 原理2.2 HoughCircles() 最基本的霍夫变换是从黑白图像中检测直线(线段) 霍夫变换(Hough Transform…

【vue】什么是虚拟Dom,怎么实现虚拟DOM,虚拟DOM一定更快吗

什么是虚拟Dom 虚拟 DOM 基于虚拟节点 VNode&#xff0c;VNode 本质上是一个对象&#xff0c;VDOM 就是VNode 组成的 废话&#xff0c;js 中所有的东西都是对象 虚拟DOM 为什么快&#xff0c;做了哪些优化 批量更新 多个DOM合并更新减少浏览器的重排和重绘局部更新 通过新VDO…

Spring中的ApplicationContext.publishEvent

简单理解 其实就是监听处理。比如找工作平台上&#xff0c;雇主 employer 发布自己的雇佣条件&#xff0c;目的是平台中有符合条件的求职者时&#xff0c;及时向雇主推荐。求职者发布简历&#xff0c;当平台发现某个求职者比较符合条件&#xff0c;就触发被动&#xff0c;推荐…

selenium元素等待及滚动条滚动

selenium三大等待&#xff0c;sleep&#xff08;强制&#xff09;、implicitlyWait&#xff08;隐式等待&#xff09;、WebDriverWait&#xff08;显式等待&#xff09;&#xff0c;主要记一下最后面的WebDriverWait。 WebDriverWait是三大等待中最常用也是最好用的一种等待方…

docker 容器修改端口和目录映射

一、容器修改端口映射 一般在运行容器时&#xff0c;我们都会通过参数 -p&#xff08;使用大写的-P参数则会随机选择宿主机的一个端口进行映射&#xff09;来指定宿主机和容器端口的映射&#xff0c;例如 docker run -it -d --name [container-name] -p 8088:80 [image-name]…

vue3的echarts从后端获取数据,用于绘制图表

场景需求&#xff1a;后端采用flask通过pymysql从数据库获取数据&#xff0c;并返回给前端。前端vue3利用axios获取数据并运用到echarts绘制图表。 第一步&#xff0c;vue中引入echarts 首先vue下载echarts npm install echarts 然后在main.js文件写如下代码 import {create…

东芝工控机维修东芝电脑PC机维修FA3100A

TOSHIBA东芝工控机维修电脑控制器PC机FA3100A MODEL8000 UF8A11M 日本东芝TOSHIBA IA controller维修SYU7209A 001 FXMC12/FXMC11;BV86R-T2GKR-DR7YF-8CPPY-4T3QD; CPU处理单元是可编程逻辑控制器的控制部分。它按照可编程逻辑控制器系统程序赋予的功能接收并存储从编程器键入…

基于 LVGL 使用 SquareLine Studio 快速设计 UI 界面

目录 简介注册与软件获取工程配置设计 UI导出源码板级验证更多内容 简介 SquareLine Studio 是一款专业的 UI 设计软件&#xff0c;它与 LVGL&#xff08;Light and Versatile Graphics Library&#xff0c;轻量级通用图形库&#xff09;紧密集成。LVGL 是一个轻量化的、开源的…