# 運維管理
---
### 1 集群搭建
#### 1.1 單Master模式
這種方式風險較大,一旦Broker重啟或者宕機時,會導致整個服務不可用。不建議線上環境使用,可以用於本地測試。
##### 1)啟動 NameServer
```bash
### 首先啟動Name Server
$ nohup sh mqnamesrv &
### 驗證Name Server 是否啟動成功
$ tail -f ~/logs/rocketmqlogs/namesrv.log
The Name Server boot success...
```
##### 2)啟動 Broker
```bash
### 啟動Broker
$ nohup sh bin/mqbroker -n localhost:9876 &
### 驗證Name Server 是否啟動成功,例如Broker的IP為:192.168.1.2,且名稱為broker-a
$ tail -f ~/logs/rocketmqlogs/Broker.log
The broker[broker-a, 192.169.1.2:10911] boot success...
```
#### 1.2 多Master模式
一個集群無Slave,全是Master,例如2個Master或者3個Master,這種模式的優缺點如下:
- 優點:配置簡單,單個Master宕機或重啟維護對應用無影響,在磁盤配置為RAID10時,即使機器宕機不可恢復情況下,由於RAID10磁盤非常可靠,消息也不會丟(異步刷盤丟失少量消息,同步刷盤一條不丟),性能最高;
- 缺點:單台機器宕機期間,這台機器上未被消費的消息在機器恢復之前不可訂閱,消息實時性會受到影響。
##### 1)啟動NameServer
NameServer需要先於Broker啟動,且如果在生產環境使用,為了保證高可用,建議一般規模的集群啟動3個NameServer,各節點的啟動命令相同,如下:
```bash
### 首先啟動Name Server
$ nohup sh mqnamesrv &
### 驗證Name Server 是否啟動成功
$ tail -f ~/logs/rocketmqlogs/namesrv.log
The Name Server boot success...
```
##### 2)啟動Broker集群
```bash
### 在機器A,啟動第一個Master,例如NameServer的IP為:192.168.1.1
$ nohup sh mqbroker -n 192.168.1.1:9876 -c $ROCKETMQ_HOME/conf/2m-noslave/broker-a.properties &
### 在機器B,啟動第二個Master,例如NameServer的IP為:192.168.1.1
$ nohup sh mqbroker -n 192.168.1.1:9876 -c $ROCKETMQ_HOME/conf/2m-noslave/broker-b.properties &
...
```
如上啟動命令是在單個NameServer情況下使用的。對於多個NameServer的集群,Broker啟動命令中`-n`后面的地址列表用分號隔開即可,例如 `192.168.1.1:9876;192.161.2:9876`。
#### 1.3 多Master多Slave模式-異步復制
每個Master配置一個Slave,有多對Master-Slave,HA采用異步復制方式,主備有短暫消息延遲(毫秒級),這種模式的優缺點如下:
- 優點:即使磁盤損壞,消息丟失的非常少,且消息實時性不會受影響,同時Master宕機后,消費者仍然可以從Slave消費,而且此過程對應用透明,不需要人工干預,性能同多Master模式幾乎一樣;
- 缺點:Master宕機,磁盤損壞情況下會丟失少量消息。
##### 1)啟動NameServer
```bash
### 首先啟動Name Server
$ nohup sh mqnamesrv &
### 驗證Name Server 是否啟動成功
$ tail -f ~/logs/rocketmqlogs/namesrv.log
The Name Server boot success...
```
##### 2)啟動Broker集群
```bash
### 在機器A,啟動第一個Master,例如NameServer的IP為:192.168.1.1
$ nohup sh mqbroker -n 192.168.1.1:9876 -c $ROCKETMQ_HOME/conf/2m-2s-async/broker-a.properties &
### 在機器B,啟動第二個Master,例如NameServer的IP為:192.168.1.1
$ nohup sh mqbroker -n 192.168.1.1:9876 -c $ROCKETMQ_HOME/conf/2m-2s-async/broker-b.properties &
### 在機器C,啟動第一個Slave,例如NameServer的IP為:192.168.1.1
$ nohup sh mqbroker -n 192.168.1.1:9876 -c $ROCKETMQ_HOME/conf/2m-2s-async/broker-a-s.properties &
### 在機器D,啟動第二個Slave,例如NameServer的IP為:192.168.1.1
$ nohup sh mqbroker -n 192.168.1.1:9876 -c $ROCKETMQ_HOME/conf/2m-2s-async/broker-b-s.properties &
```
#### 1.4 多Master多Slave模式-同步雙寫
每個Master配置一個Slave,有多對Master-Slave,HA采用同步雙寫方式,即只有主備都寫成功,才向應用返回成功,這種模式的優缺點如下:
- 優點:數據與服務都無單點故障,Master宕機情況下,消息無延遲,服務可用性與數據可用性都非常高;
- 缺點:性能比異步復制模式略低(大約低10%左右),發送單個消息的RT會略高,且目前版本在主節點宕機后,備機不能自動切換為主機。
##### 1)啟動NameServer
```bash
### 首先啟動Name Server
$ nohup sh mqnamesrv &
### 驗證Name Server 是否啟動成功
$ tail -f ~/logs/rocketmqlogs/namesrv.log
The Name Server boot success...
```
##### 2)啟動Broker集群
```bash
### 在機器A,啟動第一個Master,例如NameServer的IP為:192.168.1.1
$ nohup sh mqbroker -n 192.168.1.1:9876 -c $ROCKETMQ_HOME/conf/2m-2s-sync/broker-a.properties &
### 在機器B,啟動第二個Master,例如NameServer的IP為:192.168.1.1
$ nohup sh mqbroker -n 192.168.1.1:9876 -c $ROCKETMQ_HOME/conf/2m-2s-sync/broker-b.properties &
### 在機器C,啟動第一個Slave,例如NameServer的IP為:192.168.1.1
$ nohup sh mqbroker -n 192.168.1.1:9876 -c $ROCKETMQ_HOME/conf/2m-2s-sync/broker-a-s.properties &
### 在機器D,啟動第二個Slave,例如NameServer的IP為:192.168.1.1
$ nohup sh mqbroker -n 192.168.1.1:9876 -c $ROCKETMQ_HOME/conf/2m-2s-sync/broker-b-s.properties &
```
以上Broker與Slave配對是通過指定相同的BrokerName參數來配對,Master的BrokerId必須是0,Slave的BrokerId必須是大於0的數。另外一個Master下面可以掛載多個Slave,同一Master下的多個Slave通過指定不同的BrokerId來區分。$ROCKETMQ_HOME指的RocketMQ安裝目錄,需要用戶自己設置此環境變量。
### 2 mqadmin管理工具
> 注意:
>
> 1. 執行命令方法:`./mqadmin {command} {args}`
> 2. 幾乎所有命令都需要配置-n表示NameServer地址,格式為ip:port
> 3. 幾乎所有命令都可以通過-h獲取幫助
> 4. 如果既有Broker地址(-b)配置項又有clusterName(-c)配置項,則優先以Broker地址執行命令,如果不配置Broker地址,則對集群中所有主機執行命令,只支持一個Broker地址。-b格式為ip:port,port默認是10911
> 5. 在tools下可以看到很多命令,但並不是所有命令都能使用,只有在MQAdminStartup中初始化的命令才能使用,你也可以修改這個類,增加或自定義命令
> 6. 由於版本更新問題,少部分命令可能未及時更新,遇到錯誤請直接閱讀相關命令源碼
#### 2.1 Topic相關
<table border=0 cellpadding=0 cellspacing=0 width=714>
<col width=177>
<col width=175>
<col width=177>
<col width=185>
<tr height=23 style='height:17.0pt'>
<td height=23 class="xl63" width=177 style='height:17.0pt;width:133pt'>名稱</td>
<td class="xl64" width=175 style='width:131pt'>含義</td>
<td class="xl64" width=177 style='width:133pt'>命令選項</td>
<td class="xl64" width=185 style='width:139pt'>說明</td>
</tr>
<tr height=132 style='height:99.0pt'>
<td rowspan=8 height=593 class="xl68" width=163 style='border-bottom:1.0pt;
height:444.0pt;border-top:none;width:122pt'>updateTopic</td>
<td rowspan=8 class="xl70" width=135 style='border-bottom:1.0pt;
border-top:none;width:101pt'>創建更新Topic配置</td>
<td class="xl65" width=149 style='width:112pt'>-b</td>
<td class="xl66" width=159 style='width:119pt'>Broker 地址,表示 topic 所在
Broker,只支持單台Broker,地址為ip:port</td>
</tr>
<tr height=132 style='height:99.0pt'>
<td height=132 class="xl65" width=149 style='height:99.0pt;width:112pt'>-c</td>
<td class="xl66" width=159 style='width:119pt'>cluster 名稱,表示 topic 所在集群(集群可通過
clusterList 查詢)</td>
</tr>
<tr height=23 style='height:17.0pt'>
<td height=23 class="xl65" width=149 style='height:17.0pt;width:112pt'>-h-</td>
<td class="xl66" width=159 style='width:119pt'>打印幫助</td>
</tr>
<tr height=57 style='height:43.0pt'>
<td height=57 class="xl65" width=149 style='height:43.0pt;width:112pt'>-n</td>
<td class="xl66" width=159 style='width:119pt'>NameServer服務地址,格式 ip:port</td>
</tr>
<tr height=76 style='height:57.0pt'>
<td height=76 class="xl65" width=149 style='height:57.0pt;width:112pt'>-p</td>
<td class="xl66" width=159 style='width:119pt'>指定新topic的讀寫權限( W=2|R=4|WR=6 )</td>
</tr>
<tr height=39 style='height:29.0pt'>
<td height=39 class="xl65" width=149 style='height:29.0pt;width:112pt'>-r</td>
<td class="xl66" width=159 style='width:119pt'>可讀隊列數(默認為 8)</td>
</tr>
<tr height=39 style='height:29.0pt'>
<td height=39 class="xl65" width=149 style='height:29.0pt;width:112pt'>-w</td>
<td class="xl66" width=159 style='width:119pt'>可寫隊列數(默認為 8)</td>
</tr>
<tr height=95 style='height:71.0pt'>
<td height=95 class="xl65" width=149 style='height:71.0pt;width:112pt'>-t</td>
<td class="xl66" width=159 style='width:119pt'>topic 名稱(名稱只能使用字符
^[a-zA-Z0-9_-]+$ )</td>
</tr>
<tr height=132 style='height:99.0pt'>
<td rowspan=4 height=307 class="xl68" width=163 style='border-bottom:1.0pt;
height:230.0pt;border-top:none;width:122pt'>deleteTopic</td>
<td rowspan=4 class="xl70" width=135 style='border-bottom:1.0pt;
border-top:none;width:101pt'>刪除Topic</td>
<td class="xl65" width=149 style='width:112pt'>-c</td>
<td class="xl66" width=159 style='width:119pt'>cluster 名稱,表示刪除某集群下的某個 topic (集群
可通過 clusterList 查詢)</td>
</tr>
<tr height=23 style='height:17.0pt'>
<td height=23 class="xl65" width=149 style='height:17.0pt;width:112pt'>-h</td>
<td class="xl66" width=159 style='width:119pt'>打印幫助</td>
</tr>
<tr height=57 style='height:43.0pt'>
<td height=57 class="xl65" width=149 style='height:43.0pt;width:112pt'>-n</td>
<td class="xl66" width=159 style='width:119pt'>NameServer 服務地址,格式 ip:port</td>
</tr>
<tr height=95 style='height:71.0pt'>
<td height=95 class="xl65" width=149 style='height:71.0pt;width:112pt'>-t</td>
<td class="xl66" width=159 style='width:119pt'>topic 名稱(名稱只能使用字符
^[a-zA-Z0-9_-]+$ )</td>
</tr>
<tr height=23 style='height:17.0pt'>
<td rowspan=3 height=287 class="xl68" width=163 style='border-bottom:1.0pt;
height:215.0pt;border-top:none;width:122pt'>topicList</td>
<td rowspan=3 class="xl70" width=135 style='border-bottom:1.0pt;
border-top:none;width:101pt'>查看 Topic 列表信息</td>
<td class="xl65" width=149 style='width:112pt'>-h</td>
<td class="xl66" width=159 style='width:119pt'>打印幫助</td>
</tr>
<tr height=207 style='height:155.0pt'>
<td height=207 class="xl65" width=149 style='height:155.0pt;width:112pt'>-c</td>
<td class="xl66" width=159 style='width:119pt'>不配置-c只返回topic列表,增加-c返回clusterName,
topic, consumerGroup信息,即topic的所屬集群和訂閱關系,沒有參數</td>
</tr>
<tr height=57 style='height:43.0pt'>
<td height=57 class="xl65" width=149 style='height:43.0pt;width:112pt'>-n</td>
<td class="xl66" width=159 style='width:119pt'>NameServer 服務地址,格式 ip:port</td>
</tr>
<tr height=23 style='height:17.0pt'>
<td rowspan=3 height=103 class="xl68" width=163 style='border-bottom:1.0pt;
height:77.0pt;border-top:none;width:122pt'>topicRoute</td>
<td rowspan=3 class="xl70" width=135 style='border-bottom:1.0pt;
border-top:none;width:101pt'>查看 Topic 路由信息</td>
<td class="xl65" width=149 style='width:112pt'>-t</td>
<td class="xl66" width=159 style='width:119pt'>topic 名稱</td>
</tr>
<tr height=23 style='height:17.0pt'>
<td height=23 class="xl65" width=149 style='height:17.0pt;width:112pt'>-h</td>
<td class="xl66" width=159 style='width:119pt'>打印幫助</td>
</tr>
<tr height=57 style='height:43.0pt'>
<td height=57 class="xl65" width=149 style='height:43.0pt;width:112pt'>-n</td>
<td class="xl66" width=159 style='width:119pt'>NameServer 服務地址,格式 ip:port</td>
</tr>
<tr height=23 style='height:17.0pt'>
<td rowspan=3 height=103 class="xl68" width=163 style='border-bottom:1.0pt;
height:77.0pt;border-top:none;width:122pt'>topicStatus</td>
<td rowspan=3 class="xl70" width=135 style='border-bottom:1.0pt;
border-top:none;width:101pt'>查看 Topic 消息隊列offset</td>
<td class="xl65" width=149 style='width:112pt'>-t</td>
<td class="xl66" width=159 style='width:119pt'>topic 名稱</td>
</tr>
<tr height=23 style='height:17.0pt'>
<td height=23 class="xl65" width=149 style='height:17.0pt;width:112pt'>-h</td>
<td class="xl66" width=159 style='width:119pt'>打印幫助</td>
</tr>
<tr height=57 style='height:43.0pt'>
<td height=57 class="xl65" width=149 style='height:43.0pt;width:112pt'>-n</td>
<td class="xl66" width=159 style='width:119pt'>NameServer 服務地址,格式 ip:port</td>
</tr>
<tr height=23 style='height:17.0pt'>
<td rowspan=3 height=103 class="xl68" width=163 style='border-bottom:1.0pt;
height:77.0pt;border-top:none;width:122pt'>topicClusterList</td>
<td rowspan=3 class="xl70" width=135 style='border-bottom:1.0pt;
border-top:none;width:101pt'>查看 Topic 所在集群列表</td>
<td class="xl65" width=149 style='width:112pt'>-t</td>
<td class="xl66" width=159 style='width:119pt'>topic 名稱</td>
</tr>
<tr height=23 style='height:17.0pt'>
<td height=23 class="xl65" width=149 style='height:17.0pt;width:112pt'>-h</td>
<td class="xl66" width=159 style='width:119pt'>打印幫助</td>
</tr>
<tr height=57 style='height:43.0pt'>
<td height=57 class="xl65" width=149 style='height:43.0pt;width:112pt'>-n</td>
<td class="xl66" width=159 style='width:119pt'>NameServer 服務地址,格式 ip:port</td>
</tr>
<tr height=23 style='height:17.0pt'>
<td rowspan=6 height=518 class="xl68" width=163 style='border-bottom:1.0pt;
height:380pt;border-top:none;width:122pt'>updateTopicPerm</td>
<td rowspan=6 class="xl70" width=135 style='border-bottom:1.0pt;
border-top:none;width:101pt'>更新 Topic 讀寫權限</td>
<td class="xl65" width=149 style='width:112pt'>-t</td>
<td class="xl66" width=159 style='width:119pt'>topic 名稱</td>
</tr>
<tr height=23 style='height:17.0pt'>
<td height=23 class="xl65" width=149 style='height:17.0pt;width:112pt'>-h</td>
<td class="xl66" width=159 style='width:119pt'>打印幫助</td>
</tr>
<tr height=57 style='height:43.0pt'>
<td height=57 class="xl65" width=149 style='height:43.0pt;width:112pt'>-n</td>
<td class="xl66" width=159 style='width:119pt'>NameServer 服務地址,格式 ip:port</td>
</tr>
<tr height=132 style='height:99.0pt'>
<td height=132 class="xl65" width=149 style='height:99.0pt;width:112pt'>-b</td>
<td class="xl66" width=159 style='width:119pt'>Broker 地址,表示 topic 所在
Broker,只支持單台Broker,地址為ip:port</td>
</tr>
<tr height=76 style='height:57.0pt'>
<td height=76 class="xl65" width=149 style='height:57.0pt;width:112pt'>-p</td>
<td class="xl66" width=159 style='width:119pt'>指定新 topic 的讀寫權限( W=2|R=4|WR=6 )</td>
</tr>
<tr height=207 style='height:155.0pt'>
<td height=207 class="xl65" width=149 style='height:155.0pt;width:112pt'>-c</td>
<td class="xl66" width=159 style='width:119pt'>cluster 名稱,表示 topic 所在集群(集群可通過
clusterList 查詢),-b優先,如果沒有-b,則對集群中所有Broker執行命令</td>
</tr>
<tr height=23 style='height:17.0pt'>
<td rowspan=5 height=199 class="xl68" width=163 style='border-bottom:1.0pt;
height:149.0pt;border-top:none;width:122pt'>updateOrderConf</td>
<td rowspan=5 class="xl70" width=135 style='border-bottom:1.0pt;
border-top:none;width:101pt'>從NameServer上創建、刪除、獲取特定命名空間的kv配置,目前還未啟用</td>
<td class="xl65" width=149 style='width:112pt'>-h</td>
<td class="xl66" width=159 style='width:119pt'>打印幫助</td>
</tr>
<tr height=57 style='height:43.0pt'>
<td height=57 class="xl65" width=149 style='height:43.0pt;width:112pt'>-n</td>
<td class="xl66" width=159 style='width:119pt'>NameServer 服務地址,格式 ip:port</td>
</tr>
<tr height=23 style='height:17.0pt'>
<td height=23 class="xl65" width=149 style='height:17.0pt;width:112pt'>-t</td>
<td class="xl66" width=159 style='width:119pt'>topic,鍵</td>
</tr>
<tr height=39 style='height:29.0pt'>
<td height=39 class="xl65" width=149 style='height:29.0pt;width:112pt'>-v</td>
<td class="xl66" width=159 style='width:119pt'>orderConf,值</td>
</tr>
<tr height=57 style='height:43.0pt'>
<td height=57 class="xl65" width=149 style='height:43.0pt;width:112pt'>-m</td>
<td class="xl66" width=159 style='width:119pt'>method,可選get、put、delete</td>
</tr>
<tr height=23 style='height:17.0pt'>
<td rowspan=4 height=198 class="xl68" width=163 style='border-bottom:1.0pt;
height:140pt;border-top:none;width:122pt'>allocateMQ</td>
<td rowspan=4 class="xl70" width=135 style='border-bottom:1.0pt;
border-top:none;width:101pt'>以平均負載算法計算消費者列表負載消息隊列的負載結果</td>
<td class="xl65" width=149 style='width:112pt'>-t</td>
<td class="xl66" width=159 style='width:119pt'>topic 名稱</td>
</tr>
<tr height=23 style='height:17.0pt'>
<td height=23 class="xl65" width=149 style='height:17.0pt;width:112pt'>-h</td>
<td class="xl66" width=159 style='width:119pt'>打印幫助</td>
</tr>
<tr height=57 style='height:43.0pt'>
<td height=57 class="xl65" width=149 style='height:43.0pt;width:112pt'>-n</td>
<td class="xl66" width=159 style='width:119pt'>NameServer 服務地址,格式 ip:port</td>
</tr>
<tr height=95 style='height:71.0pt'>
<td height=95 class="xl65" width=149 style='height:71.0pt;width:112pt'>-i</td>
<td class="xl66" width=159 style='width:119pt'>ipList,用逗號分隔,計算這些ip去負載Topic的消息隊列</td>
</tr>
<tr height=23 style='height:17.0pt'>
<td rowspan=4 height=142 class="xl68" width=163 style='border-bottom:1.0pt solid black;
height:106.0pt;border-top:1.0pt;width:122pt'>statsAll</td>
<td rowspan=4 class="xl70" width=135 style='border-bottom:1.0pt;
border-top:none;width:101pt'>打印Topic訂閱關系、TPS、積累量、24h讀寫總量等信息</td>
<td class="xl65" width=149 style='width:112pt'>-h</td>
<td class="xl66" width=159 style='width:119pt'>打印幫助</td>
</tr>
<tr height=57 style='height:43.0pt'>
<td height=57 class="xl65" width=149 style='height:43.0pt;width:112pt'>-n</td>
<td class="xl66" width=159 style='width:119pt'>NameServer 服務地址,格式 ip:port</td>
</tr>
<tr height=39 style='height:29.0pt'>
<td height=39 class="xl65" width=149 style='height:29.0pt;width:112pt'>-a</td>
<td class="xl66" width=159 style='width:119pt'>是否只打印活躍topic</td>
</tr>
<tr height=23 style='height:17.0pt'>
<td height=23 class="xl65" width=149 style='height:17.0pt;width:112pt'>-t</td>
<td class="xl66" width=159 style='width:119pt'>指定topic</td>
</tr>
</table>
#### 2.2 集群相關
<table border=0 cellpadding=0 cellspacing=0 width=714>
<col width=177>
<col width=175>
<col width=177>
<col width=185>
<tr height=23 style='height:17.0pt'>
<td height=23 class="xl63" width=177 style='height:17.0pt;width:133pt'>名稱</td>
<td class="xl64" width=175 style='width:131pt'>含義</td>
<td class="xl64" width=177 style='width:133pt'>命令選項</td>
<td class="xl64" width=185 style='width:139pt'>說明</td>
</tr>
<tr height=207 style='height:155.0pt'>
<td rowspan=4 height=326 class="xl67" width=177 style='border-bottom:1.0pt;
height:244.0pt;border-top:none;width:133pt'><span
style='mso-spacerun:yes'> </span>clusterList</td>
<td rowspan=4 class="xl70" width=175 style='border-bottom:1.0pt;
border-top:none;width:131pt'>查看集群信息,集群、BrokerName、BrokerId、TPS等信息</td>
<td class="xl65" width=177 style='width:133pt'>-m</td>
<td class="xl66" width=185 style='width:139pt'>打印更多信息 (增加打印出如下信息 #InTotalYest,
#OutTotalYest, #InTotalToday ,#OutTotalToday)</td>
</tr>
<tr height=23 style='height:17.0pt'>
<td height=23 class="xl65" width=177 style='height:17.0pt;width:133pt'>-h</td>
<td class="xl66" width=185 style='width:139pt'>打印幫助</td>
</tr>
<tr height=57 style='height:43.0pt'>
<td height=57 class="xl65" width=177 style='height:43.0pt;width:133pt'>-n</td>
<td class="xl66" width=185 style='width:139pt'>NameServer 服務地址,格式 ip:port</td>
</tr>
<tr height=39 style='height:29.0pt'>
<td height=39 class="xl65" width=177 style='height:29.0pt;width:133pt'>-i</td>
<td class="xl66" width=185 style='width:139pt'>打印間隔,單位秒</td>
</tr>
<tr height=95 style='height:71.0pt'>
<td rowspan=8 height=391 class="xl67" width=177 style='border-bottom:1.0pt;
height:292.0pt;border-top:none;width:133pt'>clusterRT</td>
<td rowspan=8 class="xl70" width=175 style='border-bottom:1.0pt;
border-top:none;width:131pt'>發送消息檢測集群各Broker RT。消息發往${BrokerName} Topic。</td>
<td class="xl65" width=177 style='width:133pt'>-a</td>
<td class="xl66" width=185 style='width:139pt'>amount,每次探測的總數,RT = 總時間 /
amount</td>
</tr>
<tr height=39 style='height:29.0pt'>
<td height=39 class="xl65" width=177 style='height:29.0pt;width:133pt'>-s</td>
<td class="xl66" width=185 style='width:139pt'>消息大小,單位B</td>
</tr>
<tr height=23 style='height:17.0pt'>
<td height=23 class="xl65" width=177 style='height:17.0pt;width:133pt'>-c</td>
<td class="xl66" width=185 style='width:139pt'>探測哪個集群</td>
</tr>
<tr height=76 style='height:57.0pt'>
<td height=76 class="xl65" width=177 style='height:57.0pt;width:133pt'>-p</td>
<td class="xl66" width=185 style='width:139pt'>是否打印格式化日志,以|分割,默認不打印</td>
</tr>
<tr height=23 style='height:17.0pt'>
<td height=23 class="xl65" width=177 style='height:17.0pt;width:133pt'>-h</td>
<td class="xl66" width=185 style='width:139pt'>打印幫助</td>
</tr>
<tr height=39 style='height:29.0pt'>
<td height=39 class="xl65" width=177 style='height:29.0pt;width:133pt'>-m</td>
<td class="xl66" width=185 style='width:139pt'>所屬機房,打印使用</td>
</tr>
<tr height=39 style='height:29.0pt'>
<td height=39 class="xl65" width=177 style='height:29.0pt;width:133pt'>-i</td>
<td class="xl66" width=185 style='width:139pt'>發送間隔,單位秒</td>
</tr>
<tr height=57 style='height:43.0pt'>
<td height=57 class="xl65" width=177 style='height:43.0pt;width:133pt'>-n</td>
<td class="xl66" width=185 style='width:139pt'>NameServer 服務地址,格式 ip:port</td>
</tr>
</table>
#### 2.3 Broker相關
<table border=0 cellpadding=0 cellspacing=0 width=714>
<col width=177>
<col width=175>
<col width=177>
<col width=185>
<tr height=23 style='height:17.0pt'>
<td height=23 class="xl63" width=177 style='height:17.0pt;width:133pt'>名稱</td>
<td class="xl64" width=175 style='width:131pt'>含義</td>
<td class="xl64" width=177 style='width:133pt'>命令選項</td>
<td class="xl64" width=185 style='width:139pt'>說明</td>
</tr>
<tr height=57 style='height:43.0pt'>
<td rowspan=6 height=206 class="xl69" width=191 style='border-bottom:1.0pt;
height:154.0pt;border-top:none;width:143pt'>updateBrokerConfig</td>
<td rowspan=6 class="xl72" width=87 style='border-bottom:1.0pt;
border-top:none;width:65pt'>更新 Broker 配置文件,會修改Broker.conf</td>
<td class="xl67" width=87 style='width:65pt'>-b</td>
<td class="xl68" width=87 style='width:65pt'>Broker 地址,格式為ip:port</td>
</tr>
<tr height=23 style='height:17.0pt'>
<td height=23 class="xl67" width=87 style='height:17.0pt;width:65pt'>-c</td>
<td class="xl68" width=87 style='width:65pt'>cluster 名稱</td>
</tr>
<tr height=23 style='height:17.0pt'>
<td height=23 class="xl67" width=87 style='height:17.0pt;width:65pt'>-k</td>
<td class="xl68" width=87 style='width:65pt'>key 值</td>
</tr>
<tr height=23 style='height:17.0pt'>
<td height=23 class="xl67" width=87 style='height:17.0pt;width:65pt'>-v</td>
<td class="xl68" width=87 style='width:65pt'>value 值</td>
</tr>
<tr height=23 style='height:17.0pt'>
<td height=23 class="xl67" width=87 style='height:17.0pt;width:65pt'>-h</td>
<td class="xl68" width=87 style='width:65pt'>打印幫助</td>
</tr>
<tr height=57 style='height:43.0pt'>
<td height=57 class="xl67" width=87 style='height:43.0pt;width:65pt'>-n</td>
<td class="xl68" width=87 style='width:65pt'>NameServer 服務地址,格式 ip:port</td>
</tr>
<tr height=57 style='height:43.0pt'>
<td rowspan=3 height=137 class="xl69" width=191 style='border-bottom:1.0pt;
height:103.0pt;border-top:none;width:143pt'>brokerStatus</td>
<td rowspan=3 class="xl72" width=87 style='border-bottom:1.0pt;
border-top:none;width:65pt'>查看 Broker 統計信息、運行狀態(你想要的信息幾乎都在里面)</td>
<td class="xl67" width=87 style='width:65pt'>-b</td>
<td class="xl68" width=87 style='width:65pt'>Broker 地址,地址為ip:port</td>
</tr>
<tr height=23 style='height:17.0pt'>
<td height=23 class="xl67" width=87 style='height:17.0pt;width:65pt'>-h</td>
<td class="xl68" width=87 style='width:65pt'>打印幫助</td>
</tr>
<tr height=57 style='height:43.0pt'>
<td height=57 class="xl67" width=87 style='height:43.0pt;width:65pt'>-n</td>
<td class="xl68" width=87 style='width:65pt'>NameServer 服務地址,格式 ip:port</td>
</tr>
<tr height=57 style='height:43.0pt'>
<td rowspan=6 height=256 class="xl69" width=191 style='border-bottom:1.0pt;
height:192.0pt;border-top:none;width:143pt'>brokerConsumeStats</td>
<td rowspan=6 class="xl72" width=87 style='border-bottom:1.0pt;
border-top:none;width:65pt'>Broker中各個消費者的消費情況,按Message Queue維度返回Consume
Offset,Broker Offset,Diff,TImestamp等信息</td>
<td class="xl67" width=87 style='width:65pt'>-b</td>
<td class="xl68" width=87 style='width:65pt'>Broker 地址,地址為ip:port</td>
</tr>
<tr height=23 style='height:17.0pt'>
<td height=23 class="xl67" width=87 style='height:17.0pt;width:65pt'>-t</td>
<td class="xl68" width=87 style='width:65pt'>請求超時時間</td>
</tr>
<tr height=39 style='height:29.0pt'>
<td height=39 class="xl67" width=87 style='height:29.0pt;width:65pt'>-l</td>
<td class="xl68" width=87 style='width:65pt'>diff閾值,超過閾值才打印</td>
</tr>
<tr height=57 style='height:43.0pt'>
<td height=57 class="xl67" width=87 style='height:43.0pt;width:65pt'>-o</td>
<td class="xl68" width=87 style='width:65pt'>是否為順序topic,一般為false</td>
</tr>
<tr height=23 style='height:17.0pt'>
<td height=23 class="xl67" width=87 style='height:17.0pt;width:65pt'>-h</td>
<td class="xl68" width=87 style='width:65pt'>打印幫助</td>
</tr>
<tr height=57 style='height:43.0pt'>
<td height=57 class="xl67" width=87 style='height:43.0pt;width:65pt'>-n</td>
<td class="xl68" width=87 style='width:65pt'>NameServer 服務地址,格式 ip:port</td>
</tr>
<tr height=57 style='height:43.0pt'>
<td rowspan=2 height=114 class="xl69" width=191 style='border-bottom:1.0pt;
height:86.0pt;border-top:none;width:143pt'>getBrokerConfig</td>
<td rowspan=2 class="xl72" width=87 style='border-bottom:1.0pt
border-top:none;width:65pt'>獲取Broker配置</td>
<td class="xl67" width=87 style='width:65pt'>-b</td>
<td class="xl68" width=87 style='width:65pt'>Broker 地址,地址為ip:port</td>
</tr>
<tr height=57 style='height:43.0pt'>
<td height=57 class="xl67" width=87 style='height:43.0pt;width:65pt'>-n</td>
<td class="xl68" width=87 style='width:65pt'>NameServer 服務地址,格式 ip:port</td>
</tr>
<tr height=57 style='height:43.0pt'>
<td rowspan=3 height=137 class="xl69" width=191 style='border-bottom:1.0pt;
height:103.0pt;border-top:none;width:143pt'>wipeWritePerm</td>
<td rowspan=3 class="xl72" width=87 style='border-bottom:1.0pt
border-top:none;width:65pt'>從NameServer上清除 Broker寫權限</td>
<td class="xl67" width=87 style='width:65pt'>-b</td>
<td class="xl68" width=87 style='width:65pt'>Broker 地址,地址為ip:port</td>
</tr>
<tr height=57 style='height:43.0pt'>
<td height=57 class="xl67" width=87 style='height:43.0pt;width:65pt'>-n</td>
<td class="xl68" width=87 style='width:65pt'>NameServer 服務地址,格式 ip:port</td>
</tr>
<tr height=23 style='height:17.0pt'>
<td height=23 class="xl67" width=87 style='height:17.0pt;width:65pt'>-h</td>
<td class="xl68" width=87 style='width:65pt'>打印幫助</td>
</tr>
<tr height=57 style='height:43.0pt'>
<td rowspan=4 height=160 class="xl69" width=191 style='border-bottom:1.0pt;
height:120.0pt;border-top:none;width:143pt'>cleanExpiredCQ</td>
<td rowspan=4 class="xl72" width=87 style='border-bottom:1.0pt
border-top:none;width:65pt'>清理Broker上過期的Consume Queue,如果手動減少對列數可能產生過期隊列</td>
<td class="xl67" width=87 style='width:65pt'>-n</td>
<td class="xl68" width=87 style='width:65pt'>NameServer 服務地址,格式 ip:port</td>
</tr>
<tr height=23 style='height:17.0pt'>
<td height=23 class="xl67" width=87 style='height:17.0pt;width:65pt'>-h</td>
<td class="xl68" width=87 style='width:65pt'>打印幫助</td>
</tr>
<tr height=57 style='height:43.0pt'>
<td height=57 class="xl67" width=87 style='height:43.0pt;width:65pt'>-b</td>
<td class="xl68" width=87 style='width:65pt'>Broker 地址,地址為ip:port</td>
</tr>
<tr height=23 style='height:17.0pt'>
<td height=23 class="xl67" width=87 style='height:17.0pt;width:65pt'>-c</td>
<td class="xl68" width=87 style='width:65pt'>集群名稱</td>
</tr>
<tr height=88 style='mso-height-source:userset;height:66.0pt'>
<td rowspan=4 height=191 class="xl69" width=191 style='border-bottom:1.0pt;
height:143.0pt;border-top:none;width:143pt'>cleanUnusedTopic</td>
<td rowspan=4 class="xl72" width=87 style='border-bottom:1.0pt
border-top:none;width:65pt'>清理Broker上不使用的Topic,從內存中釋放Topic的Consume
Queue,如果手動刪除Topic會產生不使用的Topic</td>
<td class="xl67" width=87 style='width:65pt'>-n</td>
<td class="xl68" width=87 style='width:65pt'>NameServer 服務地址,格式 ip:port</td>
</tr>
<tr height=23 style='height:17.0pt'>
<td height=23 class="xl67" width=87 style='height:17.0pt;width:65pt'>-h</td>
<td class="xl68" width=87 style='width:65pt'>打印幫助</td>
</tr>
<tr height=57 style='height:43.0pt'>
<td height=57 class="xl67" width=87 style='height:43.0pt;width:65pt'>-b</td>
<td class="xl68" width=87 style='width:65pt'>Broker 地址,地址為ip:port</td>
</tr>
<tr height=23 style='height:17.0pt'>
<td height=23 class="xl67" width=87 style='height:17.0pt;width:65pt'>-c</td>
<td class="xl68" width=87 style='width:65pt'>集群名稱</td>
</tr>
<tr height=57 style='height:43.0pt'>
<td rowspan=5 height=199 class="xl69" width=191 style='border-bottom:1.0pt;
height:149.0pt;border-top:none;width:143pt'>sendMsgStatus</td>
<td rowspan=5 class="xl72" width=87 style='border-bottom:1.0pt
border-top:none;width:65pt'>向Broker發消息,返回發送狀態和RT</td>
<td class="xl67" width=87 style='width:65pt'>-n</td>
<td class="xl68" width=87 style='width:65pt'>NameServer 服務地址,格式 ip:port</td>
</tr>
<tr height=23 style='height:17.0pt'>
<td height=23 class="xl67" width=87 style='height:17.0pt;width:65pt'>-h</td>
<td class="xl68" width=87 style='width:65pt'>打印幫助</td>
</tr>
<tr height=57 style='height:43.0pt'>
<td height=57 class="xl67" width=87 style='height:43.0pt;width:65pt'>-b</td>
<td class="xl68" width=87 style='width:65pt'>BrokerName,注意不同於Broker地址</td>
</tr>
<tr height=39 style='height:29.0pt'>
<td height=39 class="xl67" width=87 style='height:29.0pt;width:65pt'>-s</td>
<td class="xl68" width=87 style='width:65pt'>消息大小,單位B</td>
</tr>
<tr height=23 style='height:17.0pt'>
<td height=23 class="xl67" width=87 style='height:17.0pt;width:65pt'>-c</td>
<td class="xl68" width=87 style='width:65pt'>發送次數</td>
</tr>
</table>
#### 2.4 消息相關
<table border=0 cellpadding=0 cellspacing=0 width=714>
<col width=177>
<col width=175>
<col width=177>
<col width=185>
<tr height=23 style='height:17.0pt'>
<td height=23 class="xl63" width=177 style='height:17.0pt;width:133pt'>名稱</td>
<td class="xl64" width=175 style='width:131pt'>含義</td>
<td class="xl64" width=177 style='width:133pt'>命令選項</td>
<td class="xl64" width=185 style='width:139pt'>說明</td>
</tr>
<tr height=128 style='height:96.0pt'>
<td rowspan=3 height=208 class="xl69" width=87 style='border-bottom:1.0pt;
height:156.0pt;border-top:none;width:65pt'>queryMsgById</td>
<td rowspan=3 class="xl72" width=87 style='border-bottom:1.0pt;
border-top:none;width:65pt'>根據offsetMsgId查詢msg,如果使用開源控制台,應使用offsetMsgId,此命令還有其他參數,具體作用請閱讀QueryMsgByIdSubCommand。</td>
<td class="xl67" width=87 style='width:65pt'>-i</td>
<td class="xl67" width=87 style='width:65pt'>msgId</td>
</tr>
<tr height=23 style='height:17.0pt'>
<td height=23 class="xl67" width=87 style='height:17.0pt;width:65pt'>-h</td>
<td class="xl68" width=87 style='width:65pt'>打印幫助</td>
</tr>
<tr height=57 style='height:43.0pt'>
<td height=57 class="xl67" width=87 style='height:43.0pt;width:65pt'>-n</td>
<td class="xl68" width=87 style='width:65pt'>NameServer 服務地址,格式 ip:port</td>
</tr>
<tr height=23 style='height:17.0pt'>
<td rowspan=4 height=126 class="xl69" width=87 style='border-bottom:1.0pt;
height:94.0pt;border-top:none;width:65pt'>queryMsgByKey</td>
<td rowspan=4 class="xl72" width=87 style='border-bottom:1.0pt;
border-top:none;width:65pt'>根據消息 Key 查詢消息</td>
<td class="xl67" width=87 style='width:65pt'>-k</td>
<td class="xl67" width=87 style='width:65pt'>msgKey</td>
</tr>
<tr height=23 style='height:17.0pt'>
<td height=23 class="xl67" width=87 style='height:17.0pt;width:65pt'>-t</td>
<td class="xl68" width=87 style='width:65pt'>Topic 名稱</td>
</tr>
<tr height=23 style='height:17.0pt'>
<td height=23 class="xl67" width=87 style='height:17.0pt;width:65pt'>-h</td>
<td class="xl68" width=87 style='width:65pt'>打印幫助</td>
</tr>
<tr height=57 style='height:43.0pt'>
<td height=57 class="xl67" width=87 style='height:43.0pt;width:65pt'>-n</td>
<td class="xl68" width=87 style='width:65pt'>NameServer 服務地址,格式 ip:port</td>
</tr>
<tr height=225 style='height:169.0pt'>
<td rowspan=6 height=390 class="xl69" width=87 style='border-bottom:1.0pt;
height:292.0pt;border-top:none;width:65pt'>queryMsgByOffset</td>
<td rowspan=6 class="xl72" width=87 style='border-bottom:1.0pt;
border-top:none;width:65pt'>根據 Offset 查詢消息</td>
<td class="xl67" width=87 style='width:65pt'>-b</td>
<td class="xl68" width=87 style='width:65pt'>Broker 名稱,(這里需要注意
填寫的是 Broker 的名稱,不是 Broker 的地址,Broker 名稱可以在 clusterList 查到)</td>
</tr>
<tr height=39 style='height:29.0pt'>
<td height=39 class="xl67" width=87 style='height:29.0pt;width:65pt'>-i</td>
<td class="xl68" width=87 style='width:65pt'>query 隊列 id</td>
</tr>
<tr height=23 style='height:17.0pt'>
<td height=23 class="xl67" width=87 style='height:17.0pt;width:65pt'>-o</td>
<td class="xl68" width=87 style='width:65pt'>offset 值</td>
</tr>
<tr height=23 style='height:17.0pt'>
<td height=23 class="xl67" width=87 style='height:17.0pt;width:65pt'>-t</td>
<td class="xl68" width=87 style='width:65pt'>topic 名稱</td>
</tr>
<tr height=23 style='height:17.0pt'>
<td height=23 class="xl67" width=87 style='height:17.0pt;width:65pt'>-h</td>
<td class="xl68" width=87 style='width:65pt'>打印幫助</td>
</tr>
<tr height=57 style='height:43.0pt'>
<td height=57 class="xl67" width=87 style='height:43.0pt;width:65pt'>-n</td>
<td class="xl68" width=87 style='width:65pt'>NameServer 服務地址,格式 ip:port</td>
</tr>
<tr height=47>
<td rowspan=6 height=209 class="xl69" width=87 style='border-bottom:1.0pt;
height:156.0pt;border-top:none;width:65pt'>queryMsgByUniqueKey</td>
<td rowspan=6 class="xl72" width=87 style='border-bottom:1.0pt;
border-top:none;width:65pt'>根據msgId查詢,msgId不同於offsetMsgId,區別詳見常見運維問題。-g,-d配合使用,查到消息后嘗試讓特定的消費者消費消息並返回消費結果</td>
<td class="xl67" width=87 style='width:65pt'>-h</td>
<td class="xl68" width=87 style='width:65pt'>打印幫助</td>
</tr>
<tr height=57 style='height:43.0pt'>
<td height=57 class="xl67" width=87 style='height:43.0pt;width:65pt'>-n</td>
<td class="xl68" width=87 style='width:65pt'>NameServer 服務地址,格式 ip:port</td>
</tr>
<tr height=23 style='height:17.0pt'>
<td height=23 class="xl67" width=87 style='height:17.0pt;width:65pt'>-i</td>
<td class="xl67" width=87 style='width:65pt'>uniqe msg id</td>
</tr>
<tr height=36 style='height:27.0pt'>
<td height=36 class="xl67" width=87 style='height:27.0pt;width:65pt'>-g</td>
<td class="xl67" width=87 style='width:65pt'>consumerGroup</td>
</tr>
<tr height=23 style='height:17.0pt'>
<td height=23 class="xl67" width=87 style='height:17.0pt;width:65pt'>-d</td>
<td class="xl67" width=87 style='width:65pt'>clientId</td>
</tr>
<tr height=23 style='height:17.0pt'>
<td height=23 class="xl67" width=87 style='height:17.0pt;width:65pt'>-t</td>
<td class="xl68" width=87 style='width:65pt'>topic名稱</td>
</tr>
<tr height=23 style='height:17.0pt'>
<td rowspan=5 height=149 class="xl69" width=87 style='border-bottom:1.0pt
height:111.0pt;border-top:none;width:65pt'>checkMsgSendRT</td>
<td rowspan=5 class="xl72" width=87 style='border-bottom:1.0pt;
border-top:none;width:65pt'>檢測向topic發消息的RT,功能類似clusterRT</td>
<td class="xl67" width=87 style='width:65pt'>-h</td>
<td class="xl68" width=87 style='width:65pt'>打印幫助</td>
</tr>
<tr height=57 style='height:43.0pt'>
<td height=57 class="xl67" width=87 style='height:43.0pt;width:65pt'>-n</td>
<td class="xl68" width=87 style='width:65pt'>NameServer 服務地址,格式 ip:port</td>
</tr>
<tr height=23 style='height:17.0pt'>
<td height=23 class="xl67" width=87 style='height:17.0pt;width:65pt'>-t</td>
<td class="xl68" width=87 style='width:65pt'>topic名稱</td>
</tr>
<tr height=23 style='height:17.0pt'>
<td height=23 class="xl67" width=87 style='height:17.0pt;width:65pt'>-a</td>
<td class="xl68" width=87 style='width:65pt'>探測次數</td>
</tr>
<tr height=23 style='height:17.0pt'>
<td height=23 class="xl67" width=87 style='height:17.0pt;width:65pt'>-s</td>
<td class="xl68" width=87 style='width:65pt'>消息大小</td>
</tr>
<tr height=23 style='height:17.0pt'>
<td rowspan=8 height=218 class="xl69" width=87 style='border-bottom:1.0pt;
height:162.0pt;border-top:none;width:65pt'>sendMessage</td>
<td rowspan=8 class="xl72" width=87 style='border-bottom:1.0pt;
border-top:none;width:65pt'>發送一條消息,可以根據配置發往特定Message Queue,或普通發送。</td>
<td class="xl67" width=87 style='width:65pt'>-h</td>
<td class="xl68" width=87 style='width:65pt'>打印幫助</td>
</tr>
<tr height=57 style='height:43.0pt'>
<td height=57 class="xl67" width=87 style='height:43.0pt;width:65pt'>-n</td>
<td class="xl68" width=87 style='width:65pt'>NameServer 服務地址,格式 ip:port</td>
</tr>
<tr height=23 style='height:17.0pt'>
<td height=23 class="xl67" width=87 style='height:17.0pt;width:65pt'>-t</td>
<td class="xl68" width=87 style='width:65pt'>topic名稱</td>
</tr>
<tr height=23 style='height:17.0pt'>
<td height=23 class="xl67" width=87 style='height:17.0pt;width:65pt'>-p</td>
<td class="xl68" width=87 style='width:65pt'>body,消息體</td>
</tr>
<tr height=23 style='height:17.0pt'>
<td height=23 class="xl67" width=87 style='height:17.0pt;width:65pt'>-k</td>
<td class="xl67" width=87 style='width:65pt'>keys</td>
</tr>
<tr height=23 style='height:17.0pt'>
<td height=23 class="xl67" width=87 style='height:17.0pt;width:65pt'>-c</td>
<td class="xl67" width=87 style='width:65pt'>tags</td>
</tr>
<tr height=23 style='height:17.0pt'>
<td height=23 class="xl67" width=87 style='height:17.0pt;width:65pt'>-b</td>
<td class="xl67" width=87 style='width:65pt'>BrokerName</td>
</tr>
<tr height=23 style='height:17.0pt'>
<td height=23 class="xl67" width=87 style='height:17.0pt;width:65pt'>-i</td>
<td class="xl67" width=87 style='width:65pt'>queueId</td>
</tr>
<tr height=23 style='height:17.0pt'>
<td rowspan=10 height=312 class="xl69" width=87 style='border-bottom:1.0pt;
height:232.0pt;border-top:none;width:65pt'>consumeMessage</td>
<td rowspan=10 class="xl72" width=87 style='border-bottom:1.0pt;
border-top:none;width:65pt'>消費消息。可以根據offset、開始&結束時間戳、消息隊列消費消息,配置不同執行不同消費邏輯,詳見ConsumeMessageCommand。</td>
<td class="xl67" width=87 style='width:65pt'>-h</td>
<td class="xl68" width=87 style='width:65pt'>打印幫助</td>
</tr>
<tr height=57 style='height:43.0pt'>
<td height=57 class="xl67" width=87 style='height:43.0pt;width:65pt'>-n</td>
<td class="xl68" width=87 style='width:65pt'>NameServer 服務地址,格式 ip:port</td>
</tr>
<tr height=23 style='height:17.0pt'>
<td height=23 class="xl67" width=87 style='height:17.0pt;width:65pt'>-t</td>
<td class="xl68" width=87 style='width:65pt'>topic名稱</td>
</tr>
<tr height=23 style='height:17.0pt'>
<td height=23 class="xl67" width=87 style='height:17.0pt;width:65pt'>-b</td>
<td class="xl67" width=87 style='width:65pt'>BrokerName</td>
</tr>
<tr height=39 style='height:29.0pt'>
<td height=39 class="xl67" width=87 style='height:29.0pt;width:65pt'>-o</td>
<td class="xl68" width=87 style='width:65pt'>從offset開始消費</td>
</tr>
<tr height=23 style='height:17.0pt'>
<td height=23 class="xl67" width=87 style='height:17.0pt;width:65pt'>-i</td>
<td class="xl67" width=87 style='width:65pt'>queueId</td>
</tr>
<tr height=23 style='height:17.0pt'>
<td height=23 class="xl67" width=87 style='height:17.0pt;width:65pt'>-g</td>
<td class="xl68" width=87 style='width:65pt'>消費者分組</td>
</tr>
<tr height=39 style='height:29.0pt'>
<td height=39 class="xl67" width=87 style='height:29.0pt;width:65pt'>-s</td>
<td class="xl68" width=87 style='width:65pt'>開始時間戳,格式詳見-h</td>
</tr>
<tr height=23 style='height:17.0pt'>
<td height=23 class="xl67" width=87 style='height:17.0pt;width:65pt'>-d</td>
<td class="xl68" width=87 style='width:65pt'>結束時間戳</td>
</tr>
<tr height=39 style='height:29.0pt'>
<td height=39 class="xl67" width=87 style='height:29.0pt;width:65pt'>-c</td>
<td class="xl68" width=87 style='width:65pt'>消費多少條消息</td>
</tr>
<tr height=23 style='height:17.0pt'>
<td rowspan=8 height=282 class="xl69" width=87 style='border-bottom:1.0pt;
height:210.0pt;border-top:none;width:65pt'>printMsg</td>
<td rowspan=8 class="xl72" width=87 style='border-bottom:1.0pt;
border-top:none;width:65pt'>從Broker消費消息並打印,可選時間段</td>
<td class="xl67" width=87 style='width:65pt'>-h</td>
<td class="xl68" width=87 style='width:65pt'>打印幫助</td>
</tr>
<tr height=57 style='height:43.0pt'>
<td height=57 class="xl67" width=87 style='height:43.0pt;width:65pt'>-n</td>
<td class="xl68" width=87 style='width:65pt'>NameServer 服務地址,格式 ip:port</td>
</tr>
<tr height=23 style='height:17.0pt'>
<td height=23 class="xl67" width=87 style='height:17.0pt;width:65pt'>-t</td>
<td class="xl68" width=87 style='width:65pt'>topic名稱</td>
</tr>
<tr height=39 style='height:29.0pt'>
<td height=39 class="xl67" width=87 style='height:29.0pt;width:65pt'>-c</td>
<td class="xl68" width=87 style='width:65pt'>字符集,例如UTF-8</td>
</tr>
<tr height=39 style='height:29.0pt'>
<td height=39 class="xl67" width=87 style='height:29.0pt;width:65pt'>-s</td>
<td class="xl68" width=87 style='width:65pt'>subExpress,過濾表達式</td>
</tr>
<tr height=39 style='height:29.0pt'>
<td height=39 class="xl67" width=87 style='height:29.0pt;width:65pt'>-b</td>
<td class="xl68" width=87 style='width:65pt'>開始時間戳,格式參見-h</td>
</tr>
<tr height=23 style='height:17.0pt'>
<td height=23 class="xl67" width=87 style='height:17.0pt;width:65pt'>-e</td>
<td class="xl68" width=87 style='width:65pt'>結束時間戳</td>
</tr>
<tr height=39 style='height:29.0pt'>
<td height=39 class="xl67" width=87 style='height:29.0pt;width:65pt'>-d</td>
<td class="xl68" width=87 style='width:65pt'>是否打印消息體</td>
</tr>
<tr height=23 style='height:17.0pt'>
<td rowspan=12 height=390 class="xl69" width=87 style='border-bottom:1.0pt;
height:290.0pt;border-top:none;width:65pt'>printMsgByQueue</td>
<td rowspan=12 class="xl72" width=87 style='border-bottom:1.0pt;
border-top:none;width:65pt'>類似printMsg,但指定Message Queue</td>
<td class="xl67" width=87 style='width:65pt'>-h</td>
<td class="xl68" width=87 style='width:65pt'>打印幫助</td>
</tr>
<tr height=57 style='height:43.0pt'>
<td height=57 class="xl67" width=87 style='height:43.0pt;width:65pt'>-n</td>
<td class="xl68" width=87 style='width:65pt'>NameServer 服務地址,格式 ip:port</td>
</tr>
<tr height=23 style='height:17.0pt'>
<td height=23 class="xl67" width=87 style='height:17.0pt;width:65pt'>-t</td>
<td class="xl68" width=87 style='width:65pt'>topic名稱</td>
</tr>
<tr height=23 style='height:17.0pt'>
<td height=23 class="xl67" width=87 style='height:17.0pt;width:65pt'>-i</td>
<td class="xl67" width=87 style='width:65pt'>queueId</td>
</tr>
<tr height=23 style='height:17.0pt'>
<td height=23 class="xl67" width=87 style='height:17.0pt;width:65pt'>-a</td>
<td class="xl67" width=87 style='width:65pt'>BrokerName</td>
</tr>
<tr height=39 style='height:29.0pt'>
<td height=39 class="xl67" width=87 style='height:29.0pt;width:65pt'>-c</td>
<td class="xl68" width=87 style='width:65pt'>字符集,例如UTF-8</td>
</tr>
<tr height=39 style='height:29.0pt'>
<td height=39 class="xl67" width=87 style='height:29.0pt;width:65pt'>-s</td>
<td class="xl68" width=87 style='width:65pt'>subExpress,過濾表達式</td>
</tr>
<tr height=39 style='height:29.0pt'>
<td height=39 class="xl67" width=87 style='height:29.0pt;width:65pt'>-b</td>
<td class="xl68" width=87 style='width:65pt'>開始時間戳,格式參見-h</td>
</tr>
<tr height=23 style='height:17.0pt'>
<td height=23 class="xl67" width=87 style='height:17.0pt;width:65pt'>-e</td>
<td class="xl68" width=87 style='width:65pt'>結束時間戳</td>
</tr>
<tr height=23 style='height:17.0pt'>
<td height=23 class="xl67" width=87 style='height:17.0pt;width:65pt'>-p</td>
<td class="xl68" width=87 style='width:65pt'>是否打印消息</td>
</tr>
<tr height=39 style='height:29.0pt'>
<td height=39 class="xl67" width=87 style='height:29.0pt;width:65pt'>-d</td>
<td class="xl68" width=87 style='width:65pt'>是否打印消息體</td>
</tr>
<tr height=39 style='height:29.0pt'>
<td height=39 class="xl67" width=87 style='height:29.0pt;width:65pt'>-f</td>
<td class="xl68" width=87 style='width:65pt'>是否統計tag數量並打印</td>
</tr>
<tr height=23 style='height:17.0pt'>
<td rowspan=7 height=410 class="xl69" width=87 style='border-bottom:1.0pt;
height:307.0pt;border-top:none;width:65pt'>resetOffsetByTime</td>
<td rowspan=7 class="xl72" width=87 style='border-bottom:1.0pt;
border-top:none;width:65pt'>按時間戳重置offset,Broker和consumer都會重置</td>
<td class="xl67" width=87 style='width:65pt'>-h</td>
<td class="xl68" width=87 style='width:65pt'>打印幫助</td>
</tr>
<tr height=57 style='height:43.0pt'>
<td height=57 class="xl67" width=87 style='height:43.0pt;width:65pt'>-n</td>
<td class="xl68" width=87 style='width:65pt'>NameServer 服務地址,格式 ip:port</td>
</tr>
<tr height=23 style='height:17.0pt'>
<td height=23 class="xl67" width=87 style='height:17.0pt;width:65pt'>-g</td>
<td class="xl68" width=87 style='width:65pt'>消費者分組</td>
</tr>
<tr height=23 style='height:17.0pt'>
<td height=23 class="xl67" width=87 style='height:17.0pt;width:65pt'>-t</td>
<td class="xl68" width=87 style='width:65pt'>topic名稱</td>
</tr>
<tr height=57 style='height:43.0pt'>
<td height=57 class="xl67" width=87 style='height:43.0pt;width:65pt'>-s</td>
<td class="xl68" width=87 style='width:65pt'>重置為此時間戳對應的offset</td>
</tr>
<tr height=188 style='height:141.0pt'>
<td height=188 class="xl67" width=87 style='height:141.0pt;width:65pt'>-f</td>
<td class="xl68" width=87 style='width:65pt'>是否強制重置,如果false,只支持回溯offset,如果true,不管時間戳對應offset與consumeOffset關系</td>
</tr>
<tr height=39 style='height:29.0pt'>
<td height=39 class="xl67" width=87 style='height:29.0pt;width:65pt'>-c</td>
<td class="xl68" width=87 style='width:65pt'>是否重置c++客戶端offset</td>
</tr>
</table>
#### 2.5 消費者、消費組相關
<table border=0 cellpadding=0 cellspacing=0 width=714>
<col width=177>
<col width=175>
<col width=177>
<col width=185>
<tr height=23 style='height:17.0pt'>
<td height=23 class="xl63" width=177 style='height:17.0pt;width:133pt'>名稱</td>
<td class="xl64" width=175 style='width:131pt'>含義</td>
<td class="xl64" width=177 style='width:133pt'>命令選項</td>
<td class="xl64" width=185 style='width:139pt'>說明</td>
</tr>
<tr height=39 style='height:29.0pt'>
<td rowspan=4 height=158 class="xl69" width=87 style='border-bottom:1.0pt;
height:110pt;border-top:none;width:65pt'>consumerProgress</td>
<td rowspan=4 class="xl72" width=87 style='border-bottom:1.0pt;
border-top:none;width:65pt'>查看訂閱組消費狀態,可以查看具體的client IP的消息積累量</td>
<td class="xl67" width=87 style='width:65pt'>-g</td>
<td class="xl68" width=87 style='width:65pt'>消費者所屬組名</td>
</tr>
<tr height=39 style='height:29.0pt'>
<td height=39 class="xl67" width=87 style='height:29.0pt;width:65pt'>-s</td>
<td class="xl68" width=87 style='width:65pt'>是否打印client IP</td>
</tr>
<tr height=23 style='height:17.0pt'>
<td height=23 class="xl67" width=87 style='height:17.0pt;width:65pt'>-h</td>
<td class="xl68" width=87 style='width:65pt'>打印幫助</td>
</tr>
<tr height=57 style='height:43.0pt'>
<td height=57 class="xl67" width=87 style='height:43.0pt;width:65pt'>-n</td>
<td class="xl68" width=87 style='width:65pt'>NameServer 服務地址,格式 ip:port</td>
</tr>
<tr height=105 style='mso-height-source:userset;height:79.0pt'>
<td rowspan=5 height=260 class="xl69" width=87 style='border-bottom:1.0pt;
height:195.0pt;border-top:none;width:65pt'>consumerStatus</td>
<td rowspan=5 class="xl72" width=87 style='border-bottom:1.0pt
border-top:none;width:65pt'>查看消費者狀態,包括同一個分組中是否都是相同的訂閱,分析Process
Queue是否堆積,返回消費者jstack結果,內容較多,使用者參見ConsumerStatusSubCommand</td>
<td class="xl67" width=87 style='width:65pt'>-h</td>
<td class="xl68" width=87 style='width:65pt'>打印幫助</td>
</tr>
<tr height=57 style='height:43.0pt'>
<td height=57 class="xl67" width=87 style='height:43.0pt;width:65pt'>-n</td>
<td class="xl68" width=87 style='width:65pt'>NameServer 服務地址,格式 ip:port</td>
</tr>
<tr height=36 style='height:27.0pt'>
<td height=36 class="xl67" width=87 style='height:27.0pt;width:65pt'>-g</td>
<td class="xl67" width=87 style='width:65pt'>consumer group</td>
</tr>
<tr height=23 style='height:17.0pt'>
<td height=23 class="xl67" width=87 style='height:17.0pt;width:65pt'>-i</td>
<td class="xl67" width=87 style='width:65pt'>clientId</td>
</tr>
<tr height=39 style='height:29.0pt'>
<td height=39 class="xl67" width=87 style='height:29.0pt;width:65pt'>-s</td>
<td class="xl68" width=87 style='width:65pt'>是否執行jstack</td>
</tr>
<tr height=57 style='height:43.0pt'>
<td rowspan=13 height=761 class="xl69" width=87 style='border-bottom:1.0pt
height:569.0pt;border-top:none;width:65pt'>updateSubGroup</td>
<td rowspan=13 class="xl72" width=87 style='border-bottom:1.0pt
border-top:none;width:65pt'>更新或創建訂閱關系</td>
<td class="xl67" width=87 style='width:65pt'>-n</td>
<td class="xl68" width=87 style='width:65pt'>NameServer 服務地址,格式 ip:port</td>
</tr>
<tr height=23 style='height:17.0pt'>
<td height=23 class="xl67" width=87 style='height:17.0pt;width:65pt'>-h</td>
<td class="xl68" width=87 style='width:65pt'>打印幫助</td>
</tr>
<tr height=23 style='height:17.0pt'>
<td height=23 class="xl67" width=87 style='height:17.0pt;width:65pt'>-b</td>
<td class="xl68" width=87 style='width:65pt'>Broker地址</td>
</tr>
<tr height=23 style='height:17.0pt'>
<td height=23 class="xl67" width=87 style='height:17.0pt;width:65pt'>-c</td>
<td class="xl68" width=87 style='width:65pt'>集群名稱</td>
</tr>
<tr height=39 style='height:29.0pt'>
<td height=39 class="xl67" width=87 style='height:29.0pt;width:65pt'>-g</td>
<td class="xl68" width=87 style='width:65pt'>消費者分組名稱</td>
</tr>
<tr height=39 style='height:29.0pt'>
<td height=39 class="xl67" width=87 style='height:29.0pt;width:65pt'>-s</td>
<td class="xl68" width=87 style='width:65pt'>分組是否允許消費</td>
</tr>
<tr height=57 style='height:43.0pt'>
<td height=57 class="xl67" width=87 style='height:43.0pt;width:65pt'>-m</td>
<td class="xl68" width=87 style='width:65pt'>是否從最小offset開始消費</td>
</tr>
<tr height=39 style='height:29.0pt'>
<td height=39 class="xl67" width=87 style='height:29.0pt;width:65pt'>-d</td>
<td class="xl68" width=87 style='width:65pt'>是否是廣播模式</td>
</tr>
<tr height=23 style='height:17.0pt'>
<td height=23 class="xl67" width=87 style='height:17.0pt;width:65pt'>-q</td>
<td class="xl68" width=87 style='width:65pt'>重試隊列數量</td>
</tr>
<tr height=23 style='height:17.0pt'>
<td height=23 class="xl67" width=87 style='height:17.0pt;width:65pt'>-r</td>
<td class="xl68" width=87 style='width:65pt'>最大重試次數</td>
</tr>
<tr height=207 style='height:155.0pt'>
<td height=207 class="xl67" width=87 style='height:155.0pt;width:65pt'>-i</td>
<td class="xl68" width=87 style='width:65pt'>當slaveReadEnable開啟時有效,且還未達到從slave消費時建議從哪個BrokerId消費,可以配置備機id,主動從備機消費</td>
</tr>
<tr height=132 style='height:99.0pt'>
<td height=132 class="xl67" width=87 style='height:99.0pt;width:65pt'>-w</td>
<td class="xl68" width=87 style='width:65pt'>如果Broker建議從slave消費,配置決定從哪個slave消費,配置BrokerId,例如1</td>
</tr>
<tr height=76 style='height:57.0pt'>
<td height=76 class="xl67" width=87 style='height:57.0pt;width:65pt'>-a</td>
<td class="xl68" width=87 style='width:65pt'>當消費者數量變化時是否通知其他消費者負載均衡</td>
</tr>
<tr height=57 style='height:43.0pt'>
<td rowspan=5 height=165 class="xl69" width=87 style='border-bottom:1.0pt
height:123.0pt;border-top:none;width:65pt'>deleteSubGroup</td>
<td rowspan=5 class="xl72" width=87 style='border-bottom:1.0pt
border-top:none;width:65pt'>從Broker刪除訂閱關系</td>
<td class="xl67" width=87 style='width:65pt'>-n</td>
<td class="xl68" width=87 style='width:65pt'>NameServer 服務地址,格式 ip:port</td>
</tr>
<tr height=23 style='height:17.0pt'>
<td height=23 class="xl67" width=87 style='height:17.0pt;width:65pt'>-h</td>
<td class="xl68" width=87 style='width:65pt'>打印幫助</td>
</tr>
<tr height=23 style='height:17.0pt'>
<td height=23 class="xl67" width=87 style='height:17.0pt;width:65pt'>-b</td>
<td class="xl68" width=87 style='width:65pt'>Broker地址</td>
</tr>
<tr height=23 style='height:17.0pt'>
<td height=23 class="xl67" width=87 style='height:17.0pt;width:65pt'>-c</td>
<td class="xl68" width=87 style='width:65pt'>集群名稱</td>
</tr>
<tr height=39 style='height:29.0pt'>
<td height=39 class="xl67" width=87 style='height:29.0pt;width:65pt'>-g</td>
<td class="xl68" width=87 style='width:65pt'>消費者分組名稱</td>
</tr>
<tr height=57 style='height:43.0pt'>
<td rowspan=6 height=172 class="xl69" width=87 style='border-bottom:1.0pt
height:120pt;border-top:none;width:65pt'>cloneGroupOffset</td>
<td rowspan=6 class="xl72" width=87 style='border-bottom:1.0pt
border-top:none;width:65pt'>在目標群組中使用源群組的offset</td>
<td class="xl67" width=87 style='width:65pt'>-n</td>
<td class="xl68" width=87 style='width:65pt'>NameServer 服務地址,格式 ip:port</td>
</tr>
<tr height=23 style='height:17.0pt'>
<td height=23 class="xl67" width=87 style='height:17.0pt;width:65pt'>-h</td>
<td class="xl68" width=87 style='width:65pt'>打印幫助</td>
</tr>
<tr height=23 style='height:17.0pt'>
<td height=23 class="xl67" width=87 style='height:17.0pt;width:65pt'>-s</td>
<td class="xl68" width=87 style='width:65pt'>源消費者組</td>
</tr>
<tr height=23 style='height:17.0pt'>
<td height=23 class="xl67" width=87 style='height:17.0pt;width:65pt'>-d</td>
<td class="xl68" width=87 style='width:65pt'>目標消費者組</td>
</tr>
<tr height=23 style='height:17.0pt'>
<td height=23 class="xl67" width=87 style='height:17.0pt;width:65pt'>-t</td>
<td class="xl68" width=87 style='width:65pt'>topic名稱</td>
</tr>
<tr height=23 style='height:17.0pt'>
<td height=23 class="xl67" width=87 style='height:17.0pt;width:65pt'>-o</td>
<td class="xl68" width=87 style='width:65pt'>暫未使用</td>
</tr>
</table>
#### 2.6 連接相關
<table border=0 cellpadding=0 cellspacing=0 width=714>
<col width=177>
<col width=175>
<col width=177>
<col width=185>
<tr height=23 style='height:17.0pt'>
<td height=23 class="xl63" width=177 style='height:17.0pt;width:133pt'>名稱</td>
<td class="xl64" width=175 style='width:131pt'>含義</td>
<td class="xl64" width=177 style='width:133pt'>命令選項</td>
<td class="xl64" width=185 style='width:139pt'>說明</td>
</tr>
<tr height=39 style='height:29.0pt'>
<td rowspan=3 height=119 class="xl69" width=87 style='border-bottom:1.0pt
height:89.0pt;border-top:none;width:65pt'>consumerConnec tion</td>
<td rowspan=3 class="xl72" width=87 style='border-bottom:1.0pt
border-top:none;width:65pt'>查詢 Consumer 的網絡連接</td>
<td class="xl67" width=87 style='width:65pt'>-g</td>
<td class="xl68" width=87 style='width:65pt'>消費者所屬組名</td>
</tr>
<tr height=57 style='height:43.0pt'>
<td height=57 class="xl67" width=87 style='height:43.0pt;width:65pt'>-n</td>
<td class="xl68" width=87 style='width:65pt'>NameServer 服務地址,格式 ip:port</td>
</tr>
<tr height=23 style='height:17.0pt'>
<td height=23 class="xl67" width=87 style='height:17.0pt;width:65pt'>-h</td>
<td class="xl68" width=87 style='width:65pt'>打印幫助</td>
</tr>
<tr height=39 style='height:29.0pt'>
<td rowspan=4 height=142 class="xl69" width=87 style='border-bottom:1.0pt
height:106.0pt;border-top:none;width:65pt'>producerConnec tion</td>
<td rowspan=4 class="xl72" width=87 style='border-bottom:1.0pt
border-top:none;width:65pt'>查詢 Producer 的網絡連接</td>
<td class="xl67" width=87 style='width:65pt'>-g</td>
<td class="xl68" width=87 style='width:65pt'>生產者所屬組名</td>
</tr>
<tr height=23 style='height:17.0pt'>
<td height=23 class="xl67" width=87 style='height:17.0pt;width:65pt'>-t</td>
<td class="xl68" width=87 style='width:65pt'>主題名稱</td>
</tr>
<tr height=57 style='height:43.0pt'>
<td height=57 class="xl67" width=87 style='height:43.0pt;width:65pt'>-n</td>
<td class="xl68" width=87 style='width:65pt'>NameServer 服務地址,格式 ip:port</td>
</tr>
<tr height=23 style='height:17.0pt'>
<td height=23 class="xl67" width=87 style='height:17.0pt;width:65pt'>-h</td>
<td class="xl68" width=87 style='width:65pt'>打印幫助</td>
</tr>
</table>
#### 2.7 NameServer相關
<table border=0 cellpadding=0 cellspacing=0 width=714>
<col width=177>
<col width=175>
<col width=177>
<col width=185>
<tr height=23 style='height:17.0pt'>
<td height=23 class="xl63" width=177 style='height:17.0pt;width:133pt'>名稱</td>
<td class="xl64" width=175 style='width:131pt'>含義</td>
<td class="xl64" width=177 style='width:133pt'>命令選項</td>
<td class="xl64" width=185 style='width:139pt'>說明</td>
</tr>
<tr height=21 style='height:16.0pt'>
<td rowspan=5 height=143 class="xl69" width=87 style='border-bottom:1.0pt
height:100pt;border-top:none;width:65pt'>updateKvConfig</td>
<td rowspan=5 class="xl72" width=87 style='border-bottom:1.0pt
border-top:none;width:65pt'>更新NameServer的kv配置,目前還未使用</td>
<td class="xl75" width=87 style='width:65pt'>-s</td>
<td class="xl76" width=87 style='width:65pt'>命名空間</td>
</tr>
<tr height=21 style='height:16.0pt'>
<td height=21 class="xl75" width=87 style='height:16.0pt;width:65pt'>-k</td>
<td class="xl75" width=87 style='width:65pt'>key</td>
</tr>
<tr height=21 style='height:16.0pt'>
<td height=21 class="xl75" width=87 style='height:16.0pt;width:65pt'>-v</td>
<td class="xl75" width=87 style='width:65pt'>value</td>
</tr>
<tr height=57 style='height:43.0pt'>
<td height=57 class="xl67" width=87 style='height:43.0pt;width:65pt'>-n</td>
<td class="xl68" width=87 style='width:65pt'>NameServer 服務地址,格式 ip:port</td>
</tr>
<tr height=23 style='height:17.0pt'>
<td height=23 class="xl67" width=87 style='height:17.0pt;width:65pt'>-h</td>
<td class="xl68" width=87 style='width:65pt'>打印幫助</td>
</tr>
<tr height=23 style='height:17.0pt'>
<td rowspan=4 height=126 class="xl69" width=87 style='border-bottom:1.0pt
height:94.0pt;border-top:none;width:65pt'>deleteKvConfig</td>
<td rowspan=4 class="xl72" width=87 style='border-bottom:1.0pt
border-top:none;width:65pt'>刪除NameServer的kv配置</td>
<td class="xl67" width=87 style='width:65pt'>-s</td>
<td class="xl68" width=87 style='width:65pt'>命名空間</td>
</tr>
<tr height=23 style='height:17.0pt'>
<td height=23 class="xl67" width=87 style='height:17.0pt;width:65pt'>-k</td>
<td class="xl67" width=87 style='width:65pt'>key</td>
</tr>
<tr height=57 style='height:43.0pt'>
<td height=57 class="xl67" width=87 style='height:43.0pt;width:65pt'>-n</td>
<td class="xl68" width=87 style='width:65pt'>NameServer 服務地址,格式 ip:port</td>
</tr>
<tr height=23 style='height:17.0pt'>
<td height=23 class="xl67" width=87 style='height:17.0pt;width:65pt'>-h</td>
<td class="xl68" width=87 style='width:65pt'>打印幫助</td>
</tr>
<tr height=57 style='height:43.0pt'>
<td rowspan=2 height=80 class="xl69" width=87 style='border-bottom:1.0pt
height:60.0pt;border-top:none;width:65pt'>getNamesrvConfig</td>
<td rowspan=2 class="xl72" width=87 style='border-bottom:1.0pt
border-top:none;width:65pt'>獲取NameServer配置</td>
<td class="xl67" width=87 style='width:65pt'>-n</td>
<td class="xl68" width=87 style='width:65pt'>NameServer 服務地址,格式 ip:port</td>
</tr>
<tr height=23 style='height:17.0pt'>
<td height=23 class="xl67" width=87 style='height:17.0pt;width:65pt'>-h</td>
<td class="xl68" width=87 style='width:65pt'>打印幫助</td>
</tr>
<tr height=57 style='height:43.0pt'>
<td rowspan=4 height=126 class="xl69" width=87 style='border-bottom:1.0pt
height:94.0pt;border-top:none;width:65pt'>updateNamesrvConfig</td>
<td rowspan=4 class="xl72" width=87 style='border-bottom:1.0pt
border-top:none;width:65pt'>修改NameServer配置</td>
<td class="xl67" width=87 style='width:65pt'>-n</td>
<td class="xl68" width=87 style='width:65pt'>NameServer 服務地址,格式 ip:port</td>
</tr>
<tr height=23 style='height:17.0pt'>
<td height=23 class="xl67" width=87 style='height:17.0pt;width:65pt'>-h</td>
<td class="xl68" width=87 style='width:65pt'>打印幫助</td>
</tr>
<tr height=23 style='height:17.0pt'>
<td height=23 class="xl67" width=87 style='height:17.0pt;width:65pt'>-k</td>
<td class="xl67" width=87 style='width:65pt'>key</td>
</tr>
<tr height=23 style='height:17.0pt'>
<td height=23 class="xl67" width=87 style='height:17.0pt;width:65pt'>-v</td>
<td class="xl67" width=87 style='width:65pt'>value</td>
</tr>
</table>
#### 2.8 其他
<table border=0 cellpadding=0 cellspacing=0 width=714>
<col width=177>
<col width=175>
<col width=177>
<col width=185>
<tr height=23 style='height:17.0pt'>
<td height=23 class="xl63" width=177 style='height:17.0pt;width:133pt'>名稱</td>
<td class="xl64" width=175 style='width:131pt'>含義</td>
<td class="xl64" width=177 style='width:133pt'>命令選項</td>
<td class="xl64" width=185 style='width:139pt'>說明</td>
</tr>
<tr height=57 style='height:43.0pt'>
<td rowspan=2 height=80 class="xl69" width=87 style='border-bottom:1.0pt
height:60.0pt;border-top:none;width:65pt'>startMonitoring</td>
<td rowspan=2 class="xl71" width=87 style='border-bottom:1.0pt
border-top:none;width:65pt'>開啟監控進程,監控消息誤刪、重試隊列消息數等</td>
<td class="xl67" width=87 style='width:65pt'>-n</td>
<td class="xl68" width=87 style='width:65pt'>NameServer 服務地址,格式 ip:port</td>
</tr>
<tr height=23 style='height:17.0pt'>
<td height=23 class="xl67" width=87 style='height:17.0pt;width:65pt'>-h</td>
<td class="xl68" width=87 style='width:65pt'>打印幫助</td>
</tr>
</table>
### 3 運維常見問題
#### 3.1 RocketMQ的mqadmin命令報錯問題
> 問題描述:有時候在部署完RocketMQ集群后,嘗試執行“mqadmin”一些運維命令,會出現下面的異常信息:
>
> ```java
> org.apache.rocketmq.remoting.exception.RemotingConnectException: connect to <null> failed
> ```
解決方法:可以在部署RocketMQ集群的虛擬機上執行`export NAMESRV_ADDR=ip:9876`(ip指的是集群中部署NameServer組件的機器ip地址)命令之后再使用“mqadmin”的相關命令進行查詢,即可得到結果。
#### 3.2 RocketMQ生產端和消費端版本不一致導致不能正常消費的問題
> 問題描述:同一個生產端發出消息,A消費端可消費,B消費端卻無法消費,rocketMQ Console中出現:
>
> ```java
> Not found the consumer group consume stats, because return offset table is empty, maybe the consumer not consume any message的異常消息。
> ```
解決方案:RocketMQ 的jar包:rocketmq-client等包應該保持生產端,消費端使用相同的version。
#### 3.3 新增一個topic的消費組時,無法消費歷史消息的問題
> 問題描述:當同一個topic的新增消費組啟動時,消費的消息是當前的offset的消息,並未獲取歷史消息。
解決方案:rocketmq默認策略是從消息隊列尾部,即跳過歷史消息。如果想消費歷史消息,則需要設置:`org.apache.rocketmq.client.consumer.DefaultMQPushConsumer#setConsumeFromWhere`。常用的有以下三種配置:
- 默認配置,一個新的訂閱組第一次啟動從隊列的最后位置開始消費,后續再啟動接着上次消費的進度開始消費,即跳過歷史消息;
```java
consumer.setConsumeFromWhere(ConsumeFromWhere.CONSUME_FROM_LAST_OFFSET);
```
- 一個新的訂閱組第一次啟動從隊列的最前位置開始消費,后續再啟動接着上次消費的進度開始消費,即消費Broker未過期的歷史消息;
```java
consumer.setConsumeFromWhere(ConsumeFromWhere.CONSUME_FROM_FIRST_OFFSET);
```
- 一個新的訂閱組第一次啟動從指定時間點開始消費,后續再啟動接着上次消費的進度開始消費,和consumer.setConsumeTimestamp()配合使用,默認是半個小時以前;
```java
consumer.setConsumeFromWhere(ConsumeFromWhere.CONSUME_FROM_TIMESTAMP);
```
#### 3.4 如何開啟從Slave讀數據功能
在某些情況下,Consumer需要將消費位點重置到1-2天前,這時在內存有限的Master Broker上,CommitLog會承載比較重的IO壓力,影響到該Broker的其它消息的讀與寫。可以開啟`slaveReadEnable=true`,當Master Broker發現Consumer的消費位點與CommitLog的最新值的差值的容量超過該機器內存的百分比(`accessMessageInMemoryMaxRatio=40%`),會推薦Consumer從Slave Broker中去讀取數據,降低Master Broker的IO。
#### 3.5 性能調優問題
異步刷盤建議使用自旋鎖,同步刷盤建議使用重入鎖,調整Broker配置項`useReentrantLockWhenPutMessage`,默認為false;異步刷盤建議開啟`TransientStorePoolEnable`;建議關閉transferMsgByHeap,提高拉消息效率;同步刷盤建議適當增大`sendMessageThreadPoolNums`,具體配置需要經過壓測。
#### 3.6 在RocketMQ中msgId和offsetMsgId的含義與區別
使用RocketMQ完成生產者客戶端消息發送后,通常會看到如下日志打印信息:
```java
SendResult [sendStatus=SEND_OK, msgId=0A42333A0DC818B4AAC246C290FD0000, offsetMsgId=0A42333A00002A9F000000000134F1F5, messageQueue=MessageQueue [topic=topicTest1, BrokerName=mac.local, queueId=3], queueOffset=4]
```
- msgId,對於客戶端來說msgId是由客戶端producer實例端生成的,具體來說,調用方法`MessageClientIDSetter.createUniqIDBuffer()`生成唯一的Id;
- offsetMsgId,offsetMsgId是由Broker服務端在寫入消息時生成的(采用”IP地址+Port端口”與“CommitLog的物理偏移量地址”做了一個字符串拼接),其中offsetMsgId就是在RocketMQ控制台直接輸入查詢的那個messageId。