目录
本文导读
环境说明
RocketMQ 下载
从 Apache 下载
从 GitHub 下载
RocketMQ 安装
文件上传
项目解压
编译部署
RocketMQ 操作
启动 NameServer
启动 Broker
内存分配失败解决办法
发送消息
接收消息
关闭服务器
常用命令
The following softwares are assumed installed:
- 64bit OS, Linux/Unix/Mac is recommended;
- 64bit JDK 1.8+;
- Maven 3.2.x
- Git (可不使用)
[root@localhost ~]# lsb_release -a
LSB Version: :core-4.1-amd64:core-4.1-noarch
Distributor ID: CentOS
Description: CentOS Linux release 7.2.1511 (Core)
Release: 7.2.1511
Codename: Core
[root@localhost ~]#
[root@localhost ~]# java -version
java version "1.8.0_172"
Java(TM) SE Runtime Environment (build 1.8.0_172-b11)
Java HotSpot(TM) 64-Bit Server VM (build 25.172-b11, mixed mode)
[root@localhost ~]#
[root@localhost conf]# mvn -v
Apache Maven 3.5.4 (1edded0938998edf8bf061f1ceb3cfdeccf443fe; 2018-06-18T02:33:14+08:00)
Maven home: /usr/local/apache-maven-3.5.4
Java version: 1.8.0_172, vendor: Oracle Corporation, runtime: /usr/local/jdk1.8.0_172/jre
Default locale: zh_CN, platform encoding: UTF-8
OS name: "linux", version: "3.10.0-327.el7.x86_64", arch: "amd64", family: "unix"
[root@localhost conf]#
下面提供两种下载方式,即可以从 Apache 官网下载,也可以从 gitHub 上进行下载。
[root@localhost local]# yum list unzip
已加载插件:fastestmirror
Repodata is over 2 weeks old. Install yum-cron? Or run: yum makecache fast
Loading mirror speeds from cached hostfile
* base: mirrors.aliyun.com
* extras: mirrors.aliyun.com
* updates: centos.ustc.edu.cn
可安装的软件包
unzip.x86_64 6.0-19.el7 base
[root@localhost local]#
[root@localhost local]# yum install unzip.x86_64
已加载插件:fastestmirror
Repodata is over 2 weeks old. Install yum-cron? Or run: yum makecache fast
base | 3.6 kB 00:00:00
extras | 3.4 kB 00:00:00
mysql-connectors-community | 2.5 kB 00:00:00
mysql-tools-community | 2.5 kB 00:00:00
mysql80-community | 2.5 kB 00:00:00
updates | 3.4 kB 00:00:00
(1/5): extras/7/x86_64/primary_db | 173 kB 00:00:00
(2/5): mysql-tools-community/x86_64/primary_db | 45 kB 00:00:01
(3/5): mysql80-community/x86_64/primary_db | 26 kB 00:00:01
(4/5): mysql-connectors-community/x86_64/primary_db
.....
Running transaction
正在安装 : unzip-6.0-19.el7.x86_64 1/1
验证中 : unzip-6.0-19.el7.x86_64 1/1
已安装:
unzip.x86_64 0:6.0-19.el7
完毕!
[root@localhost local]#
[root@localhost local]# unzip rocketmq-all-4.3.0-source-release.zip
.......
inflating: rocketmq-all-4.3.0/tools/src/main/java/org/apache/rocketmq/tools/command/message/QueryMsgByKeySubCommand.java
inflating: rocketmq-all-4.3.0/tools/src/main/java/org/apache/rocketmq/tools/command/namesrv/UpdateKvConfigCommand.java
inflating: rocketmq-all-4.3.0/tools/src/main/java/org/apache/rocketmq/tools/command/topic/DeleteTopicSubCommand.java
inflating: rocketmq-all-4.3.0/tools/src/main/java/org/apache/rocketmq/tools/command/topic/TopicListSubCommand.java
inflating: rocketmq-all-4.3.0/tools/src/main/java/org/apache/rocketmq/tools/command/topic/UpdateOrderConfCommand.java
inflating: rocketmq-all-4.3.0/tools/src/main/java/org/apache/rocketmq/tools/monitor/DefaultMonitorListener.java
inflating: rocketmq-all-4.3.0/tools/src/main/java/org/apache/rocketmq/tools/monitor/FailedMsgs.java
inflating: rocketmq-all-4.3.0/tools/src/test/java/org/apache/rocketmq/tools/command/message/ConsumeMessageCommandTest.java
inflating: rocketmq-all-4.3.0/tools/s
[root@localhost local]#
[root@localhost local]# ls -l
总用量 1588
drwxr-xr-x. 2 root root 6 8月 12 2015 bin
drwxr-xr-x. 2 root root 6 8月 12 2015 etc
drwxr-xr-x. 2 root root 6 8月 12 2015 games
drwxr-xr-x. 2 root root 6 8月 12 2015 include
drwxr-xr-x. 8 10 143 4096 3月 29 12:55 jdk1.8.0_172
drwxr-xr-x. 2 root root 6 8月 12 2015 lib
drwxr-xr-x. 2 root root 6 8月 12 2015 lib64
drwxr-xr-x. 2 root root 6 8月 12 2015 libexec
drwxr-xr-x. 11 root root 4096 7月 6 00:33 nginx
drwxr-xr-x. 9 1001 1001 4096 7月 6 03:34 nginx-1.15.0
drwxr-xr-x. 20 root root 4096 7月 26 12:13 rocketmq-all-4.3.0
-rw-r--r--. 1 root root 1605734 8月 9 23:19 rocketmq-all-4.3.0-source-release.zip
drwxr-xr-x. 2 root root 6 8月 12 2015 sbin
drwxr-xr-x. 5 root root 46 7月 3 20:18 share
drwxr-xr-x. 2 root root 6 8月 12 2015 src
drwxr-xr-x. 4 root root 54 7月 6 02:12 tomcat_1.8
[root@localhost local]# du -sh rocketmq-all-4.3.0
6.8M rocketmq-all-4.3.0
[root@localhost local]# du -sh rocketmq-all-4.3.0-source-release.zip
1.6M rocketmq-all-4.3.0-source-release.zip
[root@localhost local]#
[root@localhost rocketmq-all-4.3.0]# ls -l
总用量 60
drwxr-xr-x. 3 root root 30 7月 26 12:13 broker
-rw-r--r--. 1 root root 997 7月 26 12:13 BUILDING
drwxr-xr-x. 3 root root 30 7月 26 12:13 client
drwxr-xr-x. 3 root root 30 7月 26 12:13 common
-rw-r--r--. 1 root root 1997 7月 26 12:13 CONTRIBUTING.md
-rw-r--r--. 1 root root 271 7月 26 12:13 DEPENDENCIES
drwxr-xr-x. 2 root root 33 7月 26 12:13 dev
drwxr-xr-x. 5 root root 4096 7月 26 12:13 distribution
drwxr-xr-x. 3 root root 30 7月 26 12:13 example
drwxr-xr-x. 3 root root 30 7月 26 12:13 filter
-rw-r--r--. 1 root root 11365 7月 26 12:13 LICENSE
drwxr-xr-x. 3 root root 30 7月 26 12:13 logappender
drwxr-xr-x. 3 root root 30 7月 26 12:13 logging
drwxr-xr-x. 3 root root 30 7月 26 12:13 namesrv
-rw-r--r--. 1 root root 168 7月 26 12:13 NOTICE
drwxr-xr-x. 3 root root 30 7月 26 12:13 openmessaging
-rw-r--r--. 1 root root 23729 7月 26 12:13 pom.xml
-rw-r--r--. 1 root root 2426 7月 26 12:13 README.md
drwxr-xr-x. 3 root root 30 7月 26 12:13 remoting
drwxr-xr-x. 3 root root 30 7月 26 12:13 srvutil
drwxr-xr-x. 3 root root 30 7月 26 12:13 store
drwxr-xr-x. 3 root root 71 7月 26 12:13 style
drwxr-xr-x. 3 root root 30 7月 26 12:13 test
drwxr-xr-x. 3 root root 30 7月 26 12:13 tools
[root@localhost rocketmq-all-4.3.0]#
> unzip rocketmq-all-4.3.0-source-release.zip (解压)
> cd rocketmq-all-4.3.0/ (进入解压目录)
> mvn -Prelease-all -DskipTests clean install -U (编译部署)
> cd distribution/target/apache-rocketmq (进入指定目录)
[INFO] Reactor Summary:
[INFO]
[INFO] Apache RocketMQ 4.3.0 4.3.0 ........................ SUCCESS [02:48 min]
[INFO] rocketmq-logging 4.3.0 ............................. SUCCESS [ 17.417 s]
[INFO] rocketmq-remoting 4.3.0 ............................ SUCCESS [ 11.507 s]
[INFO] rocketmq-common 4.3.0 .............................. SUCCESS [ 8.931 s]
[INFO] rocketmq-client 4.3.0 .............................. SUCCESS [ 14.016 s]
[INFO] rocketmq-store 4.3.0 ............................... SUCCESS [ 8.584 s]
[INFO] rocketmq-srvutil 4.3.0 ............................. SUCCESS [ 2.288 s]
[INFO] rocketmq-filter 4.3.0 .............................. SUCCESS [ 2.438 s]
[INFO] rocketmq-broker 4.3.0 .............................. SUCCESS [ 7.253 s]
[INFO] rocketmq-tools 4.3.0 ............................... SUCCESS [ 3.480 s]
[INFO] rocketmq-namesrv 4.3.0 ............................. SUCCESS [ 1.642 s]
[INFO] rocketmq-logappender 4.3.0 ......................... SUCCESS [ 2.533 s]
[INFO] rocketmq-openmessaging 4.3.0 ....................... SUCCESS [ 3.220 s]
[INFO] rocketmq-example 4.3.0 ............................. SUCCESS [ 1.757 s]
[INFO] rocketmq-test 4.3.0 ................................ SUCCESS [ 5.503 s]
[INFO] rocketmq-distribution 4.3.0 4.3.0 .................. SUCCESS [ 51.228 s]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 05:13 min
[INFO] Finished at: 2018-08-10T01:14:58+08:00
[INFO] ------------------------------------------------------------------------
[root@localhost rocketmq-all-4.3.0]#
[root@localhost apache-rocketmq]# pwd
/usr/local/rocketmq-all-4.3.0/distribution/target/apache-rocketmq
[root@localhost apache-rocketmq]# ls -l
总用量 40
drwxr-xr-x. 2 root root 79 8月 10 01:14 benchmark
drwxr-xr-x. 2 root root 4096 8月 10 01:14 bin
drwxr-xr-x. 5 root root 4096 7月 26 12:13 conf
drwxr-xr-x. 2 root root 4096 8月 10 01:14 lib
-rw-r--r--. 1 root root 17336 7月 26 12:13 LICENSE
-rw-r--r--. 1 root root 1337 7月 26 12:13 NOTICE
-rw-r--r--. 1 root root 2426 7月 26 12:13 README.md
[root@localhost apache-rocketmq]#
# 启动命令,并且常驻内存
$ nohup sh bin/mqnamesrv &
# 查看启动日志能看到:The Name Server boot success字样则成功
$ tail -f ~/logs/rocketmqlogs/namesrv.log
nohup sh mqnamesrv & :属于后台启动
sh mqnamesrv :属于终端启动,直接输出日志信息,按 ctrl+c 可直接关闭退出
[root@localhost apache-rocketmq]# pwd
/usr/local/rocketmq-all-4.3.0/distribution/target/apache-rocketmq
[root@localhost apache-rocketmq]# nohup sh bin/mqnamesrv &
[1] 5865
[root@localhost apache-rocketmq]# nohup: 忽略输入并把输出追加到"nohup.out"
tail -f ~/logs/rocketmqlogs/namesrv.log
2018-08-10 01:29:12 INFO main - tls.client.keyPath = null
2018-08-10 01:29:12 INFO main - tls.client.keyPassword = null
2018-08-10 01:29:12 INFO main - tls.client.certPath = null
2018-08-10 01:29:12 INFO main - tls.client.authServer = false
2018-08-10 01:29:12 INFO main - tls.client.trustCertPath = null
2018-08-10 01:29:13 INFO main - Using OpenSSL provider
2018-08-10 01:29:14 INFO main - SSLContext created for server
2018-08-10 01:29:14 INFO NettyEventExecutor - NettyEventExecutor service started
2018-08-10 01:29:14 INFO main - The Name Server boot success. serializeType=JSON
2018-08-10 01:29:14 INFO FileWatchService - FileWatchService service started
# 启动命令,并且常驻内存:注意ip地址要配置成为服务的ip地址,保证地址以及端口能够访问
> nohup sh bin/mqbroker -n localhost:9876 &
# 查看启动日志
> tail -f ~/logs/rocketmqlogs/broker.log
nohup sh bin/mqbroker -n localhost:9876 & :属于后台启动
sh bin/mqbroker -n localhost:9876 :属于终端启动,直接输出日志信息,按 ctrl+c 可直接关闭退出
[root@localhost apache-rocketmq]# nohup sh bin/mqbroker -n localhost:9876 &
[1] 7202
[root@localhost apache-rocketmq]# nohup: 忽略输入并把输出追加到"nohup.out"
Java HotSpot(TM) 64-Bit Server VM warning: INFO: os::commit_memory(0x00000005c0000000, 8589934592, 0) failed; error='Cannot allocate memory' (errno=12)
#
# There is insufficient memory for the Java Runtime Environment to continue.
# Native memory allocation (mmap) failed to map 8589934592 bytes for committing reserved memory.
# An error report file with more information is saved as:
# /usr/local/rocketmq-all-4.3.0/distribution/target/apache-rocketmq/hs_err_pid7209.log
[root@localhost bin]# pwd
/usr/local/rocketmq-all-4.3.0/distribution/target/apache-rocketmq/bin
[root@localhost bin]# ls -l
总用量 136
-rwxr-xr-x. 1 root root 1654 7月 26 12:13 cachedog.sh
-rwxr-xr-x. 1 root root 845 7月 26 12:13 cleancache.sh
-rwxr-xr-x. 1 root root 1116 7月 26 12:13 cleancache.v1.sh
-rwxr-xr-x. 1 root root 1398 7月 26 12:13 mqadmin
-rwxr-xr-x. 1 root root 1029 7月 26 12:13 mqadmin.cmd
-rwxr-xr-x. 1 root root 1422 7月 26 12:13 mqadmin.xml
-rwxr-xr-x. 1 root root 1394 7月 26 12:13 mqbroker
-rwxr-xr-x. 1 root root 1084 7月 26 12:13 mqbroker.cmd
-rwxr-xr-x. 1 root root 1373 7月 26 12:13 mqbroker.numanode0
-rwxr-xr-x. 1 root root 1373 7月 26 12:13 mqbroker.numanode1
-rwxr-xr-x. 1 root root 1373 7月 26 12:13 mqbroker.numanode2
-rwxr-xr-x. 1 root root 1373 7月 26 12:13 mqbroker.numanode3
-rwxr-xr-x. 1 root root 1388 7月 26 12:13 mqbroker.xml
-rwxr-xr-x. 1 root root 1400 7月 26 12:13 mqfiltersrv
-rwxr-xr-x. 1 root root 1094 7月 26 12:13 mqfiltersrv.cmd
-rwxr-xr-x. 1 root root 1394 7月 26 12:13 mqfiltersrv.xml
-rwxr-xr-x. 1 root root 1396 7月 26 12:13 mqnamesrv
-rwxr-xr-x. 1 root root 1088 7月 26 12:13 mqnamesrv.cmd
-rwxr-xr-x. 1 root root 1390 7月 26 12:13 mqnamesrv.xml
-rwxr-xr-x. 1 root root 1571 7月 26 12:13 mqshutdown
-rwxr-xr-x. 1 root root 1398 7月 26 12:13 mqshutdown.cmd
-rwxr-xr-x. 1 root root 2222 7月 26 12:13 os.sh
-rwxr-xr-x. 1 root root 1148 7月 26 12:13 play.cmd
-rwxr-xr-x. 1 root root 1008 7月 26 12:13 play.sh
-rwxr-xr-x. 1 root root 772 7月 26 12:13 README.md
-rwxr-xr-x. 1 root root 819 7月 26 12:13 runbroker
-rwxr-xr-x. 1 root root 2206 7月 26 12:13 runbroker.cmd
-rwxr-xr-x. 1 root root 2928 8月 10 02:37 runbroker.sh
-rwxr-xr-x. 1 root root 1816 7月 26 12:13 runserver.cmd
-rwxr-xr-x. 1 root root 2551 8月 10 02:35 runserver.sh
-rwxr-xr-x. 1 root root 1156 7月 26 12:13 setcache.sh
-rwxr-xr-x. 1 root root 1408 7月 26 12:13 startfsrv.sh
-rwxr-xr-x. 1 root root 1601 7月 26 12:13 tools.cmd
-rwxr-xr-x. 1 root root 1870 7月 26 12:13 tools.sh
[root@localhost bin]#
#===========================================================================================
# JVM Configuration
#===========================================================================================
#JAVA_OPT="${JAVA_OPT} -server -Xms4g -Xmx4g -Xmn2g -XX:MetaspaceSize=128m -XX:MaxMetaspaceSize=320m"
JAVA_OPT="${JAVA_OPT} -server -Xms256m -Xmx256m -Xmn125m -XX:MetaspaceSize=128m -XX:MaxMetaspaceSize=320m"
JAVA_OPT="${JAVA_OPT} -XX:+UseConcMarkSweepGC -XX:+UseCMSCompactAtFullCollection -XX:CMSInitiatingOccupancyFraction=70 -XX:+CMSParallelRemarkEnabled -XX:SoftRefLRUPolicyMSPerMB=0 -XX:+CMSClassUnloadingEnabled -XX:SurvivorRatio=8 -XX:-UseParNewGC"
JAVA_OPT="${JAVA_OPT} -verbose:gc -Xloggc:/dev/shm/rmq_srv_gc.log -XX:+PrintGCDetails"
JAVA_OPT="${JAVA_OPT} -XX:-OmitStackTraceInFastThrow"
JAVA_OPT="${JAVA_OPT} -XX:-UseLargePages"
JAVA_OPT="${JAVA_OPT} -Djava.ext.dirs=${JAVA_HOME}/jre/lib/ext:${BASE_DIR}/lib"
#JAVA_OPT="${JAVA_OPT} -Xdebug -Xrunjdwp:transport=dt_socket,address=9555,server=y,suspend=n"
JAVA_OPT="${JAVA_OPT} ${JAVA_OPT_EXT}"
JAVA_OPT="${JAVA_OPT} -cp ${CLASSPATH}"
$JAVA ${JAVA_OPT} $@
#===========================================================================================
# JVM Configuration
#===========================================================================================
#JAVA_OPT="${JAVA_OPT} -server -Xms8g -Xmx8g -Xmn4g"
JAVA_OPT="${JAVA_OPT} -server -Xms256m -Xmx256m -Xmn125m"
JAVA_OPT="${JAVA_OPT} -XX:+UseG1GC -XX:G1HeapRegionSize=16m -XX:G1ReservePercent=25 -XX:InitiatingHeapOccupancyPercent=30 -XX:SoftRefLRUPolicyMSPerMB=0 -XX:SurvivorRatio=8"
JAVA_OPT="${JAVA_OPT} -verbose:gc -Xloggc:/dev/shm/mq_gc_%p.log -XX:+PrintGCDetails -XX:+PrintGCDateStamps -XX:+PrintGCApplicationStoppedTime -XX:+PrintAdaptiveSizePolicy"
JAVA_OPT="${JAVA_OPT} -XX:+UseGCLogFileRotation -XX:NumberOfGCLogFiles=5 -XX:GCLogFileSize=30m"
JAVA_OPT="${JAVA_OPT} -XX:-OmitStackTraceInFastThrow"
JAVA_OPT="${JAVA_OPT} -XX:+AlwaysPreTouch"
JAVA_OPT="${JAVA_OPT} -XX:MaxDirectMemorySize=15g"
JAVA_OPT="${JAVA_OPT} -XX:-UseLargePages -XX:-UseBiasedLocking"
JAVA_OPT="${JAVA_OPT} -Djava.ext.dirs=${JAVA_HOME}/jre/lib/ext:${BASE_DIR}/lib"
#JAVA_OPT="${JAVA_OPT} -Xdebug -Xrunjdwp:transport=dt_socket,address=9555,server=y,suspend=n"
JAVA_OPT="${JAVA_OPT} ${JAVA_OPT_EXT}"
JAVA_OPT="${JAVA_OPT} -cp ${CLASSPATH}"
[root@localhost apache-rocketmq]# nohup sh bin/mqbroker -n localhost:9876 &
[2] 7512
[1] 退出 1 nohup sh bin/mqbroker -n localhost:9876
[root@localhost apache-rocketmq]# nohup: 忽略输入并把输出追加到"nohup.out"
[root@localhost apache-rocketmq]# tail -f ~/logs/rocketmqlogs/broker.log
2018-08-10 02:39:20 WARN main - Load default discard message hook service: DefaultTransactionalMessageCheckListener
2018-08-10 02:39:21 INFO FileWatchService - FileWatchService service started
2018-08-10 02:39:21 INFO PullRequestHoldService - PullRequestHoldService service started
2018-08-10 02:39:23 INFO brokerOutApi_thread_1 - register broker to name server localhost:9876 OK
2018-08-10 02:39:23 INFO main - Start transaction service!
2018-08-10 02:39:23 INFO main - The broker[localhost.localdomain, 192.168.58.129:10911] boot success. serializeType=JSON and name server is localhost:9876
2018-08-10 02:39:30 INFO BrokerControllerScheduledThread1 - dispatch behind commit log 0 bytes
2018-08-10 02:39:30 INFO BrokerControllerScheduledThread1 - Slave fall behind master: 0 bytes
2018-08-10 02:39:33 INFO brokerOutApi_thread_2 - register broker to name server localhost:9876 OK
2018-08-10 02:40:03 INFO brokerOutApi_thread_3 - register broker to name server localhost:9876 OK
producer.setNamesrvAddr("ip:port")
:rocketmq.namesrv.addr
NAMESRV_ADDR
> export NAMESRV_ADDR=localhost:9876
> sh bin/tools.sh org.apache.rocketmq.example.quickstart.Producer
SendResult [sendStatus=SEND_OK, msgId= ...
[root@localhost apache-rocketmq]# export NAMESRV_ADDR=localhost:9876
[root@localhost apache-rocketmq]# sh bin/tools.sh org.apache.rocketmq.example.quickstart.Producer
Java HotSpot(TM) 64-Bit Server VM warning: ignoring option PermSize=128m; support was removed in 8.0
Java HotSpot(TM) 64-Bit Server VM warning: ignoring option MaxPermSize=128m; support was removed in 8.0
03:05:13.152 [main] DEBUG i.n.u.i.l.InternalLoggerFactory - Using SLF4J as the default logging framework
SendResult [sendStatus=SEND_OK, msgId=C0A83A8120207D4991AD2F02D2280000, offsetMsgId=C0A83A8100002A9F00000000000AFAC8, messageQueue=MessageQueue [topic=TopicTest, brokerName=localhost.localdomain, queueId=0], queueOffset=1000]
SendResult [sendStatus=SEND_OK, msgId=C0A83A8120207D4991AD2F02D2740001, offsetMsgId=C0A83A8100002A9F00000000000AFB7A, messageQueue=MessageQueue [topic=TopicTest, brokerName=localhost.localdomain, queueId=1], queueOffset=1000]
SendResult [sendStatus=SEND_OK, msgId=C0A83A8120207D4991AD2F02D27A0002, offsetMsgId=C0A83A8100002A9F00000000000AFC2C, messageQueue=MessageQueue [topic=TopicTest, brokerName=localhost.localdomain, queueId=2], queueOffset=1000]
.........................
> sh bin/tools.sh org.apache.rocketmq.example.quickstart.Consumer
ConsumeMessageThread_%d Receive New Messages: [MessageExt...
[root@localhost apache-rocketmq]# sh bin/tools.sh org.apache.rocketmq.example.quickstart.Consumer
ConsumeMessageThread_3 Receive New Messages: [MessageExt [queueId=0, storeSize=180, queueOffset=1031, sysFlag=0, bornTimestamp=1533841514766, bornHost=/192.168.58.129:46816, storeTimestamp=1533841514767, storeHost=/192.168.58.129:10911, msgId=C0A83A8100002A9F00000000000B518A, commitLogOffset=741770, bodyCRC=895437781, reconsumeTimes=0, preparedTransactionOffset=0, toString()=Message{topic='TopicTest', flag=0, properties={MIN_OFFSET=0, MAX_OFFSET=1250, CONSUME_START_TIME=1533841719674, UNIQ_KEY=C0A83A8120207D4991AD2F02D50E007C, WAIT=true, TAGS=TagA}, body=[72, 101, 108, 108, 111, 32, 82, 111, 99, 107, 101, 116, 77, 81, 32, 49, 50, 52], transactionId='null'}]]
ConsumeMessageThread_2 Receive New Messages: [MessageExt [queueId=0, storeSize=180, queueOffset=1030, sysFlag=0, bornTimestamp=1533841514746, bornHost=/192.168.58.129:46816, storeTimestamp=1533841514747, storeHost=/192.168.58.129:10911, msgId=C0A83A8100002A9F00000000000B4EBA, commitLogOffset=741050, bodyCRC=842174412, reconsumeTimes=0, preparedTransactionOffset=0, toString()=Message{topic='TopicTest', flag=0, properties={MIN_OFFSET=0, MAX_OFFSET=1250, CONSUME_START_TIME=1533841719669, UNIQ_KEY=C0A83A8120207D4991AD2F02D4FA0078, WAIT=true, TAGS=TagA}, body=[72, 101, 108, 108, 111, 32, 82, 111, 99, 107, 101, 116, 77, 81, 32, 49, 50, 48], transactionId='null'}]]
ConsumeMessageThread_20 Receive New Messages: [MessageExt [queueId=0, storeSize=179, queueOffset=1019, sysFlag=0, bornTimestamp=1533841514511, bornHost=/192.168.58.129:46816, storeTimestamp=1533841514515, storeHost=/192.168.58.129:10911, msgId=C0A83A8100002A9F00000000000B2FE2, commitLogOffset=733154, bodyCRC=884882597, reconsumeTimes=0, preparedTransactionOffset=0, toString()=Message{topic='TopicTest', flag=0, properties={MIN_OFFSET=0, MAX_OFFSET=1250, CONSUME_START_TIME=1533841719680, UNIQ_KEY=C0A83A8120207D4991AD2F02D40F004C, WAIT=true, TAGS=TagA}, body=[72, 101, 108, 108, 111, 32, 82, 111, 99, 107, 101, 116, 77, 81, 32, 55, 54], transactionId='null'}]]
...............
> sh bin/mqshutdown broker
The mqbroker(36695) is running...
Send shutdown request to mqbroker(36695) OK
> sh bin/mqshutdown namesrv
The mqnamesrv(36664) is running...
Send shutdown request to mqnamesrv(36664) OK
除了上面几个命令之外,还有如下一些较常用的命令,ip请以实际为准:
./mqadmin clusterList -n 127.0.0.1:9876
./mqadmin brokerStatus -n 127.0.0.1:9876 -b 172.20.1.138:10911
./mqadmin topicList -n 127.0.0.1:9876
./mqadmin topicStatus -n 127.0.0.1:9876 -t MyTopic
(换成想查询的 topic)./mqadmin topicRoute -n 127.0.0.1:9876 -t MyTopic