root@iZ2Z:~# timedatectl
Local time: Sun 2024-12-01 23:03:19 CST
Universal time: Sun 2024-12-01 15:03:19 UTC
RTC time: Sun 2024-12-01 15:03:19
Time zone: Asia/Shanghai (CST, +0800)
System clock synchronized: yes
NTP service: active
RTC in local TZ: no
docker-compose up -d --remove-orphans
[+] Running 4/4
✔ Network emqx-docker_emqx_bridge Created 0.1s
✔ Container emqx1 Started 0.3s
✔ Container emqx2 Started 0.4s
✔ Container emqx3 Started 0.3s
➜ emqx-docker orbd emqx
➜ emqx-docker
➜ emqx-docker docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
c43b1c2840bf emqx/emqx:latest "/usr/bin/docker-ent…" 6 seconds ago Up 5 seconds (healthy) 4370/tcp, 5369/tcp, 8083-8084/tcp, 8883/tcp, 0.0.0.0:1884->1883/tcp, [::]:1884->1883/tcp, 0.0.0.0:18084->18083/tcp, [::]:18084->18083/tcp emqx2
f8a8008f93d8 emqx/emqx:latest "/usr/bin/docker-ent…" 6 seconds ago Up 5 seconds (health: starting) 4370/tcp, 5369/tcp, 8083-8084/tcp, 0.0.0.0:1883->1883/tcp, :::1883->1883/tcp, 0.0.0.0:18083->18083/tcp, :::18083->18083/tcp, 8883/tcp emqx1
8b9888a67fca emqx/emqx:latest "/usr/bin/docker-ent…" 6 seconds ago Up 5 seconds (health: starting) 4370/tcp, 5369/
进入每个节点查看状态:
orbd emqx
container_id: c43b1c2840bf
NEW: OrbStack Debug Shell provides useful commands & tools, making it easy to debug any container (even minimal/distroless).
It also allows installing over 80,000 packages.
To use Debug Shell, get a Pro license: https://orbstack.dev/pricing
Learn more: https://go.orbstack.dev/debug
emqx@docker2:/opt/emqx$ ./bin/emqx ctl cluster status
Cluster status: #{running_nodes =>
['emqx@docker1.emqx.dev','emqx@docker2.emqx.dev',
'emqx@docker3.emqx.dev'],
stopped_nodes => []}
更正一下:不是 bug,只是体验问题。后续会优化。
在手动模式下,A,B,C 三个节点。
1.当在 A 节点上执行了./bin/emqx ctl cluster join B
会变成 A 节点主动加入 B 所在的集群。AB 组成一个集群。
2. 再在 A 节点主主动加入 C 节点,就会执行:A 离开原来的集群,加入 C 集群。
这时就会 AC 组成集群。
所以正确的组成集群方式应该是:
1.在 A 节点上执行./bin/emqx ctl cluster join B
2. 在 C 节点上执行./bin/emqx ctl cluster join B
3. ABC 就成了一个集群。
后续可能考虑会优化这个命令成:在 A 节点上执行./bin/emqx ctl cluster join B 时会先检查 A 节点是否在一个集群中,如果在的话,就不执行。否则太危险了。