RocketMQ 单机源码部署 自定义配置文件和端口以及acl权限配置解析

思路

1、我们首先配置完 namesrv和broker和acl认证的配置文件,然后直接使用-c指定配置文件来启动程序,就会非常明了,用户名密码要大于6,第一个用户我测试着不知道为什么始终有最高权限,大家尽量不要吧第一个用户给别人用。

1、下载源码

bash 复制代码
wget https://dist.apache.org/repos/dist/release/rocketmq/5.1.3/rocketmq-all-5.1.3-bin-release.zip

2、解压源码

bash 复制代码
unzip rocketmq-all-5.1.3-bin-release.zip

3、修改配置文件

​ 1、创建conf/namesrv.conf文件

conf 复制代码
# 监听地址和端口
listenPort=1888

​ 2、修改conf/broker.conf文件

conf 复制代码
#开启用户认证
aclEnable=true
#指定认证配置文件
aclAccessResourcePath=/home/user/rocketmq-5.1.3/conf/plain_acl.yml

# 监听地址和端口
listenPort=1889

# Name Server 地址
namesrvAddr=127.0.0.1:1888

# Broker 的集群名称
brokerClusterName=DefaultCluster

# Broker 的名称
brokerName=broker-a

# Broker 的唯一标识
brokerId=0

# 消息文件的保留时间,以小时为单位
deleteWhen=04

# 消息文件的保留时间,以小时为单位
fileReservedTime=48

# Broker 的角色
brokerRole=ASYNC_MASTER

# 磁盘刷写类型
flushDiskType=ASYNC_FLUSH

#在发送消息时,自动创建服务器不存在的Topic,默认创建的队列数
defaultTopicQueueNums=4
#是否允许Broker 自动创建Topic,建议线下开启,线上关闭
autoCreateTopicEnable=true
#是否允许Broker自动创建订阅组,建议线下开启,线上关闭
autoCreateSubscriptionGroup=true
#Broker 对外服务的监听端口
#删除文件时间点,默认是凌晨4点
deleteWhen=04
#文件保留时间,默认48小时
fileReservedTime=48
#检测物理文件磁盘空间
diskMaxUsedSpaceRatio=88
#存储路径
storePathRootDir=/home/user/rocketmq-5.1.3/store
#commitLog存储路径
storePathCommitLog=/home/user/rocketmq-5.1.3/store/commitlog
#消费队列存储路径
storePathConsumeQueue=/home/user/rocketmq-5.1.3/store/consumequeue
#消息索引存储路径
storePathIndex=/home/user/rocketmq-5.1.3/store/index
#checkpoint 文件存储路径
storeCheckpoint=/home/user/rocketmq-5.1.3/store/checkpoint
#abort 文件存储路径
abortFile=/home/user/rocketmq-5.1.3/store/abort

4、配置conf/plain_acl.yml文件

yml 复制代码
accounts:
# 账户
- accessKey: useruser
# 是否是管理员---这里警告,第一个用户似乎始终有最高权限建议非管理员向后创建
  admin: true
  # 默认主题和订阅组,不用管
  defaultGroupPerm: SUB
  defaultTopicPerm: DENY
  groupPerms: null
  # 权限密码
  secretKey: useruser
  topicPerms: null
  # 白名单
  whiteRemoteAddress: null
dataVersion:
- counter: 32
  timestamp: 1691913241329
  # 全局白名单
globalWhiteRemoteAddresses: null

5、启动

bash 复制代码
#bin/mqshutdown broker # 停止运行,不建议在生产环境这么做
#bin/mqshutdown namesrv

## 启动nameserver
## nohup xxxxx & 可以让程序进入后台运行
 nohup bin/mqnamesrv -c /home/user/rocketmq-5.1.3/conf/namesrv.conf  & 
 
 ## 启动节点  -n必须显式指定注册到那个namesrv上
sleep 3  && nohup sh bin/mqbroker -n 23.95.254.26:1888 -c /home/user/rocketmq-5.1.3/conf/broker.conf &

6、检查节点和主题

bash 复制代码
 ## 检查节点数
 sh bin/mqadmin clusterList -n 127.0.0.1:1888
 ## 检查主题
 sh bin/mqadmin topicList -n 127.0.0.1:1888

如果无法查看请更改conf/tools.yml中的用户名和密码

7、可视化工具

url 复制代码
https://rocketmq.apache.org/zh/docs/deploymentOperations/04Dashboard/#%E4%BB%8B%E7%BB%8D%E2%80%8B
相关推荐
CoderJia程序员甲1 小时前
GitHub 热榜项目 - 日榜(2025-08-14)
ai·github·开源项目·github热榜
猫头虎2 小时前
猫头虎AI分享|一款Coze、Dify类开源AI应用超级智能体快速构建工具:FastbuildAI
人工智能·开源·prompt·github·aigc·ai编程·ai-native
我是哪吒2 小时前
分布式微服务系统架构第165集:阿里,字节,腾讯架构经验汇总
后端·面试·github
GoGeekBaird5 小时前
GoHumanLoopHub开源上线,开启Agent人际协作新方式
人工智能·后端·github
草梅友仁15 小时前
草梅 Auth 1.4.0 发布与 ESLint v9 更新 | 2025 年第 33 周草梅周报
vue.js·github·nuxt.js
寻月隐君16 小时前
硬核实战:从零到一,用 Rust 和 Axum 构建高性能聊天服务后端
后端·rust·github
CoderJia程序员甲20 小时前
GitHub 热榜项目 - 日榜(2025-08-16)
人工智能·ai·开源·github
python_1361 天前
web请求和响应
java·spring·github
一宿君1 天前
Github 9 个惊艳的开源 NL2SQL 项目
sql·nlp·github
x10n91 天前
GitHub宕机时的应急协作方案
github