当前位置:网站首页>MQTT第二话 -- emqx高可用集群实现
MQTT第二话 -- emqx高可用集群实现
2022-06-29 08:11:00 【有头发的程序猿!】
本文主要记录mqtt-emqx的高可用集群搭建
1.集群搭建
基于liunx centos7,docker-comspoe,emqx:4.4.4。
1.1 docker-compose.yaml文件
version: '3.7'
services:
emqx01:
image: emqx:4.4.4
container_name: emqx01
ports:
- "1883:1883" #tcp连接
- "18083:18083" #控制台
- "8083:8083" #控制台工具websocket ws用
- "8084:8084" #控制台工具websocket wss用
environment:
- TZ=Asia/Shanghai
- EMQX_NAME=node01
- EMQX_CLUSTER__DISCOVERY=static
#集群节点ip 固定容器ip最好
- [email protected],[email protected],[email protected]
networks:
my-net:
ipv4_address: 172.19.0.221
emqx02:
image: emqx:4.4.4
container_name: emqx02
ports:
- "1813:1883"
- "18013:18083"
- "8013:8083"
- "8014:8084"
environment:
- TZ=Asia/Shanghai
- EMQX_NAME=node02
- EMQX_CLUSTER__DISCOVERY=static
#集群节点ip 固定容器ip最好
- [email protected],[email protected],[email protected]
networks:
my-net:
ipv4_address: 172.19.0.222
emqx03:
image: emqx:4.4.4
container_name: emqx03
ports:
- "1893:1883"
- "18093:18083"
- "8093:8083"
- "8094:8084"
environment:
- TZ=Asia/Shanghai
- EMQX_NAME=node03
- EMQX_CLUSTER__DISCOVERY=static
#集群节点ip 固定容器ip最好
- [email protected],[email protected],[email protected]
networks:
my-net:
ipv4_address: 172.19.0.223
networks:
#新增的网络 内部服务名调用
my-net:
external: true
设置固定内网ip时,可以先通过docker network inspect my-net获取指定网络的网段
1.2 启动容器
[[email protected] emqx-cluster]# docker-compose up -d
Recreating emqx01 ... done
Creating emqx02 ... done
Creating emqx03 ... done
[[email protected] emqx-cluster]# docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
4d45a3c5db23 emqx:4.4.4 "/usr/bin/docker-ent…" 9 seconds ago Up 6 seconds 4369-4370/tcp, 5369/tcp, 6369-6370/tcp, 0.0.0.0:1883->1883/tcp, 8081/tcp, 8883/tcp, 0.0.0.0:8083-8084->8083-8084/tcp, 0.0.0.0:18083->18083/tcp, 11883/tcp emqx01
0b3f9987307b emqx:4.4.4 "/usr/bin/docker-ent…" 9 seconds ago Up 6 seconds 4369-4370/tcp, 5369/tcp, 6369-6370/tcp, 8081/tcp, 8883/tcp, 11883/tcp, 0.0.0.0:1813->1883/tcp, 0.0.0.0:8013->8083/tcp, 0.0.0.0:8014->8084/tcp, 0.0.0.0:18013->18083/tcp emqx02
3c522f7bb76c emqx:4.4.4 "/usr/bin/docker-ent…" 9 seconds ago Up 6 seconds 4369-4370/tcp, 5369/tcp, 6369-6370/tcp, 8081/tcp, 8883/tcp, 11883/tcp, 0.0.0.0:1893->1883/tcp, 0.0.0.0:8093->8083/tcp, 0.0.0.0:8094->8084/tcp, 0.0.0.0:18093->18083/tcp emqx03
1.3 集群控制台界面

2.springboot集成
集成代码在上篇文章
MQTT第一话 – Docker安装emqx以及Springboot集成emqx有了,这里就不贴了。
mqtt client连接是单地址连接的,所以集群可由nginx转发,需要注意加心跳检测,转发地址填内网IP,不需要对外开放。
以上就是本章的全部内容了。
上一篇:MQTT第一话 – Docker安装emqx以及Springboot集成emqx
下一篇:MongoDB第一话 – Docker安装MongoDB以及Springboot集成MongoDB
立身以立学为先,立学以读书为本
边栏推荐
- Some behaviors of Apple developers that are prone to investigation
- U盘内存卡数据丢失怎么恢复,这样操作也可以
- 开户买基金,通过网上基金开户安全吗?-
- P6776-[NOI2020]超现实树
- Mosaic notes
- [microservices openfeign] timeout of openfeign
- NP3 格式化输出(一)
- Some "non-technical" Thoughts on distributed digital identity
- Debugging nocturnal simulator with ADB command
- P4769-[NOI2018]冒泡排序【组合数学,树状数组】
猜你喜欢

Typescript variable declaration - type assertion

Déclaration de la variable Typescript - - assertion de type

华为设备配置中型网络WLAN基本业务

Dialogue | prospects and challenges of privacy computing in the digital age

Debugging nocturnal simulator with ADB command

城通网盘仿蓝奏网盘源码 附带视频教程

TypeScript 變量聲明 —— 類型斷言

Oracle subquery

A review of visual SLAM methods for autonomous driving vehicles

Blueprint basis
随机推荐
Huawei equipment is configured with small network WLAN basic services
Verilog first experience
P4769-[NOI2018]冒泡排序【组合数学,树状数组】
Some "non-technical" Thoughts on distributed digital identity
Leetcode(142)——环形链表 II
Sed replace value with variable
Robcogen tutorial of robot code generator
Set up Jenkins environment and automatically associate packaged project jars for automatic release
Notes mosaïque
2022第六季完美童模 合肥赛区 决赛圆满落幕
New paid Tarot calculation source code (with building tutorial)
Typescript variable declaration - type assertion
启牛学堂让开的证券账户是真的安全靠谱吗?
Wechat applet development, how to add multiple spaces
Tutorial on building open source Internet of things platform
802.11--802.11n协议 PHY
各种级数(调和、几何)总结
搭建开源物联网平台教程
Target tracking [single target tracking (vot/sot), target detection, pedestrian re identification (re ID)]
sed 替换值为变量