1、下载服务

  1. 下载bin包或者源码包
  2. 如果下载的是源码包,需要使用命令进行编译打包
unzip rocketmq-all-4.9.3-source-release.zip
cd rocketmq-all-4.9.3/
mvn -Prelease-all -DskipTests clean install -U
cd distribution/target/rocketmq-4.9.3/rocketmq-4.9.3

2、启动服务

  1. Start Name Server
# 启动服务
nohup sh bin/mqnamesrv &
# 查看日志
tail -f ~/logs/rocketmqlogs/namesrv.log
# 停止服务
sh bin/mqshutdown namesrv
  1. Start MQ Broker
# 启动服务
nohup sh bin/mqbroker -n localhost:9876 &
# 查看日志
tail -f ~/logs/rocketmqlogs/broker.log
# 停止服务
sh bin/mqshutdown broker

本地启动 rocketmq-dashboard

1、下载服务

  1. 下载源码包

2、启动服务

  1. 修改配置文件,修改 application.yml 文件中namsrcAddrs 参数
rocketmq:
  config:
    namesrvAddrs:
      - 127.0.0.1:9876 #修改此处地址为本地
  1. 运行服务
  • 方式一
mvn spring-boot:run
## 
mvn clean package -Dmaven.test.skip=true
java -jar target/rocketmq-dashboard-1.0.1-SNAPSHOT.jar
  • 方式二
mvn clean package -Dmaven.test.skip=true
java -jar target/rocketmq-dashboard-1.0.1-SNAPSHOT.jar
  1. 浏览器访问 http://localhost:8080 进行 rocketmq 可视化管理

可能遇到的问题以及解决方法

问题 1

  • 启动 MQ broker 时无法正常启动,日志提示如下
2022-05-30 17:05:19 INFO main - load /Users/xxxx/store/config/subscriptionGroup.json OK
2022-05-30 17:05:19 INFO main - load /Users/xxxx/store/config/consumerFilter.json OK
2022-05-30 17:05:19 INFO main - Try to start service thread:AllocateMappedFileService started:false lastThread:null
2022-05-30 17:05:19 INFO main - Try to shutdown service thread:AllocateMappedFileService started:true lastThread:Thread[AllocateMappedFileService,5,main]
2022-05-30 17:05:19 INFO main - shutdown thread AllocateMappedFileService interrupt true
2022-05-30 17:05:19 INFO main - join thread AllocateMappedFileService elapsed time(ms) 0 90000
2022-05-30 17:05:19 INFO main - Try to shutdown service thread:PullRequestHoldService started:false lastThread:null

解决方法

  • 该问题可能由于使用 kill -9 ${pid} 命令关闭 broker 进程导致, 删除 /Users/xxxx/store/ 后,重启 mqnamesrvmqboker

问题 2

  • 使用 rocketmq-dashboard 时,查看部分页面时提示异常
# ip-sample-1
org.apache.rocketmq.remoting.exception.RemotingConnectException: connect to 19.168.0.103:10909 failed"
# ip-sample-2
org.apache.rocketmq.remoting.exception.RemotingConnectException: connect to 10.152.0.6:10909 failed"

解决方法

  • 查看broker日志,确认broker 是否正常启动
# 查看日志
tail -200f ~/logs/rocketmqlogs/broker.log
  • 如果未正常启动,需检查配置,启动broker
  • 如果服务正常启动,关注日志输出配置打印部分,日志的前几行
2022-05-30 18:03:13 INFO main - namesrvAddr=localhost:9876
2022-05-30 18:03:13 INFO main - brokerIP1=10.152.0.6
2022-05-30 18:03:13 INFO main - brokerIP2=10.152.0.6
  • 发现此处 IP 异常,多为多网卡或使用VPN 软件导致,可以尝试修改配置文件修复
  • 修改配置文件 conf/boker.conf
# 文件最后追加
brokerIP1 = 192.168.0.103 #调整为自己的 ip
  • 重启 broker服务
# 停止服务
sh bin/mqshutdown broker
# 启动服务,指定配置文件
nohup sh bin/mqbroker -n localhost:9876 -c ./conf/broker.conf &
  • 重启刷新rocketmq-dashboard页面查看效果

问题 3

  • 使用rocketmq-dashboardtopic发送消息时,无法正常发送,提示异常如下
[2022-05-30 18:37:29.578] ERROR http-nio-8080-exec-1 - op=global_exception_handler_print_error
java.lang.RuntimeException: org.apache.rocketmq.client.exception.MQClientException: Send [3] times, still failed, cost [33]ms, Topic: test, BrokersSent: [broker-a, broker-a, broker-a]
···
Caused by: org.apache.rocketmq.client.exception.MQBrokerException: CODE: 14  DESC: service not available now. It may be caused by one of the following reasons: the broker's disk is full [CL:  0.96 CQ:  0.96 INDEX: -1.00], messages are put to the slave, message store has been shut down, etc. BROKER: 192.168.0.103:10911
···

解决方法

  • 该问题是由于本地机器磁盘使用率高于阈值,触发报警,可以通过调整broker的启动脚本bin/runbroker.sh的参数修复
# 脚本中增加配置,指定磁盘使用率报警阈值为 99%
JAVA_OPT="${JAVA_OPT} -Drocketmq.broker.diskSpaceWarningLevelRatio=0.99"
  • 重启broker服务,重新发送消息
# 停止服务
sh bin/mqshutdown broker
# 启动服务,指定配置文件
nohup sh bin/mqbroker -n localhost:9876 -c ./conf/broker.conf &