15 RocketMQ Common Command Practices #
This article summarizes the common commands used in RocketMQ cluster operation and maintenance. By understanding the meanings of these commands, you can handle cluster operation and maintenance with ease. The following commands have been executed in actual environments.
Cluster Commands Summary #
Cluster List #
The command clusterList
is used to view the running status of each node in the cluster. It shows how many nodes are in the cluster, whether they are master or slave nodes, as well as the write TPS and read TPS of each node.
Command example:
$ bin/mqadmin clusterList -n x.x.x.x:9876
RocketMQLog:WARN No appenders could be found for logger (io.netty.util.internal.PlatformDependent0).
RocketMQLog:WARN Please initialize the logger system properly.
#Cluster Name #Broker Name #BID #Addr #Version #InTPS(LOAD) #OutTPS(LOAD) #PCWait(ms) #Hour #SPACE
fat_mq fat_mq_c 0 x.x.x.x:10911 V4_7_0 262.95(0,0ms) 259.85(0,0ms) 0 55.09 0.3130
Field Definitions
Field | Definition |
---|---|
-n | Nameserver address |
Cluster Name | Cluster name |
Broker Name | Broker name of the node |
BID | Broker ID (0 indicates master node, non-zero indicates slave node) |
Addr | Node address (ip:port) |
Version | Version number of RocketMQ |
InTPS | Number of messages written per second by the node |
OutTPS | Number of messages read per second by the node |
PCWait | pageCacheLockTimeMills (the time difference between the current time and the last time the message disk was locked) |
Hour | How long the valid messages have been stored on the disk (the time difference between the current time and the timestamp of the earliest saved message on the disk) |
SPACE | Disk usage percentage |
Cluster Resource Throughput #
The command statsAll
can be used to view the real-time throughput of all topics/consumer groups in the cluster.
Command example
$ bin/mqadmin statsAll -n x.x.x.x:9876
RocketMQLog:WARN No appenders could be found for logger (io.netty.util.internal.PlatformDependent0).
RocketMQLog:WARN Please initialize the logger system properly.
#Topic #Consumer Group #Accumulation #InTPS #OutTPS #InMsg24Hour #OutMsg24Hour
trade_eticket_created_topic trade_eticket_created_consumer 0 0.00 0.00 0 0
Field Definitions
Field | Definition |
---|---|
-n | Nameserver address |
-a | Print only active topics |
-t | Print only specified topics |
Topic | Topic name |
Consumer Group | Consumer group name |
Accumulation | Accumulated number of messages |
InTPS | Number of messages written per second for the topic |
OutTPS | Number of messages consumed per second by the consumer group |
InMsg24Hour | Total number of messages written in 24 hours for the topic |
OutMsg24Hour | Total number of messages consumed in 24 hours by the consumer group |
Topic Commands Summary #
Topic List #
Use the topicList
command to list all topics in the cluster.
Command example:
$ bin/mqadmin topicList -n x.x.x.x:9876
RocketMQLog:WARN No appenders could be found for logger (io.netty.util.internal.PlatformDependent0).
RocketMQLog:WARN Please initialize the logger system properly.
mq_demo1_topic
mq_demo1_topic
mq_demo2_topic
...
Field Definitions:
Field | Definition |
---|---|
-n | Nameserver address |
Topic Creation/Modification #
Use the updateTopic
command to create a topic. This command can also be used to modify the topic configuration, such as the number of queues, permissions, etc.
Command example:
$ bin/mqadmin updateTopic -n x.x.x.x:9876 -c fat_mq -t mq_demo_topic
RocketMQLog:WARN No appenders could be found for logger (io.netty.util.internal.PlatformDependent0).
RocketMQLog:WARN Please initialize the logger system properly.
create topic to x.x.x.x:10911 success.
TopicConfig [topicName=mq_demo_topic, readQueueNums=8, writeQueueNums=8, perm=RW-, topicFilterType=SINGLE_TAG, topicSysFlag=0, order=false]
Field Definitions:
Field | Definition |
---|---|
-n | Nameserver address |
-c | Cluster name |
-t | Topic name to be created |
topicName | Topic name |
readQueueNums | Number of read queues |
writeQueueNums | Number of write queues |
perm | Topic permission (RW indicates read and write permission) |
topicFilterType | Message filter type |
topicSysFlag | Topic system flag |
order | Whether it is an ordered topic |
Topic Routing #
Use the topicRoute
command to view the routing information of a topic, including the Broker on which the queue is located and the cluster on which the Broker is located.
Command example:
$ bin/mqadmin topicRoute -n x.x.x.x:9876 -t mq_demo_topic
RocketMQLog:WARN No appenders could be found for logger (io.netty.util.internal.PlatformDependent0).
RocketMQLog:WARN Please initialize the logger system properly.
{
"brokerDatas":[
{
"brokerAddrs":{0:"x.x.x.x:10911"
},
"brokerName":"fat_mq_c",
"cluster":"fat_mq"
}
],
"filterServerTable":{},
"queueDatas":[
{
"brokerName":"fat_mq_c",
"perm":6,
"readQueueNums":8,
"topicSynFlag":0,
"writeQueueNums":8
}
]
}
Field Definitions:
Field | Definition |
---|---|
-n | Nameserver address |
-t | Topic name |
brokerDatas | Broker information including address, node name, and cluster |
queueDatas | Number of queues, broker on which the queue is located, permissions, etc. |
Topic Status #
Use the topicStatus
command to view the status of a topic, such as the minimum offset, maximum offset, last update time, etc.
Command example:
$ bin/mqadmin topicStatus -n x.x.x.x:9876 -t mq_demo_topic
RocketMQLog:WARN No appenders could be found for logger (io.netty.util.internal.PlatformDependent0).
RocketMQLog:WARN Please initialize the logger system properly.
#Broker Name #QID #Min Offset #Max Offset #Last Updated
fat_mq_c 0 6 10 2020-07-24 14:29:57,707
fat_mq_c 1 4 8 2020-07-24 14:31:32,213
fat_mq_c 2 20 22 2020-07-24 14:35:52,752
fat_mq_c 3 14 20 2020-07-24 14:28:34,287
Field Definitions:
Field | Definition |
---|---|
-n | NameServer address |
-t | Topic name |
Broker Name | Node name |
QID | Queue ID |
Min Offset | Minimum offset of the queue |
Max Offset | Maximum offset of the queue |
Last Updated | Timestamp of the latest message written |
Topic Permissions #
You can modify the permission of a topic using the updateTopicPerm
command. There are three types of permissions: write permission represented by 2, read permission represented by 4, and read-write permission represented by 6. The following example shows how to change the permission of a topic from read-write to write:
Command example:
$ bin/mqadmin updateTopicPerm -c fat_mq -t mq_demo_topic -p 2 -n x.x.x.x:9876
RocketMQLog:WARN No appenders could be found for logger (io.netty.util.internal.PlatformDependent0).
RocketMQLog:WARN Please initialize the logger system properly.
update topic perm from 6 to 2 in x.x.x.x:10911 success.
Field definitions:
Name | Description |
---|---|
-c | Cluster name |
-t | Topic name |
-p | Permission (2: Write, 4: Read, 6: Read-Write) |
-n | NameServer address |
Topic deletion #
You can delete a topic using the deleteTopic
command. This command is used to delete unused topics.
Command example:
$ bin/mqadmin deleteTopic -n x.x.x.x:9876 -t mq_demo_topic -c fat_mq
RocketMQLog:WARN No appenders could be found for logger (io.netty.util.internal.PlatformDependent0).
RocketMQLog:WARN Please initialize the logger system properly.
delete topic [mq_demo_topic] from cluster [fat_mq] success.
delete topic [mq_demo_topic] from NameServer success.
Field definitions:
Name | Description |
---|---|
-n | Nameserver address |
-t | Topic name |
-c | Cluster name |
Consumer group command summary #
Consumer group creation #
You can create a consumer group using the updateSubGroup
command. The command will return the configuration information of the consumer group upon successful creation.
Command example:
$ bin/mqadmin updateSubGroup -n x.x.x.x:9876 -c fat_mq -g mq_demo_consumer
RocketMQLog:WARN No appenders could be found for logger (io.netty.util.internal.PlatformDependent0).
RocketMQLog:WARN Please initialize the logger system properly.
create subscription group to x.x.x.x:10911 success.
SubscriptionGroupConfig [groupName=mq_demo_consumer, consumeEnable=true, consumeFromMinEnable=false, consumeBroadcastEnable=false, retryQueueNums=1, retryMaxTimes=16, brokerId=0, whichBrokerWhenConsumeSlowly=1, notifyConsumerIdsChangedEnable=true]
Field definitions:
Name | Description |
---|---|
-n | Nameserver address |
-c | Cluster name |
-g | Consumer group name |
groupName | Consumer group name |
consumeEnable | Whether consumption is enabled, default is enabled |
consumeFromMinEnable | Whether to consume from the minimum offset, default is false |
consumeBroadcastEnable | Whether to enable broadcast consumption, default is false |
retryQueueNums | Number of retry queues, default is 1 |
retryMaxTimes | Maximum number of consumption retries, default is 16 times |
brokerId | Broker ID of the consumer group |
whichBrokerWhenConsumeSlowly | When the Master node consumes slowly, it will consume from the broker with ID 1 by default. |
Consumer status #
You can view the status of consumers, including their versions and consumer group names, using the consumerStatus
command.
Command example:
$ bin/mqadmin consumerStatus -g mq_demo_consumer -n x.x.x.x:9876
RocketMQLog:WARN No appenders could be found for logger (io.netty.util.internal.PlatformDependent0).
RocketMQLog:WARN Please initialize the logger system properly.
001 consumer-client-id-disaster_mq-x.x.x.x@21171 V4_7_0 1595768036031/consumer-client-id-disaster_mq-x.x.x.x@21171
002 consumer-client-id-disaster_mq-x.x.x.x@19089 V4_7_0 1595768036031/consumer-client-id-disaster_mq-x.x.x.x@19089
Field definitions:
Name | Description |
---|---|
-g | Consumer group name |
-n | NameServer address |
Output the first column | Which consumer number |
Output the second column | clientId |
Output the third column | The version of RocketMQ client used by this consumer |
Output the fourth column | File path (filePath) that records detailed information about the consumer |
Consumer Group Progress #
Use consumerProgress
to view the consumption progress of each Queue message in the subscription topic of the consumer group.
Command example:
$ bin/mqadmin consumerProgress -g pglog_rmq_t_biz_extend_synchbase_consumer -n x.x.x.x:9876
RocketMQLog:WARN No appenders could be found for logger (io.netty.util.internal.PlatformDependent0).
RocketMQLog:WARN Please initialize the logger system properly.
#Topic #Broker Name #QID #Broker Offset #Consumer Offset #Client IP #Diff #LastTime
pglog_rmq_t_biz_extend disaster_mq_a 0 17227343 17227343 N/A 0 2020-07-26 21:09:30
pglog_rmq_t_biz_extend disaster_mq_a 1 16588873 16588873 N/A 0 2020-07-26 21:09:30
pglog_rmq_t_biz_extend disaster_mq_a 2 12053429 12053429 N/A 0 2020-07-26 21:09:35
...
Consume TPS: 3.98
Diff Total: 6
Field meanings:
Name | Meaning |
---|---|
-g | Consumer group name |
-n | NameServer address |
Topic | Subscribed topic |
Broker Name | Broker where the subscribed topic resides |
QID | Queue ID of the subscribed topic |
Broker Offset | Message offset stored in the Queue |
Consumer Offset | Message offset consumed by the Queue |
Diff | Message accumulation situation |
LastTime | Last time the message was consumed |
Consume TPS | Number of messages consumed per second |
Diff Total | Total number of message accumulation |
Message Retrieval #
Use resetOffsetByTime
to reposition the consumption group to a past point in time and restart the consumption.
Command example:
$ bin/mqadmin resetOffsetByTime -n x.x.x.x:9876 -g melon_consumer_0010 -t melon_test_0010 -s now
RocketMQLog:WARN No appenders could be found for logger (io.netty.util.internal.PlatformDependent0).
RocketMQLog:WARN Please initialize the logger system properly.
rollback consumer offset by specified group[melon_consumer_0010], topic[melon_test_0010], force[true], timestamp(string)[now], timestamp(long)[1595900214141]
#brokerName #queueId #offset
dev_mq_b 5 281499
dev_mq_b 3 285922
dev_mq_d 5 12335
dev_mq_b 4 286157
dev_mq_b 1 279566
dev_mq_d 3 12336
dev_mq_b 2 281142
dev_mq_d 4 12333
dev_mq_d 1 12335
dev_mq_b 0 282808
dev_mq_d 2 12338
dev_mq_d 0 12343
Field meanings:
Name | Meaning |
---|---|
-n | NameServer address |
-g | Consumer group name |
-t | Topic name defined by the consumer group |
-s | Timestamp for retrieval (for example, 1595815028792, “now” represents the current time) |
brokerName | Node name |
queueId | Queue ID |
offset | Offset consumed by the queue after retrieval |
Broker Command Summary #
Broker Status #
Use brokerStatus
to check the running status of a broker in the cluster, such as startup time, version, throughput, etc.
Command example:
$ bin/mqadmin brokerStatus -b x.x.x.x:10911 -n x.x.x.x:9876
RocketMQLog:WARN No appenders could be found for logger (io.netty.util.internal.PlatformDependent0).
RocketMQLog:WARN Please initialize the logger system properly.
EndTransactionQueueSize : 0
EndTransactionThreadPoolQueueCapacity: 100000
bootTimestamp : 1591673160936
brokerVersion : 353
brokerVersionDesc : V4_7_0
commitLogDirCapacity : Total : 98.3 GiB, Free : 93.5 GiB.
commitLogDiskRatio : 0.04929098258492175
commitLogMaxOffset : 3473383494
commitLogMinOffset : 2147483648
consumeQueueDiskRatio : 0.04929098258492175
dispatchBehindBytes : 0
dispatchMaxBuffer : 0
earliestMessageTimeStamp : 1595621861014
getFoundTps : 0.0 0.0 0.0
getMessageEntireTimeMax : 290
getMissTps : 786.5213478652134 783.8549478385495 783.5753864100321
getTotalTps : 786.5213478652134 783.8549478385495 783.5753864100321
getTransferedTps : 0.0 0.0 0.0
msgGetTotalTodayMorning : 2713099
msgGetTotalTodayNow : 2713131
msgGetTotalYesterdayMorning : 1478152
msgPutTotalTodayMorning : 9303513
msgPutTotalTodayNow : 9336203
msgPutTotalYesterdayMorning : 6247199
pageCacheLockTimeMills : 0
pullThreadPoolQueueCapacity : 100000
pullThreadPoolQueueHeadWaitTimeMills: 0
pullThreadPoolQueueSize : 0
putMessageAverageSize : 326.0440501347282
putMessageDistributeTime : [<=0ms]:11 [0~10ms]:0 [10~50ms]:0 [50~100ms]:0 [100~200ms]:0 [200~500ms]:0 [500ms~1s]:0 [1~2s]:0 [2~3s]:0 [3~4s]:0 [4~5s]:0 [5~10s]:0 [10s~]:0
putMessageEntireTimeMax : 930
putMessageSizeTotal : 3044013439
putMessageTimesTotal : 9336203
putTps : 0.9999000099990001 0.9999000099990001 0.999875015623047
queryThreadPoolQueueCapacity : 20000
queryThreadPoolQueueHeadWaitTimeMills: 0
queryThreadPoolQueueSize : 0
remainHowManyDataToCommit : 0 B
remainHowManyDataToFlush : 1.1 KiB
remainTransientStoreBufferNumbs : 3
runtime : [ 49 days, 21 hours, 38 minutes, 12 seconds ]
scheduleMessageOffset_1 : 2024,2024
scheduleMessageOffset_10 : 1035,1035
scheduleMessageOffset_11 : 885,885
scheduleMessageOffset_12 : 879,879
scheduleMessageOffset_13 : 889,889
scheduleMessageOffset_14 : 640349,640349
scheduleMessageOffset_15 : 848,848
scheduleMessageOffset_16 : 851,851
scheduleMessageOffset_17 : 870,870
scheduleMessageOffset_18 : 1288,1288
scheduleMessageOffset_2 : 1243954,1243954
scheduleMessageOffset_3 : 13682,13682
scheduleMessageOffset_4 : 5965,5965
scheduleMessageOffset_5 : 5134,5134
scheduleMessageOffset_6 : 4741,4741
scheduleMessageOffset_7 : 13475,13475
scheduleMessageOffset_8 : 2530,2530
scheduleMessageOffset_9 : 2270,2270
sendThreadPoolQueueCapacity : 10000
sendThreadPoolQueueHeadWaitTimeMills: 0
sendThreadPoolQueueSize : 0
startAcceptSendRequestTimeStamp : 0
字段含义:
Field | Meaning |
---|---|
commitLogMaxOffset | Maximum offset of the commit log |
commitLogMinOffset | Minimum offset of the commit log |
consumeQueueDiskRatio | Consume queue disk usage ratio |
dispatchBehindBytes | Data in the commit log that has been stored but not forwarded to the consume queue (in bytes) |
dispatchMaxBuffer | Ignorable |
earliestMessageTimeStamp | Timestamp of the earliest message stored |
getFoundTps | TPS (transactions per second) of messages found during pulling, representing average TPS in the last 10 seconds, 1 minute, and 10 minutes respectively |
getMessageEntireTimeMax | Maximum time consumed for searching a single message |
getMissTps | TPS of messages not found during pulling, representing average TPS in the last 10 seconds, 1 minute, and 10 minutes respectively |
getTotalTps | Total TPS during pulling, representing average TPS in the last 10 seconds, 1 minute, and 10 minutes respectively |
getTransferedTps | TPS of messages transferred to the puller, representing average TPS in the last 10 seconds, 1 minute, and 10 minutes respectively |
msgGetTotalTodayMorning | Total number of messages pulled from this broker until this morning |
msgGetTotalTodayNow | Total number of messages pulled from this broker until now |
msgGetTotalYesterdayMorning | Total number of messages pulled from this broker until yesterday morning |
msgPutTotalTodayMorning | Total number of messages written to this broker until this morning |
msgPutTotalTodayNow | Total number of messages written to this broker until now |
msgPutTotalYesterdayMorning | Total number of messages written to this broker until yesterday morning |
pageCacheLockTimeMills | Time since the lock was added to the page cache |
pullThreadPoolQueueCapacity | Initial capacity of the pull thread pool queue, default is 100,000 |
pullThreadPoolQueueHeadWaitTimeMills | Time, in milliseconds, the first task in the queue has been waiting from its creation |
pullThreadPoolQueueSize | Current number of tasks in the pull thread pool queue |
putMessageAverageSize | Average size of written messages |
putMessageDistributeTime | Distribution of time taken to store messages. For example: [<=0ms]:11 means there are 11 messages with a storage time of <=0ms |
putMessageEntireTimeMax | Maximum time taken to store a single message |
putMessageSizeTotal | Total size of stored messages |
putMessageTimesTotal | Total number of stored messages |
putTps | Average TPS of writing messages in the last 10 seconds, 1 minute, and 10 minutes respectively |
queryThreadPoolQueueCapacity | The initial capacity of the thread pool queue, defaults to 20000 |
queryThreadPoolQueueHeadWaitTimeMills | The time interval in milliseconds that the first task in the queue has been waiting to be executed |
queryThreadPoolQueueSize | The current number of tasks in the thread pool queue |
remainHowManyDataToCommit | The amount of data remaining to be written to the file channel |
remainHowManyDataToFlush | The amount of data remaining to be flushed to disk |
remainTransientStoreBufferNumbs | The number of available off-heap cache buffers, initially set to 5, each with a size of 1 GB, and effective when off-heap memory transfer is enabled |
runtime | The duration the broker has been running for |
scheduleMessageOffset_1 | The maximum offset of the 1st queue in the SCHEDULE_TOPIC_XXXX topic (Note: Delayed messages are stored in the topic named SCHEDULE_TOPIC_XXXX) |
scheduleMessageOffset_10 | The maximum offset of the 10th queue in the SCHEDULE_TOPIC_XXXX topic |
scheduleMessageOffset_11 | The maximum offset of the 11th queue in the SCHEDULE_TOPIC_XXXX topic |
scheduleMessageOffset_12 | The maximum offset of the 12th queue in the SCHEDULE_TOPIC_XXXX topic |
scheduleMessageOffset_13 | The maximum offset of the 13th queue in the SCHEDULE_TOPIC_XXXX topic |
scheduleMessageOffset_14 | The maximum offset of the 14th queue in the SCHEDULE_TOPIC_XXXX topic |
scheduleMessageOffset_15 | The maximum offset of the 15th queue in the SCHEDULE_TOPIC_XXXX topic |
scheduleMessageOffset_16 | The maximum offset of the 16th queue in the SCHEDULE_TOPIC_XXXX topic |
scheduleMessageOffset_17 | The maximum offset of the 17th queue in the SCHEDULE_TOPIC_XXXX topic |
scheduleMessageOffset_18 | The maximum offset of the 18th queue in the SCHEDULE_TOPIC_XXXX topic |
scheduleMessageOffset_2 | The maximum offset of the 2nd queue in the SCHEDULE_TOPIC_XXXX topic |
scheduleMessageOffset_3 | The maximum offset of the 3rd queue in the SCHEDULE_TOPIC_XXXX topic |
scheduleMessageOffset_4 | The maximum offset of the 4th queue in the SCHEDULE_TOPIC_XXXX topic |
scheduleMessageOffset_5 | The maximum offset of the 5th queue in the SCHEDULE_TOPIC_XXXX topic |
scheduleMessageOffset_6 | The maximum offset of the 6th queue in the SCHEDULE_TOPIC_XXXX topic |
scheduleMessageOffset_7 | The maximum offset of the 7th queue in the SCHEDULE_TOPIC_XXXX topic |
scheduleMessageOffset_8 | The maximum offset of the 8th queue in the SCHEDULE_TOPIC_XXXX topic |
scheduleMessageOffset_9 | The maximum offset of the 9th queue in the SCHEDULE_TOPIC_XXXX topic |
sendThreadPoolQueueCapacity | The initial capacity of the thread pool queue for sending messages, defaults to 10000 |
sendThreadPoolQueueHeadWaitTimeMills | The time interval in milliseconds that the first task in the sending thread pool queue has been waiting to be executed |
sendThreadPoolQueueSize | The current number of tasks in the sending thread pool queue |
startAcceptSendRequestTimeStamp | The specified time when the broker starts accepting client send requests, defaults to accepting send requests after startup |
Querying Broker Configuration #
You can use the getBrokerConfig
command to query the configuration information of a broker. The following is an example of how to use the command. The specific meaning of each parameter will be explained in a separate document.
Command example:
$ bin/mqadmin getBrokerConfig -b x.x.x.x:10911 -n x.x.x.x:9876
RocketMQLog:WARN No appenders could be found for logger (io.netty.util.internal.PlatformDependent0).
RocketMQLog:WARN Please initialize the logger system properly.
============x.x.x.x:10911============
serverSelectorThreads = 3
brokerRole = ASYNC_MASTER
serverSocketRcvBufSize = 131072
osPageCacheBusyTimeOutMills = 1000
shortPollingTimeMills = 1000
clientSocketRcvBufSize = 131072
clusterTopicEnable = true
brokerTopicEnable = true
autoCreateTopicEnable = true
maxErrorRateOfBloomFilter = 20
maxMsgsNumBatch = 64
cleanResourceInterval = 10000
...
Updating Broker Configuration #
You can use the updateBrokerConfig
command to update the configuration of a broker. The updated configuration takes effect immediately without the need to restart the broker.
Command example:
$ bin/mqadmin updateBrokerConfig -b x.x.x.x:10911 -n dev-mq1.ttbike.com.cn:9876 -k slaveReadEnable -v true
RocketMQLog:WARN No appenders could be found for logger (io.netty.util.internal.PlatformDependent0).
RocketMQLog:WARN Please initialize the logger system properly.
update broker config success, x.x.x.x:10911
Field meanings:
Field | Meaning |
---|---|
-b | Broker address |
-n | NameServer address |
-k | The key of the configuration to be updated |
-v | The corresponding value of the configuration key to be updated |
Sending Messages to Broker #
You can use the sendMsgStatus
command to send test messages to a specific broker and check the running status of the broker.
Command example:
bin/mqadmin sendMsgStatus -b dev_mq_d -n x.x.x.x:9876
RocketMQLog:WARN No appenders could be found for logger (io.netty.util.internal.PlatformDependent0).
RocketMQLog:WARN Please initialize the logger system properly.
rt:2ms, SendResult=SendResult [sendStatus=SEND_OK, msgId=0A6F4B60457D5ACF98009C90AD2C0001, offsetMsgId=0A6F4B6000002AC100000000D0B7A942, messageQueue=MessageQueue [topic=dev_mq_d, brokerName=dev_mq_d, queueId=0], queueOffset=4486548]rt:2ms,...
Field meanings:
Field | Meaning |
---|---|
-b | Broker Name |
-n | NameServer Address |
-c | Specify the number of messages to send, default is 50 |
-s | Specify the message body size, default is 128k |
Summary of Message Commands #
Print Topic Messages #
The printMsg
command can be used to print messages in a topic.
Command example:
$ bin/mqadmin printMsg -d true -n x.x.x.x:9876 -t melon_dev_test
RocketMQLog:WARN No appenders could be found for logger (io.netty.util.internal.PlatformDependent0).
RocketMQLog:WARN Please initialize the logger system properly.
minOffset=0, maxOffset=0, MessageQueue [topic=melon_dev_test, brokerName=dev_mq_b, queueId=2]minOffset=0, maxOffset=0, MessageQueue [topic=melon_dev_test, brokerName=dev_mq_d, queueId=4]minOffset=0, maxOffset=0, MessageQueue [topic=melon_dev_test, brokerName=dev_mq_b, queueId=4]minOffset=0, maxOffset=0, MessageQueue [topic=melon_dev_test, brokerName=dev_mq_d, queueId=6]minOffset=0, maxOffset=0, MessageQueue [topic=melon_dev_test, brokerName=dev_mq_b, queueId=6]minOffset=0, maxOffset=1, MessageQueue [topic=melon_dev_test, brokerName=dev_mq_d, queueId=8]MessageQueue [topic=melon_dev_test, brokerName=dev_mq_d, queueId=8] no matched msg. status=NO_MATCHED_MSG, offset=1minOffset=0, maxOffset=0, MessageQueue [topic=melon_dev_test, brokerName=dev_mq_b, queueId=8]minOffset=0, maxOffset=0, MessageQueue [topic=melon_dev_test, brokerName=dev_mq_d, queueId=10]minOffset=0, maxOffset=0, MessageQueue [topic=melon_dev_test, brokerName=dev_mq_d, queueId=0]minOffset=0, maxOffset=0, MessageQueue [topic=melon_dev_test, brokerName=dev_mq_b, queueId=0]minOffset=0, maxOffset=0, MessageQueue [topic=melon_dev_test, brokerName=dev_mq_d, queueId=2]minOffset=0, maxOffset=0, MessageQueue [topic=melon_dev_test, brokerName=dev_mq_b, queueId=10]minOffset=0, maxOffset=0, MessageQueue [topic=melon_dev_test, brokerName=dev_mq_d, queueId=12]minOffset=0, maxOffset=0, MessageQueue [topic=melon_dev_test, brokerName=dev_mq_b, queueId=12]minOffset=0, maxOffset=1, MessageQueue [topic=melon_dev_test, brokerName=dev_mq_d, queueId=14]MessageQueue [topic=melon_dev_test, brokerName=dev_mq_d, queueId=14] no matched msg. status=NO_MATCHED_MSG, offset=1minOffset=0, maxOffset=2, MessageQueue [topic=melon_dev_test, brokerName=dev_mq_b, queueId=14]MSGID: 0A6F4BA1743E7BA18F1B9F54E2210028 MessageExt [brokerName=dev_mq_b, queueId=14, storeSize=225, queueOffset=1, sysFlag=0, bornTimestamp=1596205940257, bornHost=/10.111.75.161:42806, storeTimestamp=1596205940257, storeHost=/10.111.75.95:10911, msgId=0A6F4B5F00002A9F000000138873E059, commitLogOffset=83893674073, bodyCRC=1649915861, reconsumeTimes=0, preparedTransactionOffset=0, toString()=Message{topic='melon_dev_test', flag=0, properties={MIN_OFFSET=0, uber-trace-id=7617a5ff2fa5bf68%3A7617a5ff2fa5bf68%3A0%3A0, MAX_OFFSET=2, UNIQ_KEY=0A6F4BA1743E7BA18F1B9F54E2210028, WAIT=true}, body=[104, 101, 108, 108, 111, 32, 98, 97, 98, 121], transactionId='null'}] BODY: hello baby
Field meanings:
Name | Meaning |
---|---|
-d | Whether to print the message body, default is false |
-n | NameServer Address |
-t | Topic Name |
-b | Start timestamp, format is currentTimeMillis |
-c | Character encoding, default is UTF-8 |
-e | End timestamp, format is currentTimeMillis |
-s | Subscribed tags, default is all (*) , format TagA |
Query Messages by MsgId #
The queryMsgById
command is used to query messages stored in the cluster.
Command example:
$ bin/mqadmin queryMsgById -n x.x.x.x:9876 -i 0A6F4B5F00002A9F000000138873E059
RocketMQLog:WARN No appenders could be found for logger (io.netty.util.internal.PlatformDependent0).
RocketMQLog:WARN Please initialize the logger system properly.
OffsetID: 0A6F4B5F00002A9F000000138873E059
Topic: melon_dev_test
Tags: [null]
Keys: [null]
Queue ID: 14
Queue Offset: 1
CommitLog Offset: 83893674073
Reconsume Times: 0
Born Timestamp: 2020-07-31 22:32:20,257
Store Timestamp: 2020-07-31 22:32:20,257
Born Host: x.x.x.x:42806
Store Host: x.x.x.x:10911
System Flag: 0
Properties: {uber-trace-id=7617a5ff2fa5bf68%3A7617a5ff2fa5bf68%3A0%3A0, UNIQ_KEY=0A6F4BA1743E7BA18F1B9F54E2210028, WAIT=true}
Message Body Path: /tmp/rocketmq/msgbodys/0A6F4BA1743E7BA18F1B9F54E2210028
MessageTrack [consumerGroup=melon_dev_consumer, trackType=NOT_ONLINE, exceptionDesc=CODE:206 DESC:the consumer group[melon_dev_consumer] not online]
Field meanings:
Name | Meaning |
---|---|
-n | NameServer Address |
-i | Message ID |
OffsetID | |
Topic | Topic Name |
Tags | Message Tags |
Keys | Message Key |
Queue ID | Message Storage Queue |
Queue Offset | Message Offset in the Queue |
CommitLog Offset | Message Offset in the commitLog file |
Reconsume Times | Number of times the message was reconsumed |
Born Timestamp | Timestamp when the message was born |
Store Timestamp | Timestamp when the message was stored |
Born Host | IP address of the message sender |
Store Host | IP address where the message was stored |
System Flag | Flag information |
Properties | Property information |
Message Body Path | Path where the message body is stored |
MessageTrack | Consumption information |
Query Messages by Key #
You can use the queryMsgByKey
command to query messages based on the message key.
Command example:
$ bin/mqadmin queryMsgByKey -n x.x.x.x:9876 -t melon_dev_test -k orderNo1
RocketMQLog:WARN No appenders could be found for logger (io.netty.util.internal.PlatformDependent0).
RocketMQLog:WARN Please initialize the logger system properly.
#Message ID #QID #Offset
0A6F4BA1743E7BA18F1B022183DA002B 2 0
Field Meaning:
Name | Meaning |
---|---|
-n | NameServer address |
-t | Topic name |
-k | Message key |
Message ID | Message ID |
QID | Queue where the message is stored |
Offset | Offset of the message in the queue |
Retrieve Message by Offset #
Messages are stored in queues in the Broker, and you can also retrieve messages by their offsets.
Example command:
$ bin/mqadmin queryMsgByOffset -n x.x.x.x:9876 -t melon_dev_test -b dev_mq_b -i 2 -o 0
RocketMQLog:WARN No appenders could be found for logger (io.netty.util.internal.PlatformDependent0).
RocketMQLog:WARN Please initialize the logger system properly.
OffsetID: 0A6F4B5F00002A9F00000013A37FED85
Topic: melon_dev_test
Tags: [null]
Keys: [orderNo1]
Queue ID: 2
Queue Offset: 0
CommitLog Offset: 84347448709
Reconsume Times: 0
Born Timestamp: 2020-08-01 09:55:50,874
Store Timestamp: 2020-08-01 09:55:50,875
Born Host: x.x.x.x:42806
Store Host: x.x.x.x:10911
System Flag: 0
Properties: {MIN_OFFSET=0, uber-trace-id=74e72c15f101da93%3A74e72c15f101da93%3A0%3A0, MAX_OFFSET=1, KEYS=orderNo1, UNIQ_KEY=0A6F4BA1743E7BA18F1B022183DA002B, WAIT=true}
Message Body Path: /tmp/rocketmq/msgbodys/0A6F4BA1743E7BA18F1B022183DA002B
Field Meaning:
Name | Meaning |
---|---|
-n | NameServer address |
-t | Topic |
-b | Broker name |
-i | Queue ID |
-o | Offset |
OffsetID | Message ID |
Topic | Topic name |
Tags | Message tags |
Keys | Message keys |
Queue ID | Queue where the message is stored |
Queue Offset | Offset of the message in the queue |
CommitLog Offset | Offset of the message in the commitLog file |
Reconsume Times | Number of times the message has been reconsumed |
Born Timestamp | Timestamp when the message was born |
Store Timestamp | Timestamp when the message was stored |
Born Host | IP address of the machine that sent the message |
System Flag | Flag information |
Properties | Property information |
Message Body Path | Path to the stored message body |
MessageTrack | Consumption information |
Retrieve Message by UniqueKey #
You can also retrieve messages using the command queryMsgByUniqueKey.
Example command:
$ bin/mqadmin queryMsgByUniqueKey -n dev-mq1.ttbike.com.cn:9876 -t melon_dev_test -i 0A6F4BA1743E7BA18F1B022183DA002B
RocketMQLog:WARN No appenders could be found for logger (io.netty.util.internal.PlatformDependent0).
RocketMQLog:WARN Please initialize the logger system properly.
Topic: melon_dev_test
Tags: [null]
Keys: [orderNo1]
Queue ID: 2
Queue Offset: 0
CommitLog Offset: 84347448709
Reconsume Times: 0
Born Timestamp: 2020-08-01 09:55:50,874
Store Timestamp: 2020-08-01 09:55:50,875
Born Host: x.x.x.x:42806
Store Host: x.x.x.x:10911
System Flag: 0
Properties: {uber-trace-id=74e72c15f101da93%3A74e72c15f101da93%3A0%3A0, KEYS=orderNo1, UNIQ_KEY=0A6F4BA1743E7BA18F1B022183DA002B, WAIT=true}
Message Body Path: /tmp/rocketmq/msgbodys/0A6F4BA1743E7BA18F1B022183DA002B
Field Meaning:
The field meaning is the same as the previous command.