Admin Tool
Notice
- To execute a command:
./mqadmin {command} {args}
- Most commands require the configuration of the NameServer address with the
-n
flag, in the formatip:port
- Most commands can get help with the
-h
flag - If both the Broker address (
-b
) and the clusterName (-c
) are configured, the command will be executed using the Broker address. If the Broker address is not configured, the command will be executed on all hosts in the cluster. Only one Broker address is supported, in the formatip:port
, where the port is 10911 by default. - In the
tools
directory, you can see many commands, but not all of them can be used. Only those initialized inMQAdminStartup
can be used. You can also modify this class to add or define your own commands. - Some commands may not have been updated due to version updates, and may cause errors. In this case, please read the relevant command source code.
Topic-related
Topic-related parameters
Name | Definition | Command options | Explain |
updateTopic | Create/update topic configuration | -b | Broker address, representing the Broker where the topic is located. Only a single Broker is supported, with the address in the format ip:port. |
-c | Cluster name, representing the cluster where the topic is located (the cluster can be queried with the clusterList command). | ||
-h | Print help | ||
-n | NameServer address,format ip:port | ||
-p | Specify the read-write permissions for the new topic( W=2|R=4|WR=6 ) | ||
-r | Number of readable queues(default is 8) | ||
-w | Number of writable queues(default is 8) | ||
-t | Topic name (the name can only use the characters ^[a-zA-Z0-9_-]+$ ) | ||
deleteTopic | Delete Topic | -c | Cluster name, representing the deletion of a specific topic under a certain cluster (the cluster can be queried with the clusterList command). |
-h | Print help | ||
-n | NameServer address,format ip:port | ||
-t | topic name (the name can only use the characters ^[a-zA-Z0-9_-]+$ ) | ||
topicList | Query topic list information | -h | Print help |
-c | Without the -c flag, only the topic list is returned. Adding -c returns the clusterName, topic, and consumerGroup information, i.e. the cluster that the topic belongs to and the subscription relationship. There are no parameters. | ||
-n | NameServer address,format ip:port | ||
topicRoute | Query topic routing information | -t | topic name |
-h | Print help | ||
-n | NameServer address,format ip:port | ||
topicStatus | Query topic message queue offsets | -t | topic name |
-h | Print help | ||
-n | NameServer address,format ip:port | ||
topicClusterList | Query list of clusters where the topic is located | -t | topic name |
-h | Print help | ||
-n | NameServer address,format ip:port | ||
updateTopicPerm | Update topic read-write permissions | -t | topic name |
-h | Print help | ||
-n | NameServer address,format ip:port | ||
-b | Broker address, representing the Broker where the topic is located. Only a single Broker is supported, with the address in the format ip:port. | ||
-p | Specify the read-write permissions for the new topic( W=2|R=4|WR=6 ) | ||
-c | Cluster name, representing the cluster where the topic is located (the cluster can be queried with the clusterList command). The -b flag takes precedence. If there is no -b flag, the command will be executed on all Brokers in the cluster. | ||
updateOrderConf | Create, delete, and get specific kv configurations from the NameServer. This feature is currently not available. | -h | Print help |
-n | NameServer address,format ip:port | ||
-t | topic,key | ||
-v | orderConf,value | ||
-m | method,optional get、put、delete | ||
allocateMQ | Calculate the load results of the message queue for the consumer list using an average load algorithm. | -t | topic name |
-h | Print help | ||
-n | NameServer address,format ip:port | ||
-i | ipList,separated by commas, calculates the message queue load for these IPs for the topic. | ||
statsAll | Print information about the topic's subscriptions, TPS, accumulation, 24-hour total read-write volume, etc. | -h | Print help |
-n | NameServer address,format ip:port | ||
-a | Print only active topics | ||
-t | Specify topic |
Cluster-related
Cluster-related parameters
Name | Definition | Command options | Explain |
clusterList | Query cluster information, including the cluster, BrokerName, BrokerId, TPS, and other information. | -m | Print more information (additional information printed includes: #InTotalYest, #OutTotalYest,#InTotalToday ,#OutTotalToday) |
-h | Print help | ||
-n | NameServer address,format ip:port | ||
-i | Print interval, in seconds. | ||
clusterRT | Send a message to test the RT of each Broker in the cluster. The message is sent to the${BrokerName} Topic。 | -a | amount,the total number of probes each time. RT = total time / amount |
-s | Message size,Unit: B | ||
-c | Which cluster to probe | ||
-p | Whether to print formatted logs, separated by |, default is not printed. | ||
-h | Print help | ||
-m | Belonging datacenter, for printing purposes. | ||
-i | Send interval,in seconds. | ||
-n | NameServer address,format ip:port |
Broker-related
Broker-related parameters
Name | Definition | Command options | Explain |
queryMsgById | Query the msg based on offsetMsgId. If using the open source console, offsetMsgId should be used. This command has additional parameters, for more information on their function, please read QueryMsgByIdSubCommand. | -i | msgId |
-h | Print help | ||
-n | NameServer address,format ip:port | ||
queryMsgByKey | Query message based on message key. | -k | msgKey |
-t | Topic name | ||
-h | Print help | ||
-n | NameServer address,format ip:port | ||
queryMsgByOffset | Query message based on offset. | -b | Broker name (note that the name of the Broker, not its address, should be entered here. The Broker name can be found using the clusterList command). |
-i | query queue id | ||
-o | offset value | ||
-t | topic name | ||
-h | Print help | ||
-n | NameServer address,format ip:port | ||
queryMsgByUniqueKey | Query based on msgId. msgId is different from offsetMsgId, for more information see common operations issues. -g and -d are used together, after finding the message, try to let a specific consumer consume the message and return the consumption result. | -h | Print help |
-n | NameServer address,format ip:port | ||
-i | uniqe msg id | ||
-g | consumerGroup | ||
-d | clientId | ||
-t | topic name | ||
checkMsgSendRT | Check the RT of sending messages to a topic. The function is similar to clusterRT. | -h | Print help |
-n | NameServer address,format ip:port | ||
-t | topic name | ||
-a | Number of probes | ||
-s | message size | ||
sendMessage | Send a message, which can be sent to a specific message queue based on configuration, or a normal send. | -h | Print help |
-n | NameServer address,format ip:port | ||
-t | topic name | ||
-p | message body | ||
-k | keys | ||
-c | tags | ||
-b | BrokerName | ||
-i | queueId | ||
consumeMessage | Consume messages. Messages can be consumed based on offset, start & end timestamps, and message queues. Different configurations execute different consumption logic, see ConsumeMessageCommand for more information. | -h | Print help |
-n | NameServer address,format ip:port | ||
-t | topic name | ||
-b | BrokerName | ||
-o | Consume from offset | ||
-i | queueId | ||
-g | Consumer group | ||
-s | Start timestamp, see -h for format. | ||
-d | End timestamp | ||
-c | Consume a certain number of messages | ||
printMsg | Consume messages from Broker and print them, optional time period. | -h | Print help |
-n | NameServer address,format ip:port | ||
-t | topic name | ||
-c | Character set, e.g. UTF-8 | ||
-s | subExpress,filter expression | ||
-b | Start timestamp, see -h for format. | ||
-e | End timestamp | ||
-d | Whether to print the message body. | ||
printMsgByQueue | Similar to printMsg, but for a specific message queue. | -h | Print help |
-n | NameServer address,format ip:port | ||
-t | topic name | ||
-i | queueId | ||
-a | BrokerName | ||
-c | Character set, e.g. UTF-8 | ||
-s | subExpress, filter expression | ||
-b | Start timestamp, see -h for format. | ||
-e | End timestamp | ||
-p | Whether to print the message body. | ||
-d | Whether to print the message body. | ||
-f | Whether to count and print the number of tags | ||
resetOffsetByTime | Reset offset based on timestamp, both Broker and consumer will be reset. | -h | Print help |
-n | NameServer address, format ip:port | ||
-g | Consumer group | ||
-t | topic name | ||
-s | Reset to the offset corresponding to this timestamp. | ||
-f | Whether to force reset. If false, only backward offset is supported. If true, regardless of the relationship between the timestamp-corresponding offset and consumeOffset. | ||
-c | Whether to reset the offset for the C++ client. |
Message-related
Message-related parameters
Name | Definition | Command options | Explain |
queryMsgById | To query a message by its offset message ID (offsetMsgId), you can use the offsetMsgId command if using an open source console. This command has additional parameters, the specific function of which can be found by reading the QueryMsgByIdSubCommand. | -i | msgId |
-h | Print help | ||
-n | NameServer address,format ip:port | ||
queryMsgByKey | Query a message by key. | -k | msgKey |
-t | Topic name | ||
-h | Print help | ||
-n | NameServer address,format ip:port | ||
queryMsgByOffset | Query a message by offset | -b | Broker name (Note that this should be the name of the Broker, not the address. The name of the Broker can be found in clusterList.) |
-i | query queue id | ||
-o | offset value | ||
-t | topic name | ||
-h | Print help | ||
-n | NameServer address,format ip:port | ||
queryMsgByUniqueKey | Query based on msgId. Note that msgId is different from offsetMsgId. For more information, see Common Operations and Maintenance Issues. Use -g and -d together to try to have a specific consumer consume the message and return the consumption result once the message has been found. | -h | Print help |
-n | NameServer address,format ip:port | ||
-i | uniqe msg id | ||
-g | consumerGroup | ||
-d | clientId | ||
-t | topic name | ||
checkMsgSendRT | Check the RT (round-trip time) for sending messages to a topic. This function is similar to clusterRT. | -h | Print help |
-n | NameServer address,format ip:port | ||
-t | topic name | ||
-a | Number of probes. | ||
-s | Message size | ||
sendMessage | Send a message, which can be sent to a specific Message Queue according to configuration or sent normally. | -h | Print help |
-n | NameServer address,format ip:port | ||
-t | topic name | ||
-p | body,message body | ||
-k | keys | ||
-c | tags | ||
-b | BrokerName | ||
-i | queueId | ||
consumeMessage | Consume messages. Messages can be consumed based on offset, start & end timestamps, and message queue. Different configurations will execute different consumption logic. See ConsumeMessageCommand for more information. | -h | Print help |
-n | NameServer address,format ip:port | ||
-t | topic name | ||
-b | BrokerName | ||
-o | Consume from a specified offset. | ||
-i | queueId | ||
-g | Consumer group | ||
-s | Start timestamp, see -h for format. | ||
-d | End timestamp | ||
-c | Consume a specified number of messages. | ||
printMsg | Consume and print messages from the Broker within a specified time period. | -h | Print help |
-n | NameServer address,format ip:port | ||
-t | topic name | ||
-c | Character set, e.g. UTF-8 | ||
-s | subExpress,filter expression | ||
-b | Start timestamp, see -h for format. | ||
-e | End timestamp | ||
-d | Whether to print message body | ||
printMsgByQueue | Similar to printMsg, but specifies a Message Queue. | -h | Print help |
-n | NameServer address,format ip:port | ||
-t | topic name | ||
-i | queueId | ||
-a | BrokerName | ||
-c | Character set, e.g. UTF-8 | ||
-s | subExpress,filter expression | ||
-b | Start timestamp, see -h for format. | ||
-e | End timestamp | ||
-p | Whether to print the message | ||
-d | Whether to print the message body | ||
-f | Whether to count and print the number of tags | ||
resetOffsetByTime | Resetting the offset by timestamp will reset both the broker and the consumer. | -h | Print help |
-n | NameServer address, format ip:port | ||
-g | Consumer group | ||
-t | topic name | ||
-s | Reset to the offset corresponding to this timestamp. | ||
-f | Whether to force reset. If false, only backward offset is supported. If true, the relationship between the timestamp corresponding offset and consumeOffset is ignored. | ||
-c | Whether to reset the offset for the C++ client. |
Consume-related
Consume-related parameters
Name | Definitation | Command options | Explain |
consumerProgress | Consumer group consumption status, including specific client IP's message accumulation. | -g | consumer group name |
-s | Whether to print the client IP. | ||
-h | Pirnt help | ||
-n | NameServer address,format ip:port | ||
consumerStatus | Consumer status refers to the status of a consumer, including whether all consumers in the same group have the same subscriptions, whether the Process Queue is stacking up, and the jstack result of the consumer. The information returned by this command is extensive, and users should refer to the ConsumerStatusSubCommand for more details. | -h | Print help |
-n | NameServer address,format ip:port | ||
-g | consumer group | ||
-i | clientId | ||
-s | Whether to execute jstack | ||
getConsumerStatus | Get Consumer consumption progress | -g | Consumer group name |
-t | Query topic | ||
-i | Consumer client ip | ||
-n | NameServer address,format ip:port | ||
-h | Print help | ||
updateSubGroup | Update or create a subscription relationship. | -n | NameServer address,format ip:port |
-h | Print help | ||
-b | Broker address | ||
-c | Cluster name | ||
-g | Consumer group name | ||
-s | whether the group is allowed to consume | ||
-m | Whether to start consuming from the smallest offset. | ||
-d | Whether it is broadcast mode. | ||
-q | Number of retry queues. | ||
-r | Maximum number of retries | ||
-i | When slaveReadEnable is turned on and it has not yet reached the point where it is recommended to consume from the slave, it is possible to configure the standby machine id to actively consume from the standby machine. | ||
-w | If the Broker suggests consuming from the slave, the configuration determines which slave to consume from. The BrokerId can be configured, for example 1. | ||
-a | Whether other consumers are notified of load balancing when the number of consumers changes. | ||
deleteSubGroup | To remove a subscription from a Broker | -n | NameServer address,format ip:port |
-h | Print help | ||
-b | Broker address | ||
-c | Cluster name | ||
-g | Counsumer group name | ||
cloneGroupOffset | Using the offsets from the source consumer group in the target consumer group. | -n | NameServer address,format ip:port |
-h | Print help | ||
-s | Source consumer group | ||
-d | Target consumer group | ||
-t | topicname | ||
-o | Not currently in use. |
Connection-related
Connection-related parameters
Name | Definition | Command options | Explain |
consumerConnec tion | Query consumer network connections. | -g | Name of consumer group. |
-n | NameServer address,format ip:port | ||
-h | Print help | ||
producerConnec tion | Query producer network connections. | -g | Name of producer group. |
-t | topic name | ||
-n | NameServer address,format ip:port | ||
-h | Print help |
NameServer-related
Connection-related parameters
Name | Definition | Command options | Explain |
updateKvConfig | Update NameServer KV configuration, currently not in use. | -s | Name space |
-k | key | ||
-v | value | ||
-n | NameServer address,format ip:port | ||
-h | Print help | ||
deleteKvConfig | Delete NameServer KV configuration. | -s | Name space |
-k | key | ||
-n | NameServer address,format ip:port | ||
-h | Print help | ||
getNamesrvConfig | Get NameServer configuration. | -n | NameServer address,format ip:port |
-h | Print help | ||
updateNamesrvConfig | Modify NameServer configuration. | -n | NameServer address,format ip:port |
-h | Print help | ||
-k | key | ||
-v | value |
Others
Connection-related parameters
Name | Definition | Command options | Explain |
startMonitoring | Start the monitoring process to monitor events such as message deletion errors and the number of messages in the retry queue. | -n | NameServer address,format ip:port |
-h | Print help |