[Command line operations related to Ali's RocketMQ]

1. Start RocketMQ

1) Start NameServer first

nohup sh mqnamesrv > ns.log 2>&1 &

What actually starts is the main() corresponding to com.alibaba.rocketmq.namesrv.NamesrvStartup

Remark runserver.sh is a bunch of JVM parameters

 

 

2) Start the Broker again, the default port is 9876

nohup sh mqbroker -n IP:Port > bk.log 2>&1 &

What actually starts is the main() corresponding to com.alibaba.rocketmq.broker.BrokerStartup

Remark runbroker.sh is a bunch of JVM parameters

 

Summary: One-step startup only needs to run sh play.sh

[root@master bin]# sh play.sh

Start Name Server and Broker Successfully, 192.168.1.103:9876


 

 

2. View help

[root@master bin]# sh mqadmin

The most commonly used mqadmin commands are:

   updateTopic          Update or create topic

   deleteTopic          Delete topic from broker and NameServer.

   updateSubGroup       Update or create subscription group

   deleteSubGroup       Delete subscription group from broker.

   updateBrokerConfig   Update broker's config

   topicRoute           Examine topic route info

   topicStatus          Examine topic Status info

   brokerStatus         Fetch broker runtime status data

   queryMsgById         Query Message by Id

   queryMsgByKey        Query Message by Key

   queryMsgByOffset     Query Message by offset

   printMsg             Print Message Detail

   producerConnection   Query producer's socket connection and client version

   consumerConnection   Query consumer's socket connection, client version and subscription

   consumerProgress     Query consumers's progress, speed

   consumerStatus       Query consumer's internal data structure

   cloneGroupOffset     clone offset from other group.

   clusterList          List all of clusters

   topicList            Fetch all topic list from name server

   updateKvConfig       Create or update KV config.

   deleteKvConfig       Delete KV config.

   wipeWritePerm        Wipe write perm of broker in all name server

   resetOffsetByTime    Reset consumer offset by timestamp(without client restart).

   updateOrderConf      Create or update or delete order conf

   cleanExpiredCQ       Clean expired ConsumeQueue on broker.

   startMonitoring      Start Monitoring

   checkMsg             Check Message Store

   statsAll             Topic and Consumer tps stats

   syncDocs             Synchronize wiki and issue to github.com

 

See 'mqadmin help <command>' for more information on a specific command.

 

 

1) View the topic list

[root@master bin]# sh mqadmin help topicList

usage: mqadmin topicList [-c] [-h] [-n <arg>]

 -c,--clusterModel        clusterModel

 -h,--help                Print help

 -n,--namesrvAddr <arg>   Name server address list, eg: 192.168.0.1:9876;192.168.0.2:9876

[root@master bin]# sh mqadmin topicList -n 192.168.1.103:9876

BenchmarkTest

TopicTest

DefaultCluster

SELF_TEST_TOPIC

%RETRY%please_rename_unique_group_name_4

TBW102

master

OFFSET_MOVED_EVENT

[root@master bin]# 

 

 

 

 

2) Create Topic

[root@master bin]# sh mqadmin help updateTopic

usage: mqadmin updateTopic [-b <arg>] [-c <arg>] [-h] [-n <arg>] [-o <arg>] [-p <arg>] [-r <arg>] [-s <arg>]

       -t <arg> [-u <arg>] [-w <arg>]

 -b,--brokerAddr <arg>       create topic to which broker

 -c,--clusterName <arg>      create topic to which cluster

 -h,--help                   Print help

 -n,--namesrvAddr <arg>      Name server address list, eg: 192.168.0.1:9876;192.168.0.2:9876

 -o,--order <arg>            set topic's order(true|false

 -p,--perm <arg>             set topic's permission(2|4|6), intro[2:R; 4:W; 6:RW]

 -r,--readQueueNums <arg>    set read queue nums

 -s,--hasUnitSub <arg>       has unit sub (true|false

 -t,--topic <arg>            topic name

 -u,--unit <arg>             is unit topic (true|false

 -w,--writeQueueNums <arg>   set write queue nums

[root@m bin]# sh mqadmin updateTopic -n 192.168.1.103:9876 -b 192.168.1.103:10911 -t gaojingsong  

create topic to 192.168.1.103:10911 success.

TopicConfig [topicName=gaojingsong, readQueueNums=8, writeQueueNums=8, perm=RW-, topicFilterType=SINGLE_TAG, topicSysFlag=0, order=false]

[root@master bin]# sh mqadmin topicList -n 192.168.1.103:9876

BenchmarkTest

TopicTest

DefaultCluster

SELF_TEST_TOPIC

%RETRY%please_rename_unique_group_name_4

TBW102

gaojingsong

master

OFFSET_MOVED_EVENT

 

 

 

 

 

3) Statistics topic information

[root@master bin]# sh mqadmin help topicStatus

usage: mqadmin topicStatus [-h] [-n <arg>] -t <arg>

 -h,--help                Print help

 -n,--namesrvAddr <arg>   Name server address list, eg: 192.168.0.1:9876;192.168.0.2:9876

 -t,--topic <arg>         topic name

[root@master bin]# sh mqadmin  topicStatus -n  192.168.1.103:9876 -t gaojingsong

#Broker Name                      #QID  #Min Offset           #Max Offset     #Last Updated

master                            0     0                     0                       

master                            1     0                     0                       

master                            2     0                     0                       

master                            3     0                     0                       

master                            4     0                     0                       

master                            5     0                     0                       

master                            6     0                     0                       

master                            7     0                     0                       

[root@master bin]# 

 

 

 

4) View topicRoute information

[root@master bin]# sh mqadmin help topicRoute

usage: mqadmin topicRoute [-h] [-n <arg>] -t <arg>

 -h,--help                Print help

 -n,--namesrvAddr <arg>   Name server address list, eg: 192.168.0.1:9876;192.168.0.2:9876

 -t,--topic <arg>         topic name

[root@master bin]# sh mqadmin  topicRoute     -n  192.168.1.103:9876 -t gaojingsong

{

        "brokerDatas":[

                {

                        "brokerAddrs":{0:"192.168.1.103:10911"

                        },

                        "brokerName":"master"

                }

        ],

        "filterServerTable":{},

        "queueDatas":[

                {

                        "brokerName":"master",

                        "perm":6,

                        "readQueueNums":8,

                        "topicSynFlag":0,

                        "writeQueueNums":8

                }

        ]

}

[root@master bin]# 

 

4) View all topic information

[root@master bin]# sh mqadmin help statsAll

usage: mqadmin statsAll [-a] [-h] [-n <arg>]

 -a,--activeTopic         print active topic only

 -h,--help                Print help

 -n,--namesrvAddr <arg>   Name server address list, eg: 192.168.0.1:9876;192.168.0.2:9876

[root @ master bin] # sh mqadmin statsAll -n 192.168.1.103:9876

#Topic                #Consumer Group                         #InTPS     #OutTPS    #InMsg24Hour  #OutMsg24Hour

BenchmarkTest                                                             0.00                          0    NO_CONSUMER

TopicTest             please_rename_unique_group_name_        0.00        0.00              0              0

DefaultCluster                                                            0.00                          0    NO_CONSUMER

SELF_TEST_TOPIC                                                           0.00                          0    NO_CONSUMER

TBW102                                                                    0.00                          0    NO_CONSUMER

gaojingsong 0.00 0 NO_CONSUMER

master                                                                    0.00                          0    NO_CONSUMER

OFFSET_MOVED_EVENT                                                        0.00                          0    NO_CONSUMER

[root@master bin]# 

 

 

 

5) View all clusterList information

[root@master bin]# sh mqadmin help clusterList

usage: mqadmin clusterList [-h] [-m] [-n <arg>]

 -h,--help                Print help

 -m,--moreStats           Print more stats

 -n,--namesrvAddr <arg>   Name server address list, eg: 192.168.0.1:9876;192.168.0.2:9876

[root@master bin]# sh mqadmin  clusterList   -n  192.168.1.103:9876

#Cluster Name     #Broker Name                      #BID  #Addr                  #Version                    #InTPS     #OutTPS

DefaultCluster    master                            0     192.168.1.103:10911    V3_2_6                        0.00        0.00

[root@master bin]# 

 

 

5) Delete related Topic

[root@master bin]# sh mqadmin help deleteTopic

usage: mqadmin deleteTopic -c <arg> [-h] [-n <arg>] -t <arg>

 -c,--clusterName <arg>   delete topic from which cluster

 -h,--help                Print help

 -n,--namesrvAddr <arg>   Name server address list, eg: 192.168.0.1:9876;192.168.0.2:9876

 -t,--topic <arg>         topic name

[root@master bin]# sh mqadmin  deleteTopic   -n  192.168.1.103:9876 -t TopicTest

usage: mqadmin deleteTopic -c <arg> [-h] [-n <arg>] -t <arg>

 -c,--clusterName <arg>   delete topic from which cluster

 -h,--help                Print help

 -n,--namesrvAddr <arg>   Name server address list, eg: 192.168.0.1:9876;192.168.0.2:9876

 -t,--topic <arg>         topic name

[root@master bin]# sh mqadmin  deleteTopic   -n  192.168.1.103:9876 -c  DefaultCluster  -t TopicTest

delete topic [TopicTest] from cluster [DefaultCluster] success.

delete topic [TopicTest] from NameServer success.

[root @ master bin] # sh mqadmin statsAll -n 192.168.1.103:9876

#Topic                            #Consumer Group                       #InTPS     #OutTPS   #InMsg24Hour  #OutMsg24Hour

BenchmarkTest                                                             0.00                          0    NO_CONSUMER

DefaultCluster                                                            0.00                          0    NO_CONSUMER

SELF_TEST_TOPIC                                                           0.00                          0    NO_CONSUMER

TBW102                                                                    0.00                          0    NO_CONSUMER

gaojingsong 0.00 0 NO_CONSUMER

master                                                                    0.00                          0    NO_CONSUMER

OFFSET_MOVED_EVENT                                                        0.00                          0    NO_CONSUMER

[root@master bin]# 

 

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=327100637&siteId=291194637