官方文档
https://rocketmq.apache.org/zh/docs/
https://rocketmq.apache.org/zh/docs/domainModel/02topic/
https://rocketmq.apache.org/zh/docs/4.x/deployment/02admintool
集群配置管理
https://mp.weixin.qq.com/s/688wNSwZPraGvAnr0K7hRw
RocketMQ运维管理命令mqadmin-Topic
https://mp.weixin.qq.com/s/u_8pdzrnDcNMAWTI_z3eLg
https://blog.csdn.net/testbaibai/article/details/132078478
下载
https://rocketmq.apache.org/zh/download/
linux环境变量
vim /etc/profile
export JAVA_HOME=/cygdrive/c/jdkexport ROCKETMQ_HOME=/cygdrive/c/work/linuxtools/rocketmq-all-4.8.0-bin-release
export PATH=$ROCKETMQ_HOME/bin:$JAVA_HOME/bin:$PATH
export CLASSPATH=$CLASSPATH:$JAVA_HOME/lib:$JAVA_HOME/lib/tools.jar:$ROCKETMQ_HOME/lib
windows环境变量
JAVA_HOME=C:\Program Files\Java\jdk1.8.0_212ROCKETMQ_HOME=C:\work\linuxtools\rocketmq-all-4.8.0-bin-release
CLASSPATH=%CLASSPATH%;%JAVA_HOME%\lib;%JAVA_HOME%\lib\tools.jar;%ROCKETMQ_HOME%\lib
https://blog.csdn.net/God_WZH/article/details/119886519
客户端连接RocketMQ
https://support.huaweicloud.com/usermanual-hrm/hrm-ug-039.html
如果RocketMQ实例开启了ACL访问控制,执行mqadmin命令时,需要鉴权
切换到解压后的软件包目录下,在 conf/tools.yml 文件中,增加如下内容
accessKey: *******
secretKey: *******
常用命令
https://blog.csdn.net/testbaibai/article/details/132078478
https://blog.csdn.net/qq_44501429/article/details/137412867
mqadmin help
$ mqadmin.cmd
The most commonly used mqadmin commands are:updateTopic Update or create topicdeleteTopic Delete topic from broker and NameServer.updateSubGroup Update or create subscription groupdeleteSubGroup Delete subscription group from broker.updateBrokerConfig Update broker's configupdateTopicPerm Update topic permtopicRoute Examine topic route infotopicStatus Examine topic Status infotopicClusterList get cluster info for topicbrokerStatus Fetch broker runtime status dataqueryMsgById Query Message by IdqueryMsgByKey Query Message by KeyqueryMsgByUniqueKey Query Message by Unique keyqueryMsgByOffset Query Message by offsetQueryMsgTraceById query a message traceprintMsg Print Message DetailprintMsgByQueue Print Message DetailsendMsgStatus send msg to broker.brokerConsumeStats Fetch broker consume stats dataproducerConnection Query producer's socket connection and client versionconsumerConnection Query consumer's socket connection, client version and subscriptionconsumerProgress Query consumers's progress, speedconsumerStatus Query consumer's internal data structurecloneGroupOffset clone offset from other group.clusterList List all of clusterstopicList Fetch all topic list from name serverupdateKvConfig Create or update KV config.deleteKvConfig Delete KV config.wipeWritePerm Wipe write perm of broker in all name serverresetOffsetByTime Reset consumer offset by timestamp(without client restart).updateOrderConf Create or update or delete order confcleanExpiredCQ Clean expired ConsumeQueue on broker.cleanUnusedTopic Clean unused topic on broker.startMonitoring Start MonitoringstatsAll Topic and Consumer tps statsallocateMQ Allocate MQcheckMsgSendRT check message send response timeclusterRT List All clusters Message Send RTgetNamesrvConfig Get configs of name server.updateNamesrvConfig Update configs of name server.getBrokerConfig Get broker config by cluster or special broker!queryCq Query cq command.sendMessage Send a messageconsumeMessage Consume messageupdateAclConfig Update acl config yaml file in brokerdeleteAccessConfig Delete Acl Config Account in brokerclusterAclConfigVersion List all of acl config version information in clusterupdateGlobalWhiteAddr Update global white address for acl Config File in brokergetAccessConfigSubCommand List all of acl config information in clusterSee 'mqadmin help <command>' for more information on a specific command.$ mqadmin.cmd help resetOffsetByTime
usage: mqadmin resetOffsetByTime [-c] [-f <arg>] -g <arg> [-h] [-n <arg>] -s <arg> -t <arg>-c,--cplus reset c++ client offset-f,--force <arg> set the force rollback by timestamp switch[true|false]-g,--group <arg> set the consumer group-h,--help Print help-n,--namesrvAddr <arg> Name server address list, eg: 192.168.0.1:9876;192.168.0.2:9876-s,--timestamp <arg> set the timestamp[now|currentTimeMillis|yyyy-MM-dd#HH:mm:ss:SSS]-t,--topic <arg> set the topic
help
mqadmin.cmd 子命令 -h
mqadmin.cmd clusterList -h
查看集群信息:可以查看Clustername和brokerName的信息
mqadmin clusterList -n 11.54.89.103:8200
查看 Broker 统计信息、运行状态(你想要的信息几乎都在里面)
mqadmin.cmd brokerStatus -n 11.54.89.103:8200 -b 11.54.89.103:10103
Broker中各个消费者的消费情况,按Message Queue维度返回Consume Offset,Broker Offset,Diff,TImestamp等信息
mqadmin.cmd brokerConsumeStats -n 11.54.89.103:8200 -b 11.54.89.103:10101 -l 1
查看topic列表
mqadmin topicList -n 11.54.89.103:8200
查看死信队列
mqadmin topicList -n 172.18.5.44:8100 |grep "DLQ"
查看指定topic路由信息
mqadmin topicRoute -n 11.54.89.103:8200 -t tp_procureAcc
查看指定topic状态
mqadmin topicStatus -n 11.54.89.103:8200 -t tp_procureAcc
查看Topic所在集群列表
mqadmin.cmd topicClusterList -n 11.54.89.103:8200 -t tp_procureAcc
打印Topic订阅关系、TPS、积累量、24h读写总量
mqadmin.cmd statsAll -n 11.54.89.103:8200 -t tp_procureAcc
创建topic
mqadmin updateTopic -c Clustername -n localhost:9876 -t testtopic
mqadmin updateTopic -n <nameserver地址> -c <集群名称> -t <topic名称> -r 32 -w 32 -p 6
查看消费者组:查看订阅组消费状态
mqadmin.cmd consumerProgress -n 11.54.89.103:8200 -g cg_mktdistribute2b_memberIdentityCertified
./mqadmin consumerProgress -n 172.18.5.44:8100 -g cg_orderdry_orderResult
创建消费者组
mqadmin updateSubGroup -n localhost:9876 -c DefaultCluster -g testzygroup1
批量查看mq消费组消息堆积量
#!/bin/bash>error.txt
for group in $(cat group.txt);doif ./mqadmin consumerProgress -n 11.8.200.160:9876 -g MQ_INST_1540776964817304_BkZwNvvM%${group} 2> /dev/null |grep "Diff Total" &> /dev/null;thenecho -ne "${group}\t\t"./mqadmin consumerProgress -n 11.8.200.160:9876 -g MQ_INST_1540776964817304_BkZwNvvM%${group} |tail -1echoelseecho "${group}" >> error.txt./mqadmin consumerProgress -n 11.8.200.160:9876 -g MQ_INST_1540776964817304_BkZwNvvM%${group} >> error.txt 2>&1fi
done