• RocketMQ实战之常用运维命令


    压测

    1. 压测的基准是超出正常流量的2~3倍之间,预留空间应对突发流量

    2. 压测方式

      • 通过Jmeter写代码方式,集成RocketMQ客户端
      • 通过RocketMQ自带的压测脚本
    3. 压测脚本producer.sh

      名称含义
      -h使用帮助
      -k测试时消息是否有 key,默认 false
      -nNameServer 地址
      -s消息大小,默认为 128 个字节
      -t主题名称
      -w并发线程的数量,默认 64 个
    4. 可根据实际情况设计自己的压测场景

    5. 压测场景一:1 个线程、消息大小为 1K、主题为4个队列。以下结果中发送最大 TPS 为 156,最大 RT 为 1313,平均 RT 为6.390

      $ cd ./benchmark
      $ sh producer.sh -t load-test -w 1 -s 1024 -n rocketmq-nameserver1:9876;rocketmq-nameserver2:9876
      Send TPS: 39 Max RT(ms): 1313 Average RT(ms):  26.475 Send Failed: 0 Response Failed: 0
      Send TPS: 47 Max RT(ms): 1313 Average RT(ms):  21.242 Send Failed: 0 Response Failed: 0
      Send TPS: 79 Max RT(ms): 1313 Average RT(ms):  12.469 Send Failed: 0 Response Failed: 0
      Send TPS: 137 Max RT(ms): 1313 Average RT(ms):   7.205 Send Failed: 0 Response Failed: 0
      Send TPS: 144 Max RT(ms): 1313 Average RT(ms):   6.882 Send Failed: 0 Response Failed: 0
      Send TPS: 156 Max RT(ms): 1313 Average RT(ms):   6.390 Send Failed: 0 Response Failed: 0
      ...省略...
      
      • 1
      • 2
      • 3
      • 4
      • 5
      • 6
      • 7
      • 8
      • 9

    集群

    1. 集群列表:查看集群各个节点的运行情况

      $ mqadmin clusterList -n rocketmq-nameserver1:9876
      #Cluster Name     #Broker Name     #BID  #Addr            #Version #InTPS(LOAD) #OutTPS(LOAD) #PCWait(ms) #Hour #SPACE
      DefaultCluster    rocketmq-master1 0     172.19.0.4:10911 V4_9_4   95.53(0,0ms)   0.00(0,0ms)          0  0.83 0.9400
      DefaultCluster    rocketmq-master1 1     172.19.0.6:10911 V4_9_4   96.71(0,0ms)   0.00(0,0ms)          0  0.83 0.9400
      DefaultCluster    rocketmq-master2 0     172.19.0.5:10911 V4_9_4   95.86(0,0ms)   0.00(0,0ms)          0  0.83 0.9400
      DefaultCluster    rocketmq-master2 1     172.19.0.7:10911 V4_9_4   95.95(0,0ms)   0.00(0,0ms)          0  0.83 0.9400
      
      -n	Nameserver 地址
      Cluster Name	集群名称
      Broker Name	节点 Broker 名称
      BID	Broker ID (0 为主节点,从节点非 0 表示)
      Addr	节点地址(ip:port)
      Version	RocketMQ 的版本号
      InTPS	节点每秒写入的消息数量
      OutTPS	节点每秒读出的消息数量
      PCWait	pageCacheLockTimeMills(消息落盘会加锁,当前时间与最后一次加锁的差值)
      Hour	磁盘存储多久的有效消息(当前时间与磁盘存储最早的一条消息时间戳的差值)
      SPACE	磁盘已使用的占比
      
      • 1
      • 2
      • 3
      • 4
      • 5
      • 6
      • 7
      • 8
      • 9
      • 10
      • 11
      • 12
      • 13
      • 14
      • 15
      • 16
      • 17
      • 18
    2. 集群中所有主题/消费组的实时吞吐情况

      $ mqadmin statsAll -n rocketmq-nameserver1:9876
      #Topic                     #Consumer Group  #Accumulation  #InTPS #OutTPS #InMsg24Hour  #OutMsg24Hour
      SCHEDULE_TOPIC_XXXX                                    0    0.00                    0    NO_CONSUMER
      RMQ_SYS_TRANS_HALF_TOPIC                               0    0.00                    0    NO_CONSUMER
      RMQ_SYS_TRACE_TOPIC                                    0    0.00                    0    NO_CONSUMER
      rocketmq-master1                                       0    0.00                    0    NO_CONSUMER
      DefaultCluster_REPLY_TOPIC                             0    0.00                    0    NO_CONSUMER
      rocketmq-master2                                       0    0.00                    0    NO_CONSUMER
      BenchmarkTest                                          0    0.00                    0    NO_CONSUMER
      OFFSET_MOVED_EVENT                                     0    0.00                    0    NO_CONSUMER
      load-test                                              0  200.90               578781    NO_CONSUMER
      TBW102                                                 0    0.00                    0    NO_CONSUMER
      SELF_TEST_TOPIC                                        0    0.00                    0    NO_CONSUMER
      DefaultCluster                                         0    0.00                    0    NO_CONSUMER
      
      -n	Nameserver 地址
      -a	只打印活动的主题
      -t	只打印指定的主题
      Topic	主题名称
      Consumer Group	消费组名称
      Accumulation	消息堆积数量
      InTPS	该主题每秒写入的消息数量
      OutTPS	该消费组每秒消费的消息数量
      InMsg24Hour	该主题 24 小时写入的消息总数
      OutMsg24Hour	该消费组 24 小时消费的消息总数
      
      • 1
      • 2
      • 3
      • 4
      • 5
      • 6
      • 7
      • 8
      • 9
      • 10
      • 11
      • 12
      • 13
      • 14
      • 15
      • 16
      • 17
      • 18
      • 19
      • 20
      • 21
      • 22
      • 23
      • 24
      • 25

    Broker

    1. 查看某个Broker的运行状态

      $ mqadmin brokerStatus -b 172.19.0.5:10911 -n  rocketmq-nameserver1:9876
      
      # END_TRANSACTION 的线程池请求数
      EndTransactionQueueSize         : 0
      # END_TRANSACTION 线程池大小,默认 100000
      EndTransactionThreadPoolQueueCapacity: 100000
      # Broker 启动时间
      bootTimestamp                   : 1660531134035
      # Broker 版本
      brokerVersion                   : 401
      # Broker 版本描述
      brokerVersionDesc               : V4_9_4
      # commitLog 目录磁盘使用情况
      commitLogDirCapacity            : Total : 465.7 GiB, Free : 24.4 GiB.
      # commitLog 目录磁盘使用百分比
      commitLogDiskRatio              : 0.95
      commitLogDiskRatio_/usr/local/apache-rocketmq/data/store/commitlog: 0.95
      # commitLog 最大偏移量
      commitLogMaxOffset              : 1599304708
      # commitLog 最小偏移量
      commitLogMinOffset              : 0
      consumeQueueDiskRatio           : 0.95
      # 已在 commit log 中存储未转发到 consume queue 的数据(单位字节)
      dispatchBehindBytes             : 0
      # 可忽略未被使用
      dispatchMaxBuffer               : 0
      # 存储最早消息的时间戳
      earliestMessageTimeStamp        : 1660531324537
      # 拉取时被找到的消息 Tps 统计,分别表示前 10s、1 分钟、10 分钟平均 Tps
      getFoundTps                     : 0.0 0.0 0.0
      # 查找单条消息的最大耗时
      getMessageEntireTimeMax         : 1
      # 拉取时未被找到的消息 Tps 统计,分别表示前 10s、1 分钟、10 分钟平均 Tps
      getMissTps                      : 0.0 0.03335445782328808 0.03320709104222116
      # 拉取时总的消息 Tps 统计,分别表示前 10s、1 分钟、10 分钟平均 Tps
      getTotalTps                     : 0.0 0.03335445782328808 0.03320709104222116
      # 向拉取方传输消息 Tps 统计,分别表示前 10s、1 分钟、10 分钟平均 Tps
      getTransferedTps                : 0.0 0.0 0.0
      # 截止今天凌晨 12 点从该 broker 拉取的消息总数
      msgGetTotalTodayMorning         : 0
      # 截止当前时间从该 broker 拉取的消息总数
      msgGetTotalTodayNow             : 0
      # 截止昨天凌晨 12 点从该 broker 拉取的消息总数
      msgGetTotalYesterdayMorning     : 0
      # 截止今天凌晨 12 点从该 broker 写入的消息总数
      msgPutTotalTodayMorning         : 0
      # 截止当前时间从该 broker 写入的消息总数
      msgPutTotalTodayNow             : 1346216
      # 截止昨天凌晨 12 点从该 broker 写入的消息总数
      msgPutTotalYesterdayMorning     : 0
      # 消息存储时会加锁,指从加锁现在的时间
      pageCacheLockTimeMills          : 0
      # 拉取线程池队列初始容量,默认为 100000
      pullThreadPoolQueueCapacity     : 100000
      # 队列头部第一个任务从创建到现在一直未被执行的时间,即:队列第一个任务等待时间
      pullThreadPoolQueueHeadWaitTimeMills: 0
      # 拉取线程池队列当前任务数量
      pullThreadPoolQueueSize         : 0
      putLatency99                    : 15.75
      putLatency999                   : 156.67
      # 写入消息的平均大小
      putMessageAverageSize           : 1188.0
      # 消息存储的耗时分布情况。例如:[<=0ms]:11 指存储时小于等于 0ms 的有 11 条消息
      putMessageDistributeTime        : [<=0ms]:8 [0~10ms]:5275 [10~50ms]:45 [50~100ms]:11 [100~200ms]:26 [200~500ms]:3 [500ms~1s]:0 [1~2s]:0 [2~3s]:0 [3~4s]:0 [4~5s]:0 [5~10s]:0 [10s~]:0
      # 消息存储的最大耗时
      putMessageEntireTimeMax         : 2976
      # 
      putMessageFailedTimes           : 0
      # 存储消息的总大小
      putMessageSizeTotal             : 1599304608
      # 存储消息的总条数
      putMessageTimesTotal            : 1346216
      # 统计 10 秒、1 分钟、10 分钟写入平均 Tps
      putTps                          : 83.1584207896052 97.32830792835462 101.69339560769806
      # 查询线程池队列初始容量,默认为 20000
      queryThreadPoolQueueCapacity    : 20000
      # 队列头部第一个任务从创建到现在一直未被执行的时间,即:队列第一个任务等待时间
      queryThreadPoolQueueHeadWaitTimeMills: 0
      # 查询线程池队列当前任务数量
      queryThreadPoolQueueSize        : 0
      # 剩余多少数据未被刷到磁盘
      remainHowManyDataToFlush        : 0 B
      # 堆外可用缓存区数量,初始大小为 5,每个大小 1G,为在开启队外内存传输时有效
      remainTransientStoreBufferNumbs : 2147483647
      # 该 broker 运行了多久了
      runtime                         : [ 0 days, 3 hours, 1 minutes, 11 seconds ]
      # 发送线程池队列初始容量,默认为 10000
      sendThreadPoolQueueCapacity     : 10000
      # 队列头部第一个任务从创建到现在一直未被执行的时间,即:队列第一个任务等待时间
      sendThreadPoolQueueHeadWaitTimeMills: 0
      # 发送线程池队列当前任务数量
      sendThreadPoolQueueSize         : 0
      # 可以配置在指定的时间 broker 接受客户端发送请求,默认启动后则接受发送请求
      startAcceptSendRequestTimeStamp : 0
      
      • 1
      • 2
      • 3
      • 4
      • 5
      • 6
      • 7
      • 8
      • 9
      • 10
      • 11
      • 12
      • 13
      • 14
      • 15
      • 16
      • 17
      • 18
      • 19
      • 20
      • 21
      • 22
      • 23
      • 24
      • 25
      • 26
      • 27
      • 28
      • 29
      • 30
      • 31
      • 32
      • 33
      • 34
      • 35
      • 36
      • 37
      • 38
      • 39
      • 40
      • 41
      • 42
      • 43
      • 44
      • 45
      • 46
      • 47
      • 48
      • 49
      • 50
      • 51
      • 52
      • 53
      • 54
      • 55
      • 56
      • 57
      • 58
      • 59
      • 60
      • 61
      • 62
      • 63
      • 64
      • 65
      • 66
      • 67
      • 68
      • 69
      • 70
      • 71
      • 72
      • 73
      • 74
      • 75
      • 76
      • 77
      • 78
      • 79
      • 80
      • 81
      • 82
      • 83
      • 84
      • 85
      • 86
      • 87
      • 88
      • 89
      • 90
      • 91
      • 92
      • 93
      • 94
    2. Broker配置信息

      $ mqadmin getBrokerConfig -b 172.19.0.5:10911 -n rocketmq-nameserver1:9876
      
      ============172.19.0.5:10911============
      serverSelectorThreads                             =  3
      brokerRole                                        =  SYNC_MASTER
      serverSocketRcvBufSize                            =  0
      writeBufferHighWaterMark                          =  0
      osPageCacheBusyTimeOutMills                       =  1000
      shortPollingTimeMills                             =  1000
      clientSocketRcvBufSize                            =  0
      clusterTopicEnable                                =  true
      brokerTopicEnable                                 =  true
      autoCreateTopicEnable                             =  true
      maxErrorRateOfBloomFilter                         =  20
      maxMsgsNumBatch                                   =  64
      cleanResourceInterval                             =  10000
      commercialBaseCount                               =  1
      enableScheduleAsyncDeliver                        =  false
      maxTransferCountOnMessageInMemory                 =  32
      brokerFastFailureEnable                           =  true
      brokerClusterName                                 =  DefaultCluster
      flushDiskType                                     =  SYNC_FLUSH
      commercialBigCount                                =  1
      mapedFileSizeCommitLog                            =  1073741824
      mappedFileSizeConsumeQueue                        =  6000000
      consumerFallbehindThreshold                       =  17179869184
      autoCreateSubscriptionGroup                       =  true
      transientStorePoolEnable                          =  false
      flushConsumerOffsetInterval                       =  5000
      waitTimeMillsInHeartbeatQueue                     =  31000
      checkTransactionMessageEnable                     =  false
      diskMaxUsedSpaceRatio                             =  99
      cleanFileForciblyEnable                           =  true
      slaveReadEnable                                   =  false
      flushCommitLogLeastPages                          =  4
      msgTraceTopicName                                 =  RMQ_SYS_TRACE_TOPIC
      expectConsumerNumUseFilter                        =  32
      enableDetailStat                                  =  true
      traceTopicEnable                                  =  true
      useEpollNativeSelector                            =  false
      enablePropertyFilter                              =  true
      messageDelayLevel                                 =  1s 5s 10s 30s 1m 2m 3m 4m 5m 6m 7m 8m 9m 10m 20m 30m 1h 2h
      deleteCommitLogFilesInterval                      =  100
      brokerName                                        =  rocketmq-master2
      maxTransferBytesOnMessageInDisk                   =  65536
      mapedFileSizeConsumeQueue                         =  50000000
      listenPort                                        =  10911
      flushConsumeQueueLeastPages                       =  2
      pullMessageThreadPoolNums                         =  128
      useReentrantLockWhenPutMessage                    =  true
      flushIntervalConsumeQueue                         =  1000
      sendThreadPoolQueueCapacity                       =  10000
      debugLockEnable                                   =  false
      haHousekeepingInterval                            =  20000
      diskFallRecorded                                  =  true
      messageIndexEnable                                =  true
      enableScheduleMessageStats                        =  true
      clientAsyncSemaphoreValue                         =  65535
      clientCallbackExecutorThreads                     =  3
      putMsgIndexHightWater                             =  600000
      sendMessageThreadPoolNums                         =  128
      clientManagerThreadPoolQueueCapacity              =  1000000
      serverSocketSndBufSize                            =  0
      maxDelayTime                                      =  40
      clientSocketSndBufSize                            =  0
      namesrvAddr                                       =  rocketmq-nameserver1:9876;rocketmq-nameserver2:9876
      commercialEnable                                  =  true
      maxHashSlotNum                                    =  5000000
      serverSocketBacklog                               =  1024
      heartbeatThreadPoolNums                           =  3
      transactionTimeOut                                =  6000
      maxMessageSize                                    =  65536
      adminBrokerThreadPoolNums                         =  16
      defaultQueryMaxNum                                =  32
      forceRegister                                     =  true
      maxTransferBytesOnMessageInMemory                 =  262144
      isolateLogEnable                                  =  false
      enableConsumeQueueExt                             =  false
      longPollingEnable                                 =  true
      serverWorkerThreads                               =  8
      messageIndexSafe                                  =  false
      deleteConsumeQueueFilesInterval                   =  100
      haSlaveFallbehindMax                              =  268435456
      serverCallbackExecutorThreads                     =  0
      flushCommitLogThoroughInterval                    =  10000
      storeCheckpoint                                   =  /usr/local/apache-rocketmq/data/store/checkpoint
      isEnableBatchPush                                 =  false
      commercialTimerCount                              =  1
      enableDLegerCommitLog                             =  false
      slaveTimeout                                      =  3000
      useTLS                                            =  false
      redeleteHangedFileInterval                        =  120000
      flushIntervalCommitLog                            =  500
      rocketmqHome                                      =  /usr/local/apache-rocketmq
      queryMessageThreadPoolNums                        =  11
      messageStorePlugIn                                =
      serverChannelMaxIdleTimeSeconds                   =  120
      maxIndexNum                                       =  20000000
      filterDataCleanTimeSpan                           =  86400000
      filterServerNums                                  =  0
      commitCommitLogLeastPages                         =  4
      waitTimeMillsInPullQueue                          =  5000
      haSendHeartbeatInterval                           =  5000
      processReplyMessageThreadPoolNums                 =  22
      clientChannelMaxIdleTimeSeconds                   =  120
      filterSupportRetry                                =  false
      flushDelayOffsetInterval                          =  10000
      duplicationEnable                                 =  false
      replyThreadPoolQueueCapacity                      =  10000
      writeBufferLowWaterMark                           =  0
      offsetCheckInSlave                                =  false
      clientCloseSocketIfTimeout                        =  true
      transientStorePoolSize                            =  5
      putThreadPoolQueueCapacity                        =  10000
      waitTimeMillsInSendQueue                          =  200
      warmMapedFileEnable                               =  false
      endTransactionThreadPoolNums                      =  14
      flushCommitLogTimed                               =  true
      flushLeastPagesWhenWarmMapedFile                  =  4096
      clientWorkerThreads                               =  4
      storePathConsumeQueue                             =  /usr/local/apache-rocketmq/data/store/consumequeue
      endTransactionPoolQueueCapacity                   =  100000
      registerNameServerPeriod                          =  30000
      registerBrokerTimeoutMills                        =  6000
      scheduleAsyncDeliverMaxResendNum2Blocked          =  3
      accessMessageInMemoryMaxRatio                     =  40
      enableLmq                                         =  false
      highSpeedMode                                     =  false
      transactionCheckMax                               =  15
      maxLmqConsumeQueueNum                             =  20000
      checkCRCOnRecover                                 =  true
      destroyMapedFileIntervalForcibly                  =  120000
      brokerIP2                                         =  172.19.0.5
      brokerIP1                                         =  172.19.0.5
      commitIntervalCommitLog                           =  200
      clientOnewaySemaphoreValue                        =  65535
      storeReplyMessageEnable                           =  true
      traceOn                                           =  true
      clientManageThreadPoolNums                        =  32
      putMessageFutureThreadPoolNums                    =  3
      channelNotActiveInterval                          =  60000
      mappedFileSizeConsumeQueueExt                     =  50331648
      consumerManagerThreadPoolQueueCapacity            =  1000000
      serverOnewaySemaphoreValue                        =  256
      haListenPort                                      =  10912
      enableCalcFilterBitMap                            =  false
      clientPooledByteBufAllocatorEnable                =  false
      aclEnable                                         =  false
      syncFlushTimeout                                  =  5000
      storePathRootDir                                  =  /usr/local/apache-rocketmq/data/store
      rejectTransactionMessage                          =  false
      commitCommitLogThoroughInterval                   =  200
      connectTimeoutMillis                              =  3000
      regionId                                          =  DefaultRegion
      queryThreadPoolQueueCapacity                      =  20000
      consumerManageThreadPoolNums                      =  32
      disableConsumeIfConsumerReadSlowly                =  false
      flushConsumerOffsetHistoryInterval                =  60000
      fetchNamesrvAddrByAddressServer                   =  false
      storePathCommitLog                                =  /usr/local/apache-rocketmq/data/store/commitlog
      compressedRegister                                =  false
      haTransferBatchSize                               =  32768
      commercialTransCount                              =  1
      transactionCheckInterval                          =  60000
      mappedFileSizeCommitLog                           =  1073741824
      startAcceptSendRequestTimeStamp                   =  0
      serverPooledByteBufAllocatorEnable                =  true
      serverAsyncSemaphoreValue                         =  64
      scheduleAsyncDeliverMaxPendingLimit               =  2000
      heartbeatThreadPoolQueueCapacity                  =  50000
      waitTimeMillsInTransactionQueue                   =  3000
      autoDeleteUnusedStats                             =  false
      deleteWhen                                        =  04
      abortFile                                         =  /usr/local/apache-rocketmq/data/store/abortlog
      bitMapLengthConsumeQueueExt                       =  112
      fastFailIfNoBufferInStorePool                     =  false
      defaultTopicQueueNums                             =  4
      enableMultiDispatch                               =  false
      notifyConsumerIdsChangedEnable                    =  true
      flushConsumeQueueThoroughInterval                 =  60000
      brokerPermission                                  =  6
      fileReservedTime                                  =  48
      storePathIndex                                    =  /usr/local/apache-rocketmq/data/store/indexlog
      transferMsgByHeap                                 =  true
      pullThreadPoolQueueCapacity                       =  100000
      brokerId                                          =  0
      maxTransferCountOnMessageInDisk                   =  8
      
      • 1
      • 2
      • 3
      • 4
      • 5
      • 6
      • 7
      • 8
      • 9
      • 10
      • 11
      • 12
      • 13
      • 14
      • 15
      • 16
      • 17
      • 18
      • 19
      • 20
      • 21
      • 22
      • 23
      • 24
      • 25
      • 26
      • 27
      • 28
      • 29
      • 30
      • 31
      • 32
      • 33
      • 34
      • 35
      • 36
      • 37
      • 38
      • 39
      • 40
      • 41
      • 42
      • 43
      • 44
      • 45
      • 46
      • 47
      • 48
      • 49
      • 50
      • 51
      • 52
      • 53
      • 54
      • 55
      • 56
      • 57
      • 58
      • 59
      • 60
      • 61
      • 62
      • 63
      • 64
      • 65
      • 66
      • 67
      • 68
      • 69
      • 70
      • 71
      • 72
      • 73
      • 74
      • 75
      • 76
      • 77
      • 78
      • 79
      • 80
      • 81
      • 82
      • 83
      • 84
      • 85
      • 86
      • 87
      • 88
      • 89
      • 90
      • 91
      • 92
      • 93
      • 94
      • 95
      • 96
      • 97
      • 98
      • 99
      • 100
      • 101
      • 102
      • 103
      • 104
      • 105
      • 106
      • 107
      • 108
      • 109
      • 110
      • 111
      • 112
      • 113
      • 114
      • 115
      • 116
      • 117
      • 118
      • 119
      • 120
      • 121
      • 122
      • 123
      • 124
      • 125
      • 126
      • 127
      • 128
      • 129
      • 130
      • 131
      • 132
      • 133
      • 134
      • 135
      • 136
      • 137
      • 138
      • 139
      • 140
      • 141
      • 142
      • 143
      • 144
      • 145
      • 146
      • 147
      • 148
      • 149
      • 150
      • 151
      • 152
      • 153
      • 154
      • 155
      • 156
      • 157
      • 158
      • 159
      • 160
      • 161
      • 162
      • 163
      • 164
      • 165
      • 166
      • 167
      • 168
      • 169
      • 170
      • 171
      • 172
      • 173
      • 174
      • 175
      • 176
      • 177
      • 178
      • 179
      • 180
      • 181
      • 182
      • 183
      • 184
      • 185
      • 186
      • 187
    3. 配置更新,对Broker配置进行热更新,不需要重启Broker节点

      -b	Broker 地址
      -n	NameServer 地址
      -k	需更新的配置的 key
      -v	需更新配置 key 对应的值
      $ mqadmin updateBrokerConfig -b 172.19.0.5:10911 -n rocketmq-nameserver1:9876 -k slaveReadEnable -v true
      
      • 1
      • 2
      • 3
      • 4
      • 5

    主题

    1. 列出集群所有主题

      $ mqadmin topicList -n rocketmq-nameserver1:9876
      SCHEDULE_TOPIC_XXXX
      RMQ_SYS_TRANS_HALF_TOPIC
      RMQ_SYS_TRACE_TOPIC
      rocketmq-master1
      DefaultCluster_REPLY_TOPIC
      rocketmq-master2
      BenchmarkTest
      OFFSET_MOVED_EVENT
      load-test
      TBW102
      SELF_TEST_TOPIC
      DefaultCluster
      
      • 1
      • 2
      • 3
      • 4
      • 5
      • 6
      • 7
      • 8
      • 9
      • 10
      • 11
      • 12
      • 13
    2. 创建主题,也可修改主题的配置(队列数量和权限)

      # 创建主题
      $ mqadmin updateTopic -n rocketmq-nameserver1:9876 -c DefaultCluster -t test1
      create topic to 172.19.0.5:10911 success.
      create topic to 172.19.0.4:10911 success.
      TopicConfig [topicName=test1, readQueueNums=8, writeQueueNums=8, perm=RW-, topicFilterType=SINGLE_TAG, topicSysFlag=0, order=false]
      
      -n	Nameserver 地址
      -c	集群名称
      -t	要创建的 Topic 名称
      topicName	主题名称
      readQueueNums	读队列数量
      writeQueueNums	写队列数量
      perm	主题权限 RW 表示该主题拥有读写权限
      topicFilterType	消息过滤类型
      topicSysFlag	主题系统标记
      order	是否有序主题
      
      • 1
      • 2
      • 3
      • 4
      • 5
      • 6
      • 7
      • 8
      • 9
      • 10
      • 11
      • 12
      • 13
      • 14
      • 15
      • 16
    3. 查看Topic路由信息

      -n	Nameserver 地址
      -t	主题名称
      
      
      $ mqadmin topicRoute -n rocketmq-nameserver1:9876  -t load-test
      brokerDatas	broker 信息地址、节点名称、所在集群
      queueDatas	队列数量、队列所在的 broker、权限等
      {
      	"brokerDatas":[
      		{
      			"brokerAddrs":{0:"172.19.0.4:10911",1:"172.19.0.6:10911"
      			},
      			"brokerName":"rocketmq-master1",
      			"cluster":"DefaultCluster"
      		},
      		{
      			"brokerAddrs":{0:"172.19.0.5:10911",1:"172.19.0.7:10911"
      			},
      			"brokerName":"rocketmq-master2",
      			"cluster":"DefaultCluster"
      		}
      	],
      	"filterServerTable":{},
      	"queueDatas":[
      		{
      			"brokerName":"rocketmq-master1",
      			"perm":6,
      			"readQueueNums":4,
      			"topicSysFlag":0,
      			"writeQueueNums":4
      		},
      		{
      			"brokerName":"rocketmq-master2",
      			"perm":6,
      			"readQueueNums":4,
      			"topicSysFlag":0,
      			"writeQueueNums":4
      		}
      	]
      }
      
      
      
      • 1
      • 2
      • 3
      • 4
      • 5
      • 6
      • 7
      • 8
      • 9
      • 10
      • 11
      • 12
      • 13
      • 14
      • 15
      • 16
      • 17
      • 18
      • 19
      • 20
      • 21
      • 22
      • 23
      • 24
      • 25
      • 26
      • 27
      • 28
      • 29
      • 30
      • 31
      • 32
      • 33
      • 34
      • 35
      • 36
      • 37
      • 38
      • 39
      • 40
      • 41
      • 42
    4. 查看主题状态情况

      -n	NameServer 地址
      -t	主题名称
      
      $ mqadmin topicStatus -n rocketmq-nameserver1:9876 -t load-test
      #Broker Name        #QID  #Min Offset #Max Offset  #Last Updated
      rocketmq-master1    0     0           96360        2022-08-15 11:44:51,638
      rocketmq-master1    1     0           96362        2022-08-15 11:44:51,642
      rocketmq-master1    2     0           96364        2022-08-15 11:44:51,648
      rocketmq-master1    3     0           96362        2022-08-15 11:44:51,616
      rocketmq-master2    0     0           96365        2022-08-15 11:44:51,740
      rocketmq-master2    1     0           96365        2022-08-15 11:44:51,745
      rocketmq-master2    2     0           96364        2022-08-15 11:44:51,705
      rocketmq-master2    3     0           96364        2022-08-15 11:44:51,710
      
      Broker Name	节点名称
      QID	Queue ID 队列编号
      Min Offset	该队列最小偏移量
      Max Offset	该队列最大偏移量
      Last Updated	最新写入消息的时间戳
      
      • 1
      • 2
      • 3
      • 4
      • 5
      • 6
      • 7
      • 8
      • 9
      • 10
      • 11
      • 12
      • 13
      • 14
      • 15
      • 16
      • 17
      • 18
      • 19
    5. 修改主题的权限:写权限用 2 表示、读权限用 4 表示、读写权限用 6 表示

      $ mqadmin updateTopicPerm -c DefaultCluster -t test1 -p 2 -n rocketmq-nameserver1:9876
      mqadmin updateTopicPerm -c DefaultCluster -t test1 -p 2 -n rocketmq-nameserver1:9876
      update topic perm from 6 to 2 in 172.19.0.5:10911 success.
      update topic perm from 6 to 2 in 172.19.0.4:10911 success.
      
      -c	集群名称
      -t	主题名称
      -p	权限(2:W,4:R,6:WR)
      -n	NameServer 地址
      
      • 1
      • 2
      • 3
      • 4
      • 5
      • 6
      • 7
      • 8
      • 9
    6. 删除主题

      -n	Nameserver 地址
      -t	主题名称
      -c	集群名称
      $ mqadmin deleteTopic -n rocketmq-nameserver1:9876 -t test1 -c DefaultCluster
      
      • 1
      • 2
      • 3
      • 4

    发送

    1. 发送测试消息,检测Broker运行情况

      -b	Broker 名称
      -n	NameServer 地址
      -c	指定发送消息数量,默认 50 条
      -s	指定发送消息体大小,默认 128k
      
      $ mqadmin  sendMsgStatus -b rocketmq-master1 -n rocketmq-nameserver1:9876
      
      • 1
      • 2
      • 3
      • 4
      • 5
      • 6

    消费

    1. 创建消费组

      -n	Nameserver 地址
      -c	集群名称
      -g	消费组名称
      $ mqadmin updateSubGroup -n rocketmq-nameserver1:9876 -c DefaultCluster -g testGroupA
      create subscription group to 172.19.0.5:10911 success.
      create subscription group to 172.19.0.4:10911 success.
      SubscriptionGroupConfig [groupName=testGroupA, consumeEnable=true, consumeFromMinEnable=false, consumeBroadcastEnable=false, retryQueueNums=1, retryMaxTimes=16, brokerId=0, whichBrokerWhenConsumeSlowly=1, notifyConsumerIdsChangedEnable=true]
      
      groupName	消费组名称
      consumeEnable	是否开启消费,默认开启
      consumeFromMinEnable	是否从最小位点消费,默认 false
      consumeBroadcastEnable	是否开启广播消费,默认 false
      retryQueueNums	重试队列数量,默认为 1
      retryMaxTimes	消费重试次数,默认 16 次
      brokerId	消费组所在的 brokerId
      whichBrokerWhenConsumeSlowly	当 Master 节点消费慢时,默认在从节点 ID 为 1 的 broker 消费
      
      • 1
      • 2
      • 3
      • 4
      • 5
      • 6
      • 7
      • 8
      • 9
      • 10
      • 11
      • 12
      • 13
      • 14
      • 15
      • 16
    2. 查看各个消费者的情况,包括版本、消费组名称等

      $ mqadmin consumerStatus -g testGroupA -n rocketmq-nameserver1:9876
      输出第一列	第几个消费者
      输出第二列	clientId
      输出第三列	该消费者使用的客户端 RocketMQ 版本
      输出第四列	文件路径(filePath),该文件记录了消费者详细信息
      
      • 1
      • 2
      • 3
      • 4
      • 5
    3. 查看消费组进度

      $ mqadmin consumerProgress -g testGroupA -n  rocketmq-nameserver1:98766
      Topic	订阅的主题
      Broker Name	订阅主题所在的 Broker
      QID	订阅主题的 Queue ID
      Broker Offset	该 Queue 存储的消息偏移量
      Consumer Offset	该 Queue 消费的消息偏移量
      Diff	消息堆积情况
      LastTime	上次消费消息的时间
      Consume TPS	每秒钟消费消息的数量
      Diff Total	消息堆积总数
      
      • 1
      • 2
      • 3
      • 4
      • 5
      • 6
      • 7
      • 8
      • 9
      • 10

    检索

    1. 打印主题中的消息

      -d	是否打印消息体,默认 false
      -n	NameServer 地址
      -t	主题名称
      -b	开始时间戳,格式为 currentTimeMillis|yyyy-MM-dd#HH:mm:ss:SSS
      -c	字符编码,默认 UTF-8
      -e	结束时间戳,格式为 currentTimeMillis|yyyy-MM-dd#HH:mm:ss:SSS
      -s	订阅的 tag,默认为全部(*),格式 TagA || TagB
      $ mqadmin printMsg -d true -n rocketmq-nameserver1:9876 -t rocketmq-master1
      
      • 1
      • 2
      • 3
      • 4
      • 5
      • 6
      • 7
      • 8
    2. 通过 MsgId 检索消息

      -n	NameServer 地址
      -i	消息 ID
      
      $ mqadmin queryMsgById -n rocketmq-nameserver1:9876 -i AC13000400002A9F0000000065CE865C
      OffsetID:            AC13000400002A9F0000000065CE865C
      # Topic	主题名称
      Topic:               rocketmq-master1
      # Tags	消息的 TAG
      Tags:                [null]
      # Keys	发送消息的 key
      Keys:                [null]
      # 消息存储的 Queue
      Queue ID:            0
      # 消息在 Queue 中的偏移量
      Queue Offset:        50
      # 消息在 commitLog 文件中的偏移量
      CommitLog Offset:    1708033628
      # 重新消费的次数
      Reconsume Times:     0
      # 消息诞生的时间戳
      Born Timestamp:      2022-08-15 13:55:00,318
      # 消息存储的时间戳
      Store Timestamp:     2022-08-15 13:55:00,326
      # 发送消息的 IP 地址
      Born Host:           172.19.0.4:42886
      # 消息存储的 IP 地址
      Store Host:          172.19.0.4:10911
      # 标志信息
      System Flag:         0
      # 属性信息
      Properties:          {UNIQ_KEY=7F00000103BA28A418FC4B15805E0032, CLUSTER=DefaultCluster}
      # 消息体存储路径
      Message Body Path:   /tmp/rocketmq/msgbodys/7F00000103BA28A418FC4B15805E0032
      
      
      • 1
      • 2
      • 3
      • 4
      • 5
      • 6
      • 7
      • 8
      • 9
      • 10
      • 11
      • 12
      • 13
      • 14
      • 15
      • 16
      • 17
      • 18
      • 19
      • 20
      • 21
      • 22
      • 23
      • 24
      • 25
      • 26
      • 27
      • 28
      • 29
      • 30
      • 31
      • 32
      • 33
      • 34
    3. 通过Key检索消息

      -n	NameServer 地址
      -t	主题名称
      -k	消息 key
      
      $ mqadmin queryMsgByKey -n rocketmq-nameserver1:9876  -t rocketmq-master1 -k 7F00000103BA28A418FC4B15805E0032
      Message ID	消息 ID
      QID	消息存储的 Queue
      Offset	消息在 Queue 的偏移量
      
      $ mqadmin queryMsgByUniqueKey -n rocketmq-nameserver1:9876  -t rocketmq-master1 -i 7F00000103BA28A418FC4B157E9A0021
      Topic:               rocketmq-master1
      Tags:                [null]
      Keys:                [null]
      Queue ID:            0
      Queue Offset:        33
      CommitLog Offset:    1707980957
      Reconsume Times:     0
      Born Timestamp:      2022-08-15 13:54:59,866
      Store Timestamp:     2022-08-15 13:54:59,871
      Born Host:           172.19.0.4:42886
      Store Host:          172.19.0.4:10911
      System Flag:         0
      Properties:          {UNIQ_KEY=7F00000103BA28A418FC4B157E9A0021, CLUSTER=DefaultCluster}
      Message Body Path:   /tmp/rocketmq/msgbodys/7F00000103BA28A418FC4B157E9A0021
      
      OffsetID	消息 ID
      Topic	主题名称
      Tags	消息的 TAG
      Keys	消息 KEY
      Queue ID	消息存储的 Queue
      Queue Offset	消息在 Queue 中的偏移量
      CommitLog Offset	消息在 commitLog 文件中的偏移量
      Reconsume Times	重新消费的次数
      Born Timestamp	消息诞生的时间戳
      Store Timestamp	消息存储的时间戳
      Born Host	发送消息的 IP 地址
      System Flag	标志信息
      Properties	属性信息
      Message Body Path	消息体存储路径
      MessageTrack	消费情况
      
      • 1
      • 2
      • 3
      • 4
      • 5
      • 6
      • 7
      • 8
      • 9
      • 10
      • 11
      • 12
      • 13
      • 14
      • 15
      • 16
      • 17
      • 18
      • 19
      • 20
      • 21
      • 22
      • 23
      • 24
      • 25
      • 26
      • 27
      • 28
      • 29
      • 30
      • 31
      • 32
      • 33
      • 34
      • 35
      • 36
      • 37
      • 38
      • 39
      • 40
    4. 通过Offset 检索消息

      -n	NameServer 地址
      -t	主题
      -b	Broker 名字
      -i	Queue ID
      -o	偏移量 offset
      
      $ mqadmin queryMsgByOffset -n rocketmq-nameserver1:9876 -t rocketmq-master1 -b rocketmq-master1 -i 2 -o 0
      OffsetID	消息 ID
      Topic	主题名称
      Tags	消息的 TAG
      Keys	消息 KEY
      Queue ID	消息存储的 Queue
      Queue Offset	消息在 Queue 中的偏移量
      CommitLog Offset	消息在 commitLog 文件中的偏移量
      Reconsume Times	重新消费的次数
      Born Timestamp	消息诞生的时间戳
      Store Timestamp	消息存储的时间戳
      Born Host	发送消息的 IP 地址
      System Flag	标志信息
      Properties	属性信息
      Message Body Path	消息体存储路径
      MessageTrack	消费情况
      
      • 1
      • 2
      • 3
      • 4
      • 5
      • 6
      • 7
      • 8
      • 9
      • 10
      • 11
      • 12
      • 13
      • 14
      • 15
      • 16
      • 17
      • 18
      • 19
      • 20
      • 21
      • 22
  • 相关阅读:
    Python大作业——爬虫+可视化+数据分析+数据库(可视化篇)
    配置路由器支持Telnet操作 计网实验
    html文件使用postcss-pxtorem适配移动端 && 使用tailwindcss库
    STL:vector容器详解
    完美解决docker skywalking报错:no provider found for module storage
    Linux 进程层次分析
    3D制图教程
    3D全景视角,足不出户感知真实场景的魅力
    Pohlig-Hellman算法解决DLP问题
    Clickhouse—聚合函数组合
  • 原文地址:https://blog.csdn.net/usagoole/article/details/126355168