CentOS下RocketMQ安装部署

RocketMQ部署

快速开始:http://rocketmq.apache.org/docs/quick-start/
官方下载:http://rocketmq.apache.org/release_notes/release-notes-4.4.0/

Download & Build from Release

# wget http://mirrors.tuna.tsinghua.edu.cn/apache/rocketmq/4.4.0/rocketmq-all-4.4.0-source-release.zip
# unzip -q rocketmq-all-4.4.0-source-release.zip 
# cd rocketmq-all-4.4.0
# mvn -Prelease-all -DskipTests clean install -U
# cd distribution/target/apache-rocketmq

Start Name Server

> nohup sh bin/mqnamesrv &
> tail -f ~/logs/rocketmqlogs/namesrv.log
The Name Server boot success...

Start Broker

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

Send & Receive Messages

> 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...

Shutdown Servers

> 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

常见问题

No route info of this topic

若测试发送及接收消息报错

org.apache.rocketmq.client.exception.MQClientException: No route info of this topic, TopicTest
原因分析

RocketMQ运行时提示No route info of this topic异常产生的原因可能是

Broker禁止自动创建Topic,且用户没有通过手工方式创建Topic
Broker没有正确连接到Name Server
Producer没有正确连接到Name Server

首先检查下Name Server中是否成功注册了Broker,有两种方式 

第一种,看broker的日志,如果出现形如

2017-12-14 16:21:35 INFO BrokerControllerScheduledThread1 - register broker to name server 192.168.192.129:9876 OK
2017-12-14 16:22:05 INFO BrokerControllerScheduledThread1 - register broker to name server 192.168.192.129:9876 OK

证明已经连接到Name Server

第二种,在bin目录下执行命令sh bin/mqadmin clusterList -n localhost:9876如果看到

#Cluster Name     #Broker Name            #BID  #Addr                  #Version                #InTPS(LOAD)       #OutTPS(LOAD) #PCWait(ms) #Hour #SPACE
DefaultCluster    DEFAULT_BROKER          0     192.168.192.129:10911  V4_2_0_SNAPSHOT          0.00(0,0ms)         0.00(0,0ms)          0 422168.55 -1.0000

也是证明已经连接到Name Server

解决方法

(1)内存不足,需扩展内存

调整脚本中启动内存占用大小

# cd distribution/target/apache-rocketmq

# vim bin/runserver.sh

JAVA_OPT="${JAVA_OPT} -server -Xms1g -Xmx1g -Xmn512m -XX:MetaspaceSize=128m -XX:MaxMetaspaceSize=320m" 

# vim bin/runbroker.sh

JAVA_OPT="${JAVA_OPT} -server -Xms1g -Xmx1g -Xmn512m"

(2)启动broker方式问题

nohup sh bin/mqbroker -n localhost:9876 &

改为:

nohup sh mqbroker -n localhost:9876 autoCreateTopicEnable=true &

RocketMQ插件部署

(1)下载地址:https://github.com/apache/rocketmq-externals.git

(2)进入rocketmq-externals\rocketmq-console\src\main\resources文件夹,打开application.properties进行配置

server.contextPath=
server.port=8088  //配置插件工程端口
#spring.application.index=true
spring.application.name=rocketmq-console
spring.http.encoding.charset=UTF-8
spring.http.encoding.enabled=true
spring.http.encoding.force=true
logging.config=classpath:logback.xml
#if this value is empty,use env value rocketmq.config.namesrvAddr  NAMESRV_ADDR | now, you can set it in ops page.default localhost:9876
rocketmq.config.namesrvAddr=127.0.0.1:9876  //配置MQ地址(默认端口为9876)
#if you use rocketmq version < 3.5.8, rocketmq.config.isVIPChannel should be false.default true
rocketmq.config.isVIPChannel=
#rocketmq-console's data path:dashboard/monitor
rocketmq.config.dataPath=/tmp/rocketmq-console/data
#set it false if you don't want use dashboard.default true
rocketmq.config.enableDashBoardCollect=true
#set the message track trace topic if you don't want use the default one
rocketmq.config.msgTrackTopicName=

(3)修改rocketmq-console/pom.xml

把pom文件中rocketmq的version改成4.4.0即可

<rocketmq.version>4.4.0-SNAPSHOT</rocketmq.version>

改为

<rocketmq.version>4.4.0</rocketmq.version>

参考:https://github.com/apache/rocketmq-externals/issues/208

(4)编译启动

进入\rocketmq-externals\rocketmq-console文件夹,执行mvn clean package -Dmaven.test.skip=true,编译生成

编译成功之后,CMD进入target文件夹,执行java -jar rocketmq-console-ng-1.0.0.jar,启动rocketmq-console-ng-1.0.0.jar

# cd rocketmq-externals/rocketmq-console

# mvn clean package -Dmaven.test.skip=true

# cd target

# nohup java -jar rocketmq-console-ng-1.0.0.jar &

(5)测试:浏览器中输入xxx.xxx.xxx.xxx:8088,成功后即可查看

版权声明:
作者:Joe.Ye
链接:https://www.appblog.cn/index.php/2023/02/26/rocketmq-installation-and-deployment-under-centos/
来源:APP全栈技术分享
文章版权归作者所有,未经允许请勿转载。

THE END
分享
二维码
打赏
海报
CentOS下RocketMQ安装部署
RocketMQ部署 快速开始:http://rocketmq.apache.org/docs/quick-start/ 官方下载:http://rocketmq.apache.org/release_notes/release-notes-4.4.0/ Downloa……
<<上一篇
下一篇>>
文章目录
关闭
目 录