Apache RocketMQ 安装说明
安装步骤 参考快速开始
https://rocketmq.apache.org/zh/docs/quickStart/01quickstart
安装可视化rocketmq_dashboard下载地址
https://rocketmq.apache.org/zh/docs/4.x/deployment/03Dashboard/
安装rocketmq_mqtt
https://rocketmq.apache.org/zh/docs/4.x/mqtt/01RocketMQMQTTOverview
enableLmq = true
enableMultiDispatch = true
git clone https://github.com/apache/rocketmq-mqtt
cd rocketmq-mqtt
mvn -Prelease-all -DskipTests clean install -U
cd distribution/target/
target下是打包的包
下面例子中 ROCKETMQ所在机器192.168.33.22,ROCKETMQ-MQTT服务所在机器172.16.10.160
修改conf/connect.conf
mqttPort=1883
enablePrometheus=true
修改conf/meta.conf
IP换成要运行服务的机器的
selfAddress=172.16.10.160:25000
membersAddress=172.16.10.160:25000
修改conf/service.conf
metaAddr的IP换成要运行服务的机器的
username和secretKey配置了要记住,mqtt生产者要使用它做认证
eventNotifyRetryTopic=xx //notify重试topic,提前创建
clientRetryTopic=xx //客户端消息重试topic,提前创建
NAMESRV_ADDR的IP换成RocketMQ nameserver服务所在机器的IP
如下:
username=test
secretKey=test
NAMESRV_ADDR=192.168.33.22:9876
eventNotifyRetryTopic=eventNotifyRetryTopic
clientRetryTopic=clientRetryTopic
metaAddr=172.16.10.160:25000
创建topic
mqadmin updatetopic -c {cluster} -t {topic} -n {namesrv}
上面配置的eventNotifyRetryTopic和clientRetryTopic也必须创建
实际执行如下:
sh mqadmin updatetopic -c DefaultCluster -t eventNotifyRetryTopic -n 192.168.33.22:9876
sh mqadmin updatetopic -c DefaultCluster -t clientRetryTopic -n 192.168.33.22:9876
sh mqadmin updatetopic -c DefaultCluster -t test-topic -n 192.168.33.22:9876
Configure Gateway Node List:
mqadmin updateKvConfig -s LMQ -k LMQ_CONNECT_NODES -v {ip1,ip2} -n {namesrv}
实际执行命令
sh mqadmin updateKvConfig -s LMQ -k LMQ_CONNECT_NODES -v 172.16.10.160 -n 192.168.33.22:9876
Configure the first-level topic list
mqadmin updateKvConfig -s LMQ -k ALL_FIRST_TOPICS -v {topic1,topic2} -n {namesrv}
实际执行如下:
sh mqadmin updateKvConfig -s LMQ -k ALL_FIRST_TOPICS -v eventNotifyRetryTopic,clientRetryTopic,test-topic -n 192.168.33.22:9876
Configure a list of wildcard characters under each first-level topic
mqadmin updateKvConfig -s LMQ -k {topic} -v {topic/+} -n {namesrv}
实际执行如下:
mqadmin updateKvConfig -s LMQ -k eventNotifyRetryTopic -v eventNotifyRetryTopic/+ -n 192.168.33.22:9876
mqadmin updateKvConfig -s LMQ -k clientRetryTopic -v clientRetryTopic/+ -n 192.168.33.22:9876
mqadmin updateKvConfig -s LMQ -k test-topic -v test-topic/+ -n 192.168.33.22:9876
cd bin
sh meta.sh start
sh mqtt.sh start
启动日志在$HOME/logs/start_out.log
启动完后应该meta对应25000端口,mqtt对应1883端口
使用rocketmq-mqtt工程中的mqtt-example做测试
将其中的一些IP、topic改为实际的
经测试,可以用mqtt做生产者,rocketmq做消费者
MqttProducer 消息生产
RocketMQConsumer 消息消费
备注:需要开发的端口号
4.1. runserver.sh 256m,256m 512m
4.2. runbroker.sh 512m 512m