Apache RocketMQ 安装、测试、报错解决

1. 准备

64bit OS, Linux/Unix/Mac 
64bit JDK 1.8+;
Maven 3.2.x

2.下载和构建

下载 4.2.0 源代码版本地址:http://mirrors.hust.edu.cn/apache/rocketmq/4.2.0/rocketmq-all-4.2.0-source-release.zip

现在执行以下命令来解压缩 4.2.0 源代码版本并构建二进制工件。

  > unzip rocketmq-all-4.2.0-source-release.zip
  > cd rocketmq-all-4.2.0/
  > mvn -Prelease-all -DskipTests clean install -U
  > cd distribution/target/apache-rocketmq

3.启动mqnamesrv  、mqbroker 

  > nohup sh bin/mqnamesrv &
  > tail -f ~/logs/rocketmqlogs/namesrv.log

运行成功的日志输出:
  The Name Server boot success...


官方启动 broker 方式如下:
  > nohup sh bin/mqbroker -n localhost:9876 &
经测试这样是不行的,要在后面加上设置 : autoCreateTopicEnable=true 。

最终运行命令为:(nohup 记录日志,& 表示后台运行 )
  > nohup sh mqbroker -n localhost:9876 autoCreateTopicEnable=true &
  > tail -f ~/logs/rocketmqlogs/broker.log 

运行成功的日志输出:
  The broker[%s, 172.30.30.233:10911] boot success...

 4.修改配置、发送和接收消息

设置环境变量
 > 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...

5.关闭服务

> sh bin/mqshutdown broker

运行成功时日志输出:
The mqbroker(36695) is running...
Send shutdown request to mqbroker(36695) OK


> sh bin/mqshutdown namesrv

运行成功时日志输出:
The mqnamesrv(36664) is running...
Send shutdown request to mqnamesrv(36664) OK

6.踩过的坑

1)报错: There is insufficient memory for the Java Runtime Environment to continue

解决方式:  解决There is insufficient memory for the Java Runtime Environment to continue

2)报错:org.apache.rocketmq.client.exception.MQClientException: No route info of this topic, TopicTest

解决方式:解决:org.apache.rocketmq.client.exception.MQClientException: No route info of this topic, TopicTest

3)报错:Could not find or load main class org.apache.rocketmq.example.quickstart.Producer

解决方式:解决:Could not find or load main class org.apache.rocketmq.example.quickstart.Producer

 

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

你可能感兴趣的:(消息队列)