docker-compose emqx
时间: 2023-12-14 14:34:36 浏览: 238
docker编排工具.rar
以下是使用docker-compose启动EMQ X集群的步骤:
1.首先,确保已经安装了Docker和Docker Compose。
2.创建一个名为`docker-compose.yml`的文件,并将以下内容复制到文件中:
```yaml
version: '3'
services:
emqx1:
image: emqx/emqx:4.2.2
container_name: emqx1
environment:
- EMQX_NAME=emqx1
- EMQX_HOST=emqx1
- EMQX_NODE__DIST_LISTEN_MAX=6379
- EMQX_LISTENER__TCP__EXTERNAL=1883
- EMQX_LISTENER__WS__EXTERNAL=8083
- EMQX_LOADED_PLUGINS="emqx_management,emqx_dashboard,emqx_recon,emqx_retainer,emqx_rule_engine"
ports:
- "1883:1883"
- "8083:8083"
- "18083:18083"
volumes:
- ./emqx1/data:/opt/emqx/data
- ./emqx1/log:/opt/emqx/log
- ./emqx1/etc/plugins:/opt/emqx/etc/plugins
- ./emqx1/etc/certs:/opt/emqx/etc/certs
depends_on:
- emqx2
- emqx3
emqx2:
image: emqx/emqx:4.2.2
container_name: emqx2
environment:
- EMQX_NAME=emqx2
- EMQX_HOST=emqx2
- EMQX_NODE__DIST_LISTEN_MAX=6379
- EMQX_LISTENER__TCP__EXTERNAL=1884
- EMQX_LISTENER__WS__EXTERNAL=8084
- EMQX_LOADED_PLUGINS="emqx_management,emqx_dashboard,emqx_recon,emqx_retainer,emqx_rule_engine"
volumes:
- ./emqx2/data:/opt/emqx/data
- ./emqx2/log:/opt/emqx/log
- ./emqx2/etc/plugins:/opt/emqx/etc/plugins
- ./emqx2/etc/certs:/opt/emqx/etc/certs
depends_on:
- emqx3
emqx3:
image: emqx/emqx:4.2.2
container_name: emqx3
environment:
- EMQX_NAME=emqx3
- EMQX_HOST=emqx3
- EMQX_NODE__DIST_LISTEN_MAX=6379
- EMQX_LISTENER__TCP__EXTERNAL=1885
- EMQX_LISTENER__WS__EXTERNAL=8085
- EMQX_LOADED_PLUGINS="emqx_management,emqx_dashboard,emqx_recon,emqx_retainer,emqx_rule_engine"
volumes:
- ./emqx3/data:/opt/emqx/data
- ./emqx3/log:/opt/emqx/log
- ./emqx3/etc/plugins:/opt/emqx/etc/plugins
- ./emqx3/etc/certs:/opt/emqx/etc/certs
```
3.在终端中,进入包含`docker-compose.yml`文件的目录,并运行以下命令:
```shell
docker-compose up -d
```
这将启动一个包含三个EMQ X节点的集群。
4.要检查集群是否正在运行,请运行以下命令:
```shell
docker-compose ps
```
这将显示正在运行的容器列表。
5.要停止集群,请运行以下命令:
```shell
docker-compose down
```
阅读全文