[root@localhost-001 bin]# sh mqadmin The most commonly used mqadmin commands are: updateTopic Update or create topic deleteTopic Delete topic from broker and NameServer. updateSubGroup Update or create subscription group deleteSubGroup Delete subscription group from broker. updateBrokerConfig Update broker's config updateTopicPerm Update topic perm topicRoute Examine topic route info topicStatus Examine topic Status info topicClusterList get cluster info for topic brokerStatus Fetch broker runtime status data queryMsgById Query Message by Id queryMsgByKey Query Message by Key queryMsgByUniqueKey Query Message by Unique key queryMsgByOffset Query Message by offset printMsg Print Message Detail printMsgByQueue Print Message Detail sendMsgStatus send msg to broker. brokerConsumeStats Fetch broker consume stats data producerConnection Query producer's socket connection and client version consumerConnection Query consumer's socket connection, client version and subscription consumerProgress Query consumers's progress, speed consumerStatus Query consumer's internal data structure cloneGroupOffset clone offset from other group. clusterList List all of clusters topicList Fetch all topic list from name server updateKvConfig Create or update KV config. deleteKvConfig Delete KV config. wipeWritePerm Wipe write perm of broker in all name server resetOffsetByTime Reset consumer offset by timestamp(without client restart). updateOrderConf Create or update or delete order conf cleanExpiredCQ Clean expired ConsumeQueue on broker. cleanUnusedTopic Clean unused topic on broker. startMonitoring Start Monitoring statsAll Topic and Consumer tps stats allocateMQ Allocate MQ checkMsgSendRT check message send response time clusterRT List All clusters Message Send RT getNamesrvConfig 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 message consumeMessage Consume message updateAclConfig Update acl config yaml file in broker deleteAccessConfig Delete Acl Config Account in broker clusterAclConfigVersion List all of acl config version information in cluster updateGlobalWhiteAddr Update global white address for acl Config File in broker getAccessConfigSubCommand List all of acl config information in cluster See 'mqadmin help <command>' for more information on a specific command.
其中列出了最常用的命令,并附有简短说明。要获取每个命令的详细手册,使用命令:bash mqadmin help 。例如,命令bash mqadmin help clusterList将显示以下帮助文本:
1 2 3 4 5 6 7
[root@localhost-001 bin]# bash mqadmin help clusterList usage: mqadmin clusterList [-h] [-i <arg>] [-m] [-n <arg>] -h,--help Print help -i,--interval <arg> specify intervals numbers, it is in seconds -m,--moreStats Print more stats -n,--namesrvAddr <arg> Name server address list, eg: 192.168.0.1:9876;192.168.0.2:9876 [root@localhost-001 bin]#
[root@localhost-001 bin] 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 172.24.30.194:10911 success. create topic to 172.24.30.193:10911 success. create topic to 172.24.30.192:10911 success. TopicConfig [topicName=zhurunhua, readQueueNums=8, writeQueueNums=8, perm=RW-, topicFilterType=SINGLE_TAG, topicSysFlag=0, order=false] [root@localhost-001 bin]
deleteTopic
作用:从broker和nameserver删除topic
命令:mqadmin deleteTopic -c [-h] [-n ] -t
参数
含义
备注
-c,–clusterName
指定cluster名称
-h,–help
打印help信息
-n,–namesrvAddr
name server地址列表
以分号分割,例如:192.168.0.1:9876;192.168.0.2:9876
-t,–topic
设置topic名称
示例:
1 2 3 4 5
[root@localhost-001 bin] RocketMQLog:WARN No appenders could be found for logger (io.netty.util.internal.PlatformDependent0). RocketMQLog:WARN Please initialize the logger system properly. delete topic [zhurunhua] from cluster [xdf-test1] success. delete topic [zhurunhua] from NameServer success.
topicList
作用:从nameserver列出所有topic
命令:mqadmin topicList [-c] [-h] [-n ]
参数
含义
备注
-h,–help
打印help信息
-n,–namesrvAddr
nameserver服务地址列表
-c,–clusterModel
指定cluster模式
示例:
1 2 3 4 5 6 7 8 9
[root@localhost-001 bin] RocketMQLog:WARN No appenders could be found for logger (io.netty.util.internal.PlatformDependent0). RocketMQLog:WARN Please initialize the logger system properly. %DLQ%xxoo %RETRY%dfub-order BenchmarkTest testschedule ... ...
[root@localhost-001 bin] 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 4 in 172.24.30.192:10911 success. TopicConfig [topicName=zhurunhua, readQueueNums=8, writeQueueNums=8, perm=R--, topicFilterType=SINGLE_TAG, topicSysFlag=0, order=false].
[root@localhost-001 bin] RocketMQLog:WARN No appenders could be found for logger (io.netty.util.internal.PlatformDependent0). RocketMQLog:WARN Please initialize the logger system properly.
[root@localhost-001 bin] RocketMQLog:WARN No appenders could be found for logger (io.netty.util.internal.PlatformDependent0). RocketMQLog:WARN Please initialize the logger system properly. xdf-test1 [root@localhost-001 bin]
[root@localhost-001 bin] RocketMQLog:WARN No appenders could be found for logger (io.netty.util.internal.PlatformDependent0). RocketMQLog:WARN Please initialize the logger system properly. success [root@localhost-001 bin]
注意:需同时指定nameserver和broker地址,若只指定了nameserver,会报错:wait response on the channel <172.24.30.192:9876> timeout, 4904(ms)
[root@localhost-001 bin] RocketMQLog:WARN No appenders could be found for logger (io.netty.util.internal.PlatformDependent0). RocketMQLog:WARN Please initialize the logger system properly.
[root@localhost-001 bin] RocketMQLog:WARN No appenders could be found for logger (io.netty.util.internal.PlatformDependent0). RocketMQLog:WARN Please initialize the logger system properly. rt:1ms, SendResult=SendResult [sendStatus=SEND_OK, msgId=AC110001F3237EA987AC6F72C5140001, offsetMsgId=AC181EC000002A9F000000014136B4B6, messageQueue=MessageQueue [topic=broker-a, brokerName=broker-a, queueId=0], queueOffset=58]rt:1ms, SendResult=SendResult [sendStatus=SEND_OK, msgId=AC110001F3237EA987AC6F72C5160002, offsetMsgId=AC181EC000002A9F000000014136B597, messageQueue=MessageQueue [topic=broker-a, brokerName=broker-a, queueId=0], queueOffset=59]rt:5ms, SendResult=SendResult [sendStatus=SEND_OK, msgId=AC110001F3237EA987AC6F72C5170003, offsetMsgId=AC181EC000002A9F000000014136B678, messageQueue=MessageQueue [topic=broker-a, brokerName=broker-a, queueId=0], queueOffset=60] [root@localhost-001 bin] [root@localhost-001 bin]
queryMsgByKey
作用:根据key查询消息
命令:mqadmin queryMsgByKey [-h] -k [-n ] -t
参数
含义
备注
-h,–help
打印help信息
-n,–namesrvAddr
nameserver服务地址列表
-t,–topic
topic名称
-k,–msgKey
消息key
示例:
1 2 3 4 5 6 7 8 9 10 11 12 13 14
[root@localhost-001 bin] RocketMQLog:WARN No appenders could be found for logger (io.netty.util.internal.PlatformDependent0). RocketMQLog:WARN Please initialize the logger system properly.
[root@localhost-001 bin] RocketMQLog:WARN No appenders could be found for logger (io.netty.util.internal.PlatformDependent0). RocketMQLog:WARN Please initialize the logger system properly. OffsetID: AC181EC100002A9F000000018A727660 Topic: zhurunhua Tags: [测试message] Keys: [test-key] Queue ID: 2 Queue Offset: 0 CommitLog Offset: 6617724512 Reconsume Times: 0 Born Timestamp: 2023-03-01 15:08:31,339 Store Timestamp: 2023-03-01 15:08:31,345 Born Host: 172.24.30.192:25687 Store Host: 172.24.30.193:10911 System Flag: 0 Properties: {KEYS=test-key, UNIQ_KEY=AC110001EBBC7EA987AC6F6552EB0000, CLUSTER=xdf-test1, WAIT=true, TAGS=测试message} Message Body Path: /tmp/rocketmq/msgbodys/AC110001EBBC7EA987AC6F6552EB0000`
[root@localhost-001 bin] RocketMQLog:WARN No appenders could be found for logger (io.netty.util.internal.PlatformDependent0). RocketMQLog:WARN Please initialize the logger system properly. Topic: zhurunhua Tags: [测试message] Keys: [test-key1] Queue ID: 1 Queue Offset: 0 CommitLog Offset: 5865661490 Reconsume Times: 0 Born Timestamp: 2023-03-01 14:57:02,899 Store Timestamp: 2023-03-01 14:57:02,904 Born Host: 172.24.30.192:56596 Store Host: 172.24.30.194:10911 System Flag: 0 Properties: {KEYS=test-key1, UNIQ_KEY=AC110001E5CC7EA987AC6F5AD1B30000, CLUSTER=xdf-test1, WAIT=true, TAGS=测试message} Message Body Path: /tmp/rocketmq/msgbodys/AC110001E5CC7EA987AC6F5AD1B30000 [root@localhost-001 bin]`
[root@localhost-001 bin] 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 172.24.30.194:10911 success. create subscription group to 172.24.30.193:10911 success. create subscription group to 172.24.30.192:10911 success. SubscriptionGroupConfig [groupName=zhurunhua-consume-group, consumeEnable=true, consumeFromMinEnable=true, consumeBroadcastEnable=true, retryQueueNums=8, retryMaxTimes=3, brokerId=0, whichBrokerWhenConsumeSlowly=1, notifyConsumerIdsChangedEnable=true][root@localhost-001 bin] [root@localhost-001 bin]
[root@localhost-001 bin] RocketMQLog:WARN No appenders could be found for logger (io.netty.util.internal.PlatformDependent0). RocketMQLog:WARN Please initialize the logger system properly. delete subscription group [zhurunhua-consume-group] from broker [172.24.30.194:10911] in cluster [xdf-test1] success. delete subscription group [zhurunhua-consume-group] from broker [172.24.30.193:10911] in cluster [xdf-test1] success. delete subscription group [zhurunhua-consume-group] from broker [172.24.30.192:10911] in cluster [xdf-test1] success. delete topic [%RETRY%zhurunhua-consume-group] from cluster [xdf-test1] success. delete topic [%RETRY%zhurunhua-consume-group] from NameServer success. delete topic [%DLQ%zhurunhua-consume-group] from cluster [xdf-test1] success. delete topic [%DLQ%zhurunhua-consume-group] from NameServer success. [root@localhost-001 bin]
[root@localhost-001 bin] RocketMQLog:WARN No appenders could be found for logger (io.netty.util.internal.PlatformDependent0). RocketMQLog:WARN Please initialize the logger system properly. 001 172.24.202.77@org.apache.rocketmq.spring.support.DefaultRocketMQListenerContainer_10 V4_5_1 1600767940334/172.24.202.77@org.apache.rocketmq.spring.support.DefaultRocketMQListenerContainer_10
Same subscription in the same group of consumer
Rebalance OK [root@localhost-001 bin]
clusterList
作用:查看集群信息
命令:mqadmin clusterList [-h] [-i ] [-m] [-n ]
参数
含义
备注
-h,–help
打印help信息
-n,–namesrvAddr
nameserver服务地址列表
-i,–interval
指定间隔数
单位:秒
-m,–moreStats
打印更多信息
示例:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
[root@localhost-001 bin] RocketMQLog:WARN No appenders could be found for logger (io.netty.util.internal.PlatformDependent0). RocketMQLog:WARN Please initialize the logger system properly.
[root@localhost-001 bin] RocketMQLog:WARN No appenders could be found for logger (io.netty.util.internal.PlatformDependent0). RocketMQLog:WARN Please initialize the logger system properly.
[root@localhost-001 bin] RocketMQLog:WARN No appenders could be found for logger (io.netty.util.internal.PlatformDependent0). RocketMQLog:WARN Please initialize the logger system properly.
[root@localhost-001 bin] RocketMQLog:WARN No appenders could be found for logger (io.netty.util.internal.PlatformDependent0). RocketMQLog:WARN Please initialize the logger system properly.
[root@localhost-001 bin] RocketMQLog:WARN No appenders could be found for logger (io.netty.util.internal.PlatformDependent0). RocketMQLog:WARN Please initialize the logger system properly. Queue data: max: 1, min: 0 ====================================== idx: 0 ConsumeQueueData{physicOffset=6609928052, physicSize=395, tagsCode=0, extendDataJson='null', bitMap='null', eval=false, msg='null'} ====================================== [root@localhost-001 bin] [root@localhost-001 bin]
运维管理
wipeWritePerm
作用:清除特定Brokerd的写权限
命令:mqadmin wipeWritePerm -b [-h] [-n ]
参数
含义
备注
-h,–help
打印help信息
-n,–namesrvAddr
nameserver服务地址列表
-b,–brokerName
broker name
示例:
1 2 3 4 5
[root@localhost-001 bin] RocketMQLog:WARN No appenders could be found for logger (io.netty.util.internal.PlatformDependent0). RocketMQLog:WARN Please initialize the logger system properly. wipe write perm of broker[broker-a] in name server[172.24.30.192:9876] OK, 187 [root@localhost-001 bin]
./mqadmin resetOffsetByTime -n 172.24.30.192:9876 -g zhurunhua-1 -s now -t zhurunhua
cleanExpiredCQ
作用:清理过期的消费者队列
命令:mqadmin cleanExpiredCQ [-b ] [-c ] [-h] [-n ]
参数
含义
备注
-h,–help
打印help信息
-n,–namesrvAddr
nameserver服务地址列表
-b,–brokerAddr
broker地址
-c,–cluster
集群名称
示例:
1 2 3 4 5
[root@localhost-001 bin] RocketMQLog:WARN No appenders could be found for logger (io.netty.util.internal.PlatformDependent0). RocketMQLog:WARN Please initialize the logger system properly. success [root@localhost-001 bin]
[root@localhost-001 bin] RocketMQLog:WARN No appenders could be found for logger (io.netty.util.internal.PlatformDependent0). RocketMQLog:WARN Please initialize the logger system properly. ============172.24.30.192:9876============ serverChannelMaxIdleTimeSeconds = 120 listenPort = 9876 serverCallbackExecutorThreads = 0 serverAsyncSemaphoreValue = 64 serverSocketSndBufSize = 65535 rocketmqHome = /neworiental/rocketmq-nameserver/rocketmq-all-4.7.1-bin-release clusterTest = false serverSelectorThreads = 3 useEpollNativeSelector = false orderMessageEnable = false serverPooledByteBufAllocatorEnable = true kvConfigPath = /neworiental/rocketmq-nameserver/namesrv/kvConfig.json serverWorkerThreads = 8 serverSocketRcvBufSize = 65535 productEnvName = center serverOnewaySemaphoreValue = 256 configStorePath = /neworiental/rocketmq-nameserver/rocketmq-all-4.7.1-bin-release/conf/nameserver.conf [root@localhost-001 bin]
注意:经测试,-n每次只能指定一个nameserver地址
updateNamesrvConfig
作用:修改name server 配置
命令:mqadmin updateNamesrvConfig [-h] -k [-n ] -v
参数
含义
备注
-h,–help
打印help信息
-n,–namesrvAddr
nameserver服务地址列表
-k,–key
config key值
-v,–value
config value值
示例:
1 2 3 4 5 6
[root@localhost-001 bin] RocketMQLog:WARN No appenders could be found for logger (io.netty.util.internal.PlatformDependent0). RocketMQLog:WARN Please initialize the logger system properly. update name server config success![172.24.30.192:9876] serverSelectorThreads : 5 [root@localhost-001 bin]
[root@localhost-001 bin] 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, 172.24.30.194:10911 update broker config success, 172.24.30.193:10911 update broker config success, 172.24.30.192:10911 [root@localhost-001 bin]