使用docker compose部署emqx集群的示例
更新时间:2023年06月21日 14:50:16 作者:蒲公英PGY
这篇文章主要介绍了使用docker compose部署emqx集群,本文通过示例代码给大家介绍的非常详细,对大家的学习或工作具有一定的参考借鉴价值,需要的朋友可以参考下
1、docker-compose.yml 文件,内容如下:
version: '3' services: emqx1: image: emqx:5.0.26 container_name: emqx1 environment: - "EMQX_NODE_NAME=emqx@node1.emqx.io" - "EMQX_CLUSTER__DISCOVERY_STRATEGY=static" - "EMQX_CLUSTER__STATIC__SEEDS=[emqx@node1.emqx.io,emqx@node2.emqx.io]" healthcheck: test: ["CMD", "/opt/emqx/bin/emqx_ctl", "status"] interval: 5s timeout: 25s retries: 5 networks: emqx-bridge: aliases: - node1.emqx.io ports: - 1883:1883 - 8083:8083 - 8084:8084 - 8883:8883 - 18083:18083 # volumes: # - $PWD/emqx1_data:/opt/emqx/data emqx2: image: emqx:5.0.26 container_name: emqx2 environment: - "EMQX_NODE_NAME=emqx@node2.emqx.io" - "EMQX_CLUSTER__DISCOVERY_STRATEGY=static" - "EMQX_CLUSTER__STATIC__SEEDS=[emqx@node1.emqx.io,emqx@node2.emqx.io]" healthcheck: test: ["CMD", "/opt/emqx/bin/emqx_ctl", "status"] interval: 5s timeout: 25s retries: 5 networks: emqx-bridge: aliases: - node2.emqx.io # volumes: # - $PWD/emqx2_data:/opt/emqx/data networks: emqx-bridge: driver: bridge
2、通过命令行切换 docker-compose.yml 文件所在目录,然后输入以下命令启动 EMQX 集群:
docker-compose up -d
3、查看集群状态
$ docker exec -it emqx1 sh -c "emqx_ctl cluster status" Cluster status: #{running_nodes => ['emqx@node1.emqx.com','emqx@node2.emqx.com'], stopped_nodes => []}
官方参考资料:https://www.emqx.io/docs/zh/v5/deploy/install-docker.html
到此这篇关于使用docker compose部署emqx集群的文章就介绍到这了,更多相关docker compose部署emqx集群内容请搜索脚本之家以前的文章或继续浏览下面的相关文章希望大家以后多多支持脚本之家!
您可能感兴趣的文章:
相关文章
Docker跨服务器通信Overlay解决方案(上)之 Consul单实例
这篇文章主要介绍了Docker跨服务器通信Overlay解决方案(上)之 Consul单实例,本文通过场景分析实例代码相结合给大家介绍的非常详细,对大家的学习或工作具有一定的参考借鉴价值,需要的朋友可以参考下2021-12-12
最新评论