前言
上一篇文章已经总结了
ActiveMQ + MQTT 集群搭建(虚机版本) + Springboot使用配置
本篇文章总结一下docker部署方案
一、docker方式部署
1.创建挂载目录
本地创建挂载目录:/home/jenkins/test_apps/mnt/activemq-cluster。
在该目录下基于activemq.xml修改名字创建三个配置文件activemq-clusters.xml、activemq-master.xml、activemq-slave.xml。
在该目录下创建目录kahadb用来挂载数据。
2.分别修改三个配置文件(虚机配置第三点一致),如下:
<transportConnectors>
<!-- DOS protection, limit concurrent connections to 1000 and frame size to 100MB -->
<transportConnector name="openwire" uri="tcp://0.0.0.0:61616?maximumConnections=10000&wireFormat.maxFrameSize=104857600"/>
<transportConnector name="mqtt" uri="mqtt://0.0.0.0:1883?maximumConnections=10000&wireFormat.maxFrameSize=104857600"/>
</transportConnectors>
<!-- 配置网络代理,cluster 节点需要与 master 跟 slave 进行穿透 -->
<networkConnectors>
<networkConnector name="network-clusters" uri="static:(tcp://192.168.10.41:61617,tcp://192.168.10.41:61618)" duplex="true" />
</networkConnectors>
<transportConnectors>
<!-- DOS protection, limit concurrent connections to 1000 and frame size to 100MB -->
<transportConnector name="openwire" uri="tcp://0.0.0.0:61617?maximumConnections=10000&wireFormat.maxFrameSize=104857600"/>
<transportConnector name="mqtt" uri="mqtt://0.0.0.0:2884?maximumConnections=10000&wireFormat.maxFrameSize=104857600"/>
</transportConnectors>
<!-- 配置网络代理,master 节点需要与 cluster 跟 slave 进行穿透 -->
<networkConnectors>
<networkConnector name="network-master" uri="static:(tcp://192.168.10.41:61616,tcp://192.168.10.41:61618)" duplex="true" />
</networkConnectors>
<transportConnectors>
<!-- DOS protection, limit concurrent connections to 1000 and frame size to 100MB -->
<transportConnector name="openwire" uri="tcp://0.0.0.0:61618?maximumConnections=10000&wireFormat.maxFrameSize=104857600"/>
<transportConnector name="mqtt" uri="mqtt://0.0.0.0:2885?maximumConnections=10000&wireFormat.maxFrameSize=104857600"/>
</transportConnectors>
<!-- 配置网络代理,slave 节点需要与 master 跟 cluster 进行穿透 -->
<networkConnectors>
<networkConnector name="network-slave" uri="static:(tcp://192.168.10.41:61616,tcp://192.168.10.41:61617)" duplex="true" />
</networkConnectors>
3.容器启动:
-----------无挂载日志-----------
clusters启动:
docker run --name='activemq_clusters' \
-itd \
--privileged=true \
--restart=unless-stopped \
-p 61616:61616 \
-p 8161:8161 \
-p 1883:1883 \
-e ACTIVEMQ_ADMIN_LOGIN=admin \
-e ACTIVEMQ_ADMIN_PASSWORD=admin \
-v /home/jenkins/test_apps/mnt/activemq-cluster/activemq-clusters-a.xml:/opt/activemq/conf/activemq.xml \
webcenter/activemq:5.15.12
master启动
docker run --name='activemq_master' \
-itd \
--privileged=true \
--restart=unless-stopped \
-p 61617:61617 \
-p 8171:8161 \
-p 2884:1884 \
-e ACTIVEMQ_ADMIN_LOGIN=admin \
-e ACTIVEMQ_ADMIN_PASSWORD=admin \
-v /home/jenkins/test_apps/mnt/activemq-cluster/activemq-master-a.xml:/opt/activemq/conf/activemq.xml \
-v /home/jenkins/test_apps/mnt/activemq-cluster/kahadb:/opt/activemq/data/kahadb \
webcenter/activemq:5.15.12
slave启动:
docker run --name='activemq_slave' \
-itd \
--privileged=true \
--restart=unless-stopped \
-p 61618:61618 \
-p 8181:8161 \
-p 2885:1885 \
-e ACTIVEMQ_ADMIN_LOGIN=admin \
-e ACTIVEMQ_ADMIN_PASSWORD=admin \
-v /home/jenkins/test_apps/mnt/activemq-cluster/activemq-slave-a.xml:/opt/activemq/conf/activemq.xml \
-v /home/jenkins/test_apps/mnt/activemq-cluster/kahadb:/opt/activemq/data/kahadb \
webcenter/activemq:5.15.12
4.集群验证
1、容器启动后,和虚机一样进行配置检查,判断网络连接是否互通,是否形成集群;
2、项目配置同虚机搭建;文章来源:https://www.toymoban.com/news/detail-847991.html
总结
对docker搭建ActiveMQ + MQTT集群进行了简单总结,记录一下。文章来源地址https://www.toymoban.com/news/detail-847991.html
到了这里,关于ActiveMQ + MQTT 集群搭建(docker版本)的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!