安装前的准备

JDK1.8+
rocketmq-all-4.9.1-bin-release

安装过程

安装JDK

首先把jdk1.8.tar.gz解压到当前目录下,如下图所示

RocketMQ单机版安装_.net


修改/etc/profile文件,添加环境变量,代码段如下面所示,其中/opt/jdk1.8.0_144的值为上图中解压的路径。

#JAVA_HOME
export JAVA_HOME=/opt/jdk1.8.0_144
export PATH=$PATH:$JAVA_HOME/bin

RocketMQ单机版安装_apache_02


查看是否安装成功

echo $JAVA_HOME

安装RocketMQ

下载、解压并且修改配置

下载RocketMQ安装包并解压,进入解压后的目录如下图所示

RocketMQ单机版安装_.net_03


修改rocketmq-all-4.9.1-bin-release/bin/runserver.sh文件

RocketMQ单机版安装_java_04

修改rocketmq-all-4.9.1-bin-release/bin/runbroker.sh文件、

RocketMQ单机版安装_.net_05

启动NameServer和Broker

参考:
RocketMQ官方文档 http://rocketmq.apache.org/docs/quick-start/

> nohup sh bin/mqnamesrv &
> tail -f ~/logs/rocketmqlogs/namesrv.log
The Name Server boot success...
> nohup sh bin/mqbroker -n localhost:9876 &
> tail -f ~/logs/rocketmqlogs/broker.log
The broker[%s, 172.30.30.233:10911] boot success...

收发消息测试

参考:
RocketMQ官方文档 http://rocketmq.apache.org/docs/quick-start/

> export NAMESRV_ADDR=localhost:9876
> sh bin/tools.sh org.apache.rocketmq.example.quickstart.Producer
SendResult [sendStatus=SEND_OK, msgId= ...

> sh bin/tools.sh org.apache.rocketmq.example.quickstart.Consumer
ConsumeMessageThread_%d Receive New Messages: [MessageExt...

RocketMQ可视化控制台安装

下载地址:https://github.com/apache/rocketmq-externals/tags

RocketMQ单机版安装_java_06


下载下来以后是一个SpringBoot项目,修改配置文件里的端口和nameServer,如下图所示

RocketMQ单机版安装_apache_07


进入rocketmq-externals-rocketmq-console-1.0.0\rocketmq-console目录下并执行打包命令

mvn clean package -Dmaven.test.skip=true

RocketMQ单机版安装_.net_08

打包以后启动,并且在控制台输入http://ip:7000/#/

RocketMQ单机版安装_apache_09

JavaAPI

​https://gitee.com/cbeann/Demooo/tree/master/rocketmq-demo​

遇到的问题
发现用java代码去发送消息的时候,发现总是超时,后来发送broker注册到nameServer的ip是内网ip,所以访问不到,需要重启broker并且配置broker的ip为外网ip
解决方案如下:​

参考

RocketMQ官方文档:http://rocketmq.apache.org/docs/quick-start/
尚硅谷哔哩哔哩视频: https://www.bilibili.com/video/BV1cf4y157sz?p=22