官网:
https://rocketmq.apache.org/zh/
安装RocketMQ 5.2.0
wget https://dist.apache.org/repos/dist/release/rocketmq/5.2.0/rocketmq-all-5.2.0-bin-release.zip
unzip rocketmq-all-5.2.0-bin-release.zip
#启动之前修改jvm启动内存
cd bin
#修改:runserver.sh 、runbroker.sh 文件,将启动内存改小
-Xms1g -Xmx1g -Xmn512m
#启动nameServer
nohup sh bin/mqnamesrv &
#关闭 nameServer
sh bin/mqshutdown namesrv
#启动Broker+Proxy
nohup sh bin/mqbroker -n localhost:9876 --enable-proxy &
#关闭Broker
sh bin/mqshutdown broker
部署 RocketMQ Dashboard
下载页:
https://rocketmq.apache.org/zh/download
下载并安装:
wget https://dist.apache.org/repos/dist/release/rocketmq/rocketmq-dashboard/1.0.0/rocketmq-dashboard-1.0.0-source-release.zip
#安装Maven
wget http://repos.fedorapeople.org/repos/dchen/apache-maven/epel-apache-maven.repo -O /etc/yum.repos.d/epel-apache-maven.repo
yum -y install apache-maven
#解压、编译
unzip rocketmq-dashboard-1.0.0-source-release.zip
cd rocketmq-dashboard-1.0.0-source-release
mvn clean package -Dmaven.test.skip=true
#修改配置文件application.properties
rocketmq.config.namesrvAddr=127.0.0.1:9876
#启动 rocketmq-dashboard
nohup java -jar rocketmq-dashboard-1.0.0.jar &
关于namesrvAddr
最好用域名代替Ip,在服务器上的/etc/hosts文件中配置,本机开发时也配置hosts
你的ip namesrv.rocket
最后在rocketmq-dashboard中配置,保证各端均能访问,否则设置成内网Ip,则通过公网无法访问,设置成公网ip,则内网访问不合算,也不安全。
基于springboot开发版本一致性
使用rocketmq-spring-boot-starter 2.2.3 版本,对应的rocketmq服务器版本:5.2.0
对应的rocketmq-client、springboot、springcloud
<dependency>
<groupId>org.apache.rocketmq</groupId>
<artifactId>rocketmq-client</artifactId>
<version>4.9.3</version>
</dependency>
<dependency>
<groupId>org.apache.rocketmq</groupId>
<artifactId>rocketmq-spring-boot-starter</artifactId>
<version>2.2.3</version>
</dependency>
<spring-boot.version>2.5.9</spring-boot.version>
<spring-cloud.version>2020.0.6</spring-cloud.version>
常用命令
1、查看消息
./mqadmin queryMsgByUniqueKey -n 127.0.0.1:9876 -t topic_snapshot -i 7F0000012E5C18B4AAC26F5AAA4E0000
# -n NameServer 服务地址,格式 ip:port
# -i uniqe msg id
# -t topic名称