vue django基于Python的学生宿舍水电费在线缴费管理系统_6wz3doj7
2025/12/31 19:56:41
适用场景:
- 不清楚某个 Topic 是否有生产 / 消费
- 不知道 ConsumerGroup 是什么
- mqadmin 命令部分不可用(版本差异)
- 需要用 mqadmin 做最小化排障、验证链路
当前环境使用的 mqadmin 路径:
/root/rocketmq/broker/bin/mqadmin该 mqadmin 特点:
consumeMessage(可模拟消费)consumerList/topicConsumeStatus| 概念 | 说明 |
|---|---|
| Topic | 生产侧逻辑概念(消息写入) |
| ConsumerGroup | 消费侧逻辑概念(offset 归属) |
| #InTPS | Topic 生产速率(每秒写入消息数) |
| #OutTPS | Topic 消费速率(每秒消费消息数) |
| #Accumulation | 消息堆积量(BrokerOffset - ConsumerOffset) |
⚠️ Topic 与 ConsumerGroup不是一对一关系
mqadmin topicStatus-n<NameSrv>-t<Topic>示例输出:
#Broker Name #QID #Min Offset #Max Offset #Last Updated rocketmq-ddffdb1a-0 0 0 22 2025-12-31 07:04:47,308关注字段:#MaxOffset
判断逻辑:
mqadmin statsAll-n<NameSrv>|grep<Topic>示例输出:
#Topic #Consumer Group #Accumulation #InTPS #OutTPS #InMsg24Hour #OutMsg24Hour bpx-topic 0 0.00 0.00 20 NO_CONSUMER字段含义:
#InTPS:生产速率(msg/s)#OutTPS:消费速率(msg/s)#Accumulation:消息堆积量判断:
NO_CONSUMER→ 无消费者订阅该 Topicmqadmin consumerProgress-n<NameSrv>示例输出:
#Group #Count #Version #Type #Model #TPS #Diff Total bpx-consumer-group 0 OFFLINE 0 0 TOOLS_CONSUMER 3 V4_9_4 PULL 0 0说明:
mqadmin consumerProgress-n<NameSrv>-g<ConsumerGroup>用途:
mqadmin consumerConnection-n<NameSrv>-g<ConsumerGroup>示例输出(在线):
#ClientId #ClientAddr #Language #Version 245.0.1.220@consumer-xxx@STREAM 245.0.1.220:40726 JAVA V4_9_4判断:
mqadmin sendMessage\-n<NameSrv>\-t<Topic>\-p"mqadmin test message"示例输出:
#Broker Name #QID #Send Result #MsgId rocketmq-ddffdb1a-0 0 SEND_OK F500033F033A3AF49F1C9C0758D10000用途:
⚠️风险说明:
- 不指定
-g参数:只读取消息,不推进 offset(相对安全)- 指定
-g <ConsumerGroup>参数:会推进该 Group 的 offset(生产环境慎用)
mqadmin consumeMessage\-n<NameSrv>\-t<Topic>\-c10mqadmin consumeMessage\-n<NameSrv>\-t<Topic>\-g<ConsumerGroup>\-c10说明:
mqadmin help consumeMessage真实消费必须使用:
1️⃣ topicStatus → 是否有生产 2️⃣ statsAll → 生产 / 消费 TPS 3️⃣ consumerProgress → 谁在消费 + 是否堆积 4️⃣ consumerConnection → Consumer 是否在线⚠️生产环境慎用以下命令:
| 命令 | 风险 |
|---|---|
consumeMessage -g <Group> | 推进 offset,可能丢失消息 |
resetOffsetByTime | 重置 offset,可能重复消费或跳过消息 |
skipAccumulatedMessage | 跳过堆积消息,造成业务消息丢失 |
| 参数 | 含义 |
|---|---|
-n | NameServer 地址,格式ip:port,多个用分号分隔 |
-t | Topic 名称 |
-g | ConsumerGroup 名称 |
-b | Broker 地址或名称 |
-h | 查看帮助 |
-c | 数量(如消息条数) |
| 文档 | 链接 |
|---|---|
| Admin Tool 官方文档(中文) | rocketmq.apache.org/zh/docs/deploymentOperations/02admintool |
| Admin Tool 官方文档(English) | rocketmq.apache.org/docs/deploymentOperations/02admintool |
| Apache RocketMQ 官网 | rocketmq.apache.org |
| Apache RocketMQ GitHub | github.com/apache/rocketmq |
| 类别 | 命令 | 说明 |
|---|---|---|
| Topic | topicList | 查看所有 Topic |
| Topic | topicStatus | 查看 Topic 消息队列 offset |
| Topic | topicRoute | 查看 Topic 路由信息 |
| Topic | statsAll | 打印订阅关系、TPS、积累量等 |
| 消费 | consumerProgress | 查看消费状态和进度 |
| 消费 | consumerConnection | 查询 Consumer 网络连接 |
| 消费 | consumerStatus | 查看消费者详细状态 |
| 消息 | sendMessage | 发送一条测试消息 |
| 消息 | consumeMessage | 消费消息(可指定 offset) |
| 消息 | queryMsgById | 根据 msgId 查询消息 |
| 消息 | queryMsgByKey | 根据 Key 查询消息 |
| 集群 | clusterList | 查看集群信息 |
| 集群 | brokerStatus | 查看 Broker 运行状态 |
在 RocketMQ 中:
- Topic 看生产
- ConsumerGroup 看消费
- statsAll 看吞吐
- consumerProgress 看堆积
这四点,能解决 90% 的 RocketMQ 排障问题。
Sources: