前期准备:安装JDK和maven,并配置好全局变量。
安装rocketMQ
1.下载源码并构建二进制文件
wget http://mirrors.hust.edu.cn/apache/rocketmq/4.3.1/rocketmq-all-4.3.1-source-release.zip
unzip rocketmq-all-4.3.1-source-release.zip
cd rocketmq-all-4.3.1
mvn -Prelease-all -DskipTests clean install -U
此处需要等待大概十几分钟。。。。。
[INFO] Building tar: /home/liyihui/rocketmq-all-4.3.1/distribution/target/apache-rocketmq.tar.gz
[INFO] Building zip: /home/liyihui/rocketmq-all-4.3.1/distribution/target/apache-rocketmq.zip
[INFO]
[INFO] --- jacoco-maven-plugin:0.7.8:prepare-agent-integration (default-prepare-agent-integration) @ rocketmq-distribution ---
[INFO] failsafeArgLine set to -javaagent:/root/.m2/repository/org/jacoco/org.jacoco.agent/0.7.8/org.jacoco.agent-0.7.8-runtime.jar=destfile=/home/liyihui/rocketmq-all-4.3.1/distribution/target/jacoco-it.exec
[INFO]
[INFO] --- maven-failsafe-plugin:2.19.1:integration-test (default) @ rocketmq-distribution ---
[INFO] Tests are skipped.
[INFO]
[INFO] --- maven-checkstyle-plugin:2.17:check (verify) @ rocketmq-distribution ---
[INFO] Starting audit...
Audit done.
[INFO]
[INFO] --- jacoco-maven-plugin:0.7.8:report (default-report) @ rocketmq-distribution ---
[INFO] Skipping JaCoCo execution due to missing execution data file.
[INFO]
[INFO] --- jacoco-maven-plugin:0.7.8:report-integration (default-report-integration) @ rocketmq-distribution ---
[INFO] Skipping JaCoCo execution due to missing execution data file.
[INFO]
[INFO] --- maven-install-plugin:2.5.2:install (default-install) @ rocketmq-distribution ---
[INFO] Installing /home/liyihui/rocketmq-all-4.3.1/distribution/pom.xml to /root/.m2/repository/org/apache/rocketmq/rocketmq-distribution/4.3.1/rocketmq-distribution-4.3.1.pom
[INFO] Installing /home/liyihui/rocketmq-all-4.3.1/distribution/target/apache-rocketmq.tar.gz to /root/.m2/repository/org/apache/rocketmq/rocketmq-distribution/4.3.1/rocketmq-distribution-4.3.1.tar.gz
[INFO] Installing /home/liyihui/rocketmq-all-4.3.1/distribution/target/apache-rocketmq.zip to /root/.m2/repository/org/apache/rocketmq/rocketmq-distribution/4.3.1/rocketmq-distribution-4.3.1.zip
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO]
[INFO] Apache RocketMQ 4.3.1 .............................. SUCCESS [11:27 min]
[INFO] rocketmq-logging 4.3.1 ............................. SUCCESS [ 23.853 s]
[INFO] rocketmq-remoting 4.3.1 ............................ SUCCESS [ 21.889 s]
[INFO] rocketmq-common 4.3.1 .............................. SUCCESS [ 4.253 s]
[INFO] rocketmq-client 4.3.1 .............................. SUCCESS [ 26.335 s]
[INFO] rocketmq-store 4.3.1 ............................... SUCCESS [ 16.791 s]
[INFO] rocketmq-srvutil 4.3.1 ............................. SUCCESS [ 35.219 s]
[INFO] rocketmq-filter 4.3.1 .............................. SUCCESS [ 1.353 s]
[INFO] rocketmq-broker 4.3.1 .............................. SUCCESS [ 9.089 s]
[INFO] rocketmq-tools 4.3.1 ............................... SUCCESS [ 2.546 s]
[INFO] rocketmq-namesrv 4.3.1 ............................. SUCCESS [ 1.020 s]
[INFO] rocketmq-logappender 4.3.1 ......................... SUCCESS [ 1.686 s]
[INFO] rocketmq-openmessaging 4.3.1 ....................... SUCCESS [ 2.071 s]
[INFO] rocketmq-example 4.3.1 ............................. SUCCESS [ 0.976 s]
[INFO] rocketmq-test 4.3.1 ................................ SUCCESS [ 5.313 s]
[INFO] rocketmq-distribution 4.3.1 ........................ SUCCESS [01:27 min]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 15:30 min
[INFO] Finished at: 2019-06-26T16:06:09+08:00
[INFO] Final Memory: 64M/828M
[INFO] ------------------------------------------------------------------------
2.启动NameServer
cd distribution/target/apache-rocketmq
nohup sh bin/mqnamesrv &
//如果这条命令报错,请使用 nohup sh bin/mqnamesrv >/dev/null 2>&1 &
cat nohup.out
//查看启动是否成功
3.启动Broker
nohup sh bin/mqbroker -n localhost:9876 autoCreateTopicEnable=true &
//autoCreateTopicEnable=true 允许自动创建topic
cat nohup.out
//查看启动状态
4.查看服务状态
在bin目录下执行命令:sh mqadmin clusterList -n localhost:9876
5.常用命令
- 关闭NameServer sh bin/mqshutdown namesrv
- 关闭Broker sh bin/mqshutdown broker
- 查看集群情况 ./mqadmin clusterList -n localhost:9876
- 查看 broker 状态 ./mqadmin brokerStatus -n localhost:9876 -b ***.***.*.***:10911 (broker 地址)
- 查看 topic 列表 ./mqadmin topicList -n localhost:9876
- 查看 topic 状态 ./mqadmin topicStatus -n localhost9876 -t MyTopic (topic名称)
- 查看 topic 路由 ./mqadmin topicRoute -n localhost:9876 -t MyTopic