Linux下安装配置rocketmq

一、常规安装配置

1.  首先安装JDK

安装JDK的方法:https://blog.csdn.net/Shiloh_My/article/details/82911878

2. 安装maven

下载源码包

wget http://mirror.bit.edu.cn/apache/maven/binaries/apache-maven-3.2.2-bin.tar.gz

tar -zxvf apache-maven-3.2.2-bin.tar.gz

配置maven环境变量

vim /etc/profile

 #配置maven环境变量
 export MAVEN_HOME=/usr/maven/apache-maven-3.5.4
 export MAVEN_HOME
 export PATH=$PATH:$MAVEN_HOME/bin

source /etc/profile

测试maven 

#mvn -v
Apache Maven 3.2.2 (45f7c06d68e745d05611f7fd14efb6594181933e; 2014-06-17T21:51:42+08:00)
Maven home: /usr/maven/apache-maven-3.2.2
Java version: 1.8.0_181, vendor: Oracle Corporation
Java home: /usr/java/jdk1.8.0_181/jre
Default locale: zh_CN, platform encoding: UTF-8
OS name: "linux", version: "3.10.0-862.14.4.el7.x86_64", arch: "amd64", family: "unix"

Linux下安装配置rocketmq_第1张图片

3. 安装rocketmq 

下载源码包并构建二进制文件

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] --- maven-install-plugin:2.5.2:install (default-install) @ rocketmq-distribution ---
[INFO] Installing /usr/roketmq/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 /usr/roketmq/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 /usr/roketmq/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 [  5.362 s]
[INFO] rocketmq-logging 4.3.1 ............................. SUCCESS [  4.130 s]
[INFO] rocketmq-remoting 4.3.1 ............................ SUCCESS [  7.105 s]
[INFO] rocketmq-common 4.3.1 .............................. SUCCESS [  4.319 s]
[INFO] rocketmq-client 4.3.1 .............................. SUCCESS [  5.337 s]
[INFO] rocketmq-store 4.3.1 ............................... SUCCESS [  3.346 s]
[INFO] rocketmq-srvutil 4.3.1 ............................. SUCCESS [  0.537 s]
[INFO] rocketmq-filter 4.3.1 .............................. SUCCESS [  1.414 s]
[INFO] rocketmq-broker 4.3.1 .............................. SUCCESS [  4.164 s]
[INFO] rocketmq-tools 4.3.1 ............................... SUCCESS [  2.795 s]
[INFO] rocketmq-namesrv 4.3.1 ............................. SUCCESS [  1.298 s]
[INFO] rocketmq-logappender 4.3.1 ......................... SUCCESS [  0.884 s]
[INFO] rocketmq-openmessaging 4.3.1 ....................... SUCCESS [  1.923 s]
[INFO] rocketmq-example 4.3.1 ............................. SUCCESS [  1.380 s]
[INFO] rocketmq-test 4.3.1 ................................ SUCCESS [  2.465 s]
[INFO] rocketmq-distribution 4.3.1 ........................ SUCCESS [  5.923 s]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 52.856 s
[INFO] Finished at: 2018-10-09T14:36:31+08:00
[INFO] Final Memory: 60M/289M
[INFO] ------------------------------------------------------------------------

Linux下安装配置rocketmq_第2张图片

进入到目录

cd distribution/target/apache-rocketmq

启动NameServer

 

nohup sh bin/mqnamesrv &
如果这条命令报错,请使用 nohup sh bin/mqnamesrv  >/dev/null 2>&1 &

tail -f ~/logs/rocketmqlogs/namesrv.log

启动Broker

nohup sh bin/mqbroker -n localhost:9876 &
tail -f ~/logs/rocketmqlogs/broker.log

发送和接受消息

在发送/接收消息之前,我们需要告诉客户名称服务器的位置。RocketMQ 提供了多种方法来实现这一点。为了简单起见,我们使用环境变量NAMESRV_ADDR

export NAMESRV_ADDR=localhost:9876
sh bin/tools.sh org.apache.rocketmq.example.quickstart.Producer

接收消息

sh bin/tools.sh org.apache.rocketmq.example.quickstart.Consumer

关闭服务器

sh bin/mqshutdown broker    //停止 broker

sh bin/mqshutdown namesrv   //停止 nameserver

常用命令

上面几个启动和关闭 name server 和 broker 的就不再说了,

  • 查看集群情况 ./mqadmin clusterList -n 127.0.0.1:9876
  • 查看 broker 状态 ./mqadmin brokerStatus -n 127.0.0.1:9876 -b 172.20.1.138:10911 (注意换成你的 broker 地址)
  • 查看 topic 列表 ./mqadmin topicList -n 127.0.0.1:9876
  • 查看 topic 状态 ./mqadmin topicStatus -n 127.0.0.1:9876 -t MyTopic (换成你想查询的 topic)
  • 查看 topic 路由 ./mqadmin topicRoute -n 127.0.0.1:9876 -t MyTopic

 

 

你可能感兴趣的:(Linux)