mqadmin is rocketmq comes with command-line management tool, you can perform the operation in the bin directory, for example, you want to use query routing information in a topic:
>sh mqadmin topicroute -t topicName
{
"brokerDatas":[
{
"brokerAddrs":{0:"192.168.142.80:10911"
},
"brokerName":"bogon",
"cluster":"DefaultCluster"
}
],
"filterServerTable":{},
"queueDatas":[
{
"brokerName":"bogon",
"perm":6,
"readQueueNums":4,
"topicSynFlag":0,
"writeQueueNums":4
}
]
}
Using mqadmin command to create, modify configuration information broker topic update, query message and other specific operation, r "ocketmq real and Explanation" book are described in detail.
1.1. Console use
RocketMQ provided with a series of console commands and console for administrators to manage the subject, cluster, broker and other information;
Log console
First enter RocketMQ project, enter / RocketMQ / bin
There is a script in the directory mqadmin
View Help
In mqadmin can see what commands
sh mqadmin
View using specific commands
sh mqadmin help command name
For example, see the use of updateTopic
sh mqadmin help updateTopic
1.2. Detailed command
1.2.1. Creating Topic
instruction
updateTopic
Classpath
com.alibaba.rocketmq.tools.command.topic.UpdateTopicSubCommand
parameter |
Required |
Explanation |
-b |
If -c is empty, the required |
broker address, built in the broker represents the topic |
-c |
If -b is empty, the required |
cluster name, represents the topic in the build cluster (cluster can be found by clusterList) |
-h |
no |
Print Help |
-n |
Yes |
nameserve service address list, the format ip: port; ip: port; ... |
-p |
no |
Specify the new topic of access restrictions (W | R | WR) |
-r |
no |
Read queue number (the default is 8) |
-w |
no |
Write the number of the queue (default is 8) |
-t |
Yes |
opic name (character name can only be used ^ [a-zA-Z0-9 _-] + $) |
1.2.2. Delete Topic
instruction
deleteTopic
Classpath
com.alibaba.rocketmq.tools.command.topic.DeleteTopicSubCommand
parameter |
Required |
Explanation |
-c |
Yes |
cluster name that represents delete a topic in a cluster (cluster can clusterList query) |
-h |
no |
Print Help |
-n |
Yes |
nameserve service address list, the format ip: port; ip: port; ... |
-t |
Yes |
topic names (names are restricted to character ^ [a-zA-Z0-9 _-] + $) |
1.2.3. Create a (revised) Subscribe to group
instruction
updateSubGroup
Classpath
com.alibaba.rocketmq.tools.command.consumer.UpdateSubGroupSubCommand
parameter |
Required |
Explanation |
-b |
If -c is empty, the required |
broker address, represents a subscription form in the broker |
-c |
If -b is empty, the required |
cluster name, represents the topic in the build cluster (cluster can be found by clusterList) |
-d |
no |
Whether to allow broadcast consumption |
-g |
Yes |
Subscribe to the group name |
-i |
no |
Which broker from start spending |
-m |
no |
Whether to allow the consumer to start from the smallest of the queue, the default is set to false |
-q |
no |
Consumption failure message on a retry queue, each subscriber group arranged several retry queue |
-r |
no |
Consumption the maximum number of retries, than delivery to the dead letter queue is no longer delivered, and alarm |
-s |
no |
Consumption function is turned on |
-w |
no |
After the discovery message accumulation, the Consumer consumption redirect requests to another machine a Slave |
-h |
no |
Print Help |
-n |
Yes |
nameserve service address list, the format ip: port; ip: port; ... |
1.2.4. Delete subscription group configuration
instruction
deleteSubGroup
Classpath
com.alibaba.rocketmq.tools.command.consumer.DeleteSubscriptionGroupCommand
parameter |
Required |
Explanation |
-b |
If -c is empty, the required |
broker address, represents a subscription form in the broker |
-c |
If -b is empty, the required |
cluster name, represents the topic in the build cluster (cluster can be found by clusterList) |
-g |
Yes |
Subscribe to the group name |
-h |
no |
Print Help |
-n |
Yes |
nameserve service address list, the format ip: port; ip: port; ... |
1.2.5 Update Broker Profiles
instruction
updateBrokerConfig
Classpath
com.alibaba.rocketmq.tools.command.broker.UpdateBrokerConfigSubCommand
parameter |
Required |
Explanation |
-b |
If -c is empty, the required |
broker address, represents a subscription form in the broker |
-c |
If -b is empty, the required |
cluster name, represents the topic in the build cluster (cluster can be found by clusterList) |
-k |
是 |
key 值 |
-v |
否 |
value 值 |
-h |
否 |
打印帮助 |
-n |
是 |
nameserve 服务地址列表,格式ip:port;ip:port;... |
1.2.6. 查看Topic 列表信息
指令
topicList
类路径
com.alibaba.rocketmq.tools.command.broker.UpdateBrokerConfigSubCommand
参数 |
是否必填 |
说明 |
-h |
否 |
打印帮助 |
-n |
是 |
nameserve 服务地址列表,格式ip:port;ip:port;... |
1.2.7. 查看Topic 路由信息
指令
topicRoute
类路径
com.alibaba.rocketmq.tools.command.topic.TopicRouteSubCommand
参数 |
是否必填 |
说明 |
-t |
是 |
topic 名称 |
-h |
否 |
打印帮助 |
-n |
是 |
nameserve 服务地址列表,格式ip:port;ip:port;... |
1.2.8. 查看Topic 统计信息
指令
topicStats
类路径
com.alibaba.rocketmq.tools.command.topic.TopicStatsSubCommand
参数 |
是否必填 |
说明 |
-t |
是 |
topic 名称 |
-h |
否 |
打印帮助 |
-n |
是 |
nameserve 服务地址列表,格式ip:port;ip:port;... |
1.2.9. 查看Broker 统计信息
指令
brokerStats
类路径
com.alibaba.rocketmq.tools.command.broker.BrokerStatsSubCommanD
参数 |
是否必填 |
说明 |
-b |
是 |
broker 地址 |
-h |
否 |
打印帮助 |
-n |
是 |
nameserve 服务地址列表,格式ip:port;ip:port;... |
1.2.10. 根据消息ID 查询消息
指令
queryMsgById
类路径
com.alibaba.rocketmq.tools.command.message.QueryMsgByIdSubCommand
参数 |
是否必填 |
说明 |
-i |
是 |
消息id |
-h |
否 |
打印帮助 |
-n |
是 |
nameserve 服务地址列表,格式ip:port;ip:port;... |
1.2.11. 根据消息Key 查询消息
指令
queryMsgByKey
类路径
com.alibaba.rocketmq.tools.command.message.QueryMsgByKeySubCommand
参数 |
是否必填 |
说明 |
-f |
否 |
被查询消息的截止时间 |
-k |
是 |
msgKey |
-t |
是 |
topic 名称 |
-h |
否 |
打印帮助 |
-n |
是 |
nameserve 服务地址列表,格式ip:port;ip:port;... |
1.2.12. 根据Offset 查询消息
指令
queryMsgByOffset
类路径
com.alibaba.rocketmq.tools.command.message.QueryMsgByOffsetSubCommand
参数 |
是否必填 |
说明 |
-b |
是 |
Broker 名称,表示订阅组建在该broker(这里需要注意填写的是broker 的名称,不是broker 的地址,broker名称可以在clusterList 查到 |
-i |
是 |
query 队列id |
-o |
是 |
offset 值 |
-t |
是 |
topic 名称 |
-h |
否 |
打印帮助 |
-n |
是 |
nameserve 服务地址列表,格式ip:port;ip:port;... |
1.2.13. 查询Producer 的网络连接
该命令只打印当前与cluster 连接的producer 网络连接信息
指令
producerConnection
类路径
com.alibaba.rocketmq.tools.command.connection.ProducerConnectionSubCommand
参数 |
是否必填 |
说明 |
-g |
是 |
生产者所属组名 |
-t |
是 |
topic 名称 |
-h |
否 |
打印帮助 |
-n |
是 |
nameserve 服务地址列表,格式ip:port;ip:port;... |
1.2.14. 查询Consumer 的网络连接
该命令只打印当前与cluster 连接的consumer 网络连接信息
指令
consumerConnection
类路径
com.alibaba.rocketmq.tools.command.connection.ConsumerConnectionSubCommand
参数 |
是否必填 |
说明 |
-g |
是 |
消费者所属组名 |
-h |
否 |
打印帮助 |
-n |
是 |
nameserve 服务地址列表,格式ip:port;ip:port;... |
1.2.15. 查看订阅组消费状态
指令
consumerProgress
类路径
com.alibaba.rocketmq.tools.command.consumer.ConsumerProgressSubCommand
参数 |
是否必填 |
说明 |
-g |
是 |
消费者所属组名 |
-h |
否 |
打印帮助 |
-n |
是 |
nameserve 服务地址列表,格式ip:port;ip:port;... |
1.2.16. 查看集群消息
指令
clusterList
类路径
com.alibaba.rocketmq.tools.command.cluster.ClusterListSubCommand
参数 |
是否必填 |
说明 |
-m |
否 |
打印更多信息 |
-h |
否 |
打印帮助 |
-n |
是 |
nameserve 服务地址列表,格式ip:port;ip:port;... |
1.2.17. 添加(更新)KV 配置信息
指令
updateKvConfig
类路径
com.alibaba.rocketmq.tools.command.namesrv.UpdateKvConfigCommand
参数 |
是否必填 |
说明 |
-k |
是 |
key 值 |
-v |
是 |
value 值 |
-s |
是 |
Namespace 值 |
-h |
否 |
打印帮助 |
-n |
是 |
nameserve 服务地址列表,格式ip:port;ip:port;... |
1.2.18. 删除KV 配置信息
指令
deleteKvConfig
类路径
com.alibaba.rocketmq.tools.command.namesrv.DeleteKvConfigCommand
参数 |
是否必填 |
说明 |
-k |
是 |
key 值 |
-s |
是 |
Namespace 值 |
-h |
否 |
打印帮助 |
-n |
是 |
nameserve 服务地址列表,格式ip:port;ip:port;... |
1.2.19. 添加(更新)Project group 配置信息
指令 updateProjectGroup
类路径 com.alibaba.rocketmq.tools.command.namesrv.UpdateProjectGroupCommand
参数 |
是否必填 |
说明 |
-p |
是 |
project group 名 |
-i |
否 |
服务器ip |
-h |
否 |
打印帮助 |
-n |
是 |
nameserve 服务地址列表,格式ip:port;ip:port;... |
1.2.20. 删除Project group 配置信息
指令
deleteProjectGroup
类路径
com.alibaba.rocketmq.tools.command.namesrv.DeleteProjectGroupCommand
参数 |
是否必填 |
说明 |
-p |
是 |
project group 名 |
-i |
否 |
服务器ip |
-h |
否 |
打印帮助 |
-n |
是 |
nameserve 服务地址列表,格式ip:port;ip:port;... |
1.2.21. 取得Project group 配置信息
指令
getProjectGroup
类路径
com.alibaba.rocketmq.tools.command.namesrv.GetProjectGroupCommand
参数 |
是否必填 |
说明 |
-p |
是 |
project group 名 |
-i |
否 |
服务器ip |
-h |
否 |
打印帮助 |
-n |
是 |
nameserve 服务地址列表,格式ip:port;ip:port;... |
1.2.22. 设置消费进度
根据时间来设置消费进度,设置之前要关闭这个订阅组的所有consumer,设置完再启动,方可生效
指令
resetOffsetByTime
类路径
com.alibaba.rocketmq.tools.command.offset.ResetOffsetByTimeSubCommand
参数 |
是否必填 |
说明 |
-f |
否 |
通过时间戳强制回滚(true|false),默认为true |
-s |
是 |
时间戳 |
-g |
是 |
消费者所属组名 |
-t |
是 |
topic 名称 |
-h |
否 |
打印帮助 |
-n |
是 |
nameserve 服务地址列表,格式ip:port;ip:port;... |
1.2.23. 清除特定Broker权限
指令
wipeWritePerm
类路径
com.alibaba.rocketmq.tools.command.namesrv.WipeWritePermSubCommand
参数 |
是否必填 |
说明 |
-b |
是 |
broker 地址 |
-h |
否 |
打印帮助 |
-n |
是 |
nameserve 服务地址列表,格式ip:port;ip:port;... |
1.2.24. 获取Consumer消费进度
该命令只打印当前与cluster 连接的consumer 的消费进度
指令
getConsumerStatus
类路径
com.alibaba.rocketmq.tools.command.offset.GetConsumerStatusCommand
参数 |
是否必填 |
说明 |
-g |
是 |
消费者所属组名 |
-t |
是 |
查询主题 |
-i |
否 |
Consumer 客户端ip |
-h |
否 |
打印帮助 |
-n |
是 |
nameserve 服务地址列表,格式ip:port;ip:port;... |