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
相关推荐
三水不滴20 小时前
Apache RocketMQ的原理与实践
经验分享·apache·rocketmq
飞乐鸟21 小时前
Github 16.8k Star!推荐一款开源的高性能分布式对象存储系统!
分布式·开源·github
CCC:CarCrazeCurator1 天前
IDE 与编程语言区分介绍
git·github
Go_Zezhou1 天前
render快速部署网站和常见问题解决
运维·服务器·开发语言·python·github·状态模式
玉梅小洋1 天前
Git 使用技巧——查看 Commit 修改文件的概要
git·github
矢志航天的阿洪2 天前
从GitHub到本地:Python IGRF库环境配置完全指南
开发语言·python·github
chunmiao30322 天前
了解github上,watch,fork,star代表啥
github
CoderJia程序员甲2 天前
GitHub 热榜项目 - 日榜(2026-01-30)
开源·大模型·llm·github·ai教程
Aliex_git2 天前
Claude Code 使用笔记(四)- GitHub Claude 审查助手
人工智能·笔记·学习·github·ai编程
MicrosoftReactor2 天前
技术速递|使用 GitHub Copilot SDK 构建智能体:自动化技术更新追踪实战指南
自动化·github·copilot