Linux下Rocketmq4.7安装记录

官网下载安装包

本次教程安装的RocketMQ4.7版本,针对linux部署,其他系统参考RocketMQ官网

前置条件
64bit OS, Linux/Unix/Mac is recommended;(Windows user see guide below)
64bit JDK 1.8+;
Maven 3.2.x;
Git;
4g+ free disk for Broker server

解压压缩包
unzip rocketmq-all-4.7.1-source-release.zip

重命名
mv rocketmq-all-4.7.1-source-release rocketmq-all-4.7.1

进入目录
cd rocketmq-all-4.7.1/

打包依赖(首次有点久)
mvn -Prelease-all -DskipTests clean install -U

cd distribution/target/rocketmq-4.7.1/rocketmq-4.7.1

1.Start Name Server(启动nameServer)

nohup sh bin/mqnamesrv &

查看日志
tail -f ~/logs/rocketmqlogs/namesrv.log
显示The Name Server boot success…代表启动成功

2.Start Broker
启动broker (-n指定nameserver地址,nameserver服务端口为9876, broker默认端口 10911)
nohup sh bin/mqbroker -n localhost:9876 &
查看日志
tail -f ~/logs/rocketmqlogs/broker.log
显示The broker[%s, 172.30.30.233:10911] boot success…代表启动成功

3.Send & Receive Messages(验证是否成功)
说明:Before sending/receiving messages, we need to tell clients the location of name servers. RocketMQ provides multiple ways to achieve this. For simplicity, we use environment variable NAMESRV_ADDR

设置名称服务地址
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…代表成功

4.Shutdown Servers (关闭nameserver broker执行的命令)
sh bin/mqshutdown broker
sh bin/mqshutdown namesrv

使用jps命令可查看后台进程

源码安装RocketMQ4.x可视化控制台
下载源码链接

cd rocketmq-externals/rocketmq-console

编译打包
mvn clean package -Dmaven.test.skip=true
进入target目录 通过java -jar的方式运行, 启动后是 8080端口

其他常见问题:

1)无法连接获取broker信息
修改配置文件,名称路由地址为 namesrvAddr,例如我本机地址为
src/main/resources/application.properties
rocketmq.config.namesrvAddr=127.0.0.1:9876
2)连接不成功
在阿里云,腾讯云或者虚拟机,记得检查端口号和防火墙是否启动
阿里云控制台有安全组,需要开放对应的端口

你可能感兴趣的:(linux)