EMQX docker持久化
时间: 2023-11-12 17:04:09 浏览: 193
EMQX docker持久化可以通过修改EMQX配置文件和使用docker-compose实现。具体步骤如下:
1. 修改EMQX配置文件:在emqx/etc/emqx.conf中添加以下内容:
persistence.client_session.clean_interval = 7200s
persistence.client_session.max_inflight = 65535
persistence.client_session.queue_qos0_messages = false
persistence.client_session.queue_qos1_messages = true
persistence.client_session.queue_qos2_messages = true
persistence.offline_message.max_inflight = 1000000
persistence.offline_message.queue_qos0_messages = false
persistence.offline_message.queue_qos1_messages = true
persistence.offline_message.queue_qos2_messages = true
persistence.subscription.max_inflight = 65535
persistence.subscription.queue_qos0_messages = false
persistence.subscription.queue_qos1_messages = true
persistence.subscription.queue_qos2_messages = true
persistence.retained_message.max_inflight = 1000000
persistence.retained_message.queue_qos0_messages = false
persistence.retained_message.queue_qos1_messages = true
persistence.retained_message.queue_qos2_messages = true
log.console = file
log.console.level = debug
log.console.file = /emqx/log/console.log
log.error = file
log.error.level = error
log.error.file = /emqx/log/error.log
log.crash = file
log.crash.file = /emqx/log/crash.log
log.crash.maximum_size = 10MB
log.crash.maximum_rotation = 10
2. 创建docker-compose.yml文件:在该文件中添加以下内容:
version: '3'
services:
emqx:
image: emqx/emqx:latest
container_name: emqx
restart: always
ports:
- "1883:1883"
- "8883:8883"
- "8083:8083"
- "18083:18083"
volumes:
- ./emqx/data:/opt/emqx/data
- ./emqx/log:/opt/emqx/log
- ./emqx/etc:/opt/emqx/etc
3. 创建redis文件夹和redis.conf文件:在redis文件夹中创建redis.conf文件,并添加以下内容:
appendonly yes
appendfsync everysec
4. 启动集群:在终端中运行docker-compose up命令启动EMQX集群。
阅读全文