这是进程堆内存超限被强制杀掉,不是随机重启。日志里的 Context: maximum heap size reached + Kill: true 就是这个信号。
先确认到底是“进程被杀”还是“整个节点重启”:
grep -Ei "maximum heap size reached|proc_heap_too_large|connection_shutdown|BOOT|stopped|SIGTERM" data/log/emqx.log* | tail -n 200
emqx ctl broker
如果 uptime 没重置,通常是某个连接/规则相关进程反复超限被杀。
你这个日志里 Max Heap Size: 6291456(约 6MB),先把 force_shutdown 和 zone 覆盖配置查出来:
emqx ctl conf show force_shutdown
emqx ctl conf show zones
重点看 max_heap_size、max_mailbox_size。
另外把系统层面的 OOM 也排除掉:
dmesg -T | grep -Ei "oom|out of memory|killed process" | tail -n 100
如果是 Docker/K8s:
docker inspect <emqx_container> --format '{{.State.RestartCount}} {{.State.OOMKilled}}'
配置了最大内存不生效erlang.system_flags.max_heap_size = 268435456 # 256MB,单位字节
你这个配置项写错路径了。Context: maximum heap size reached 走的是 force_shutdown.max_heap_size,不是 erlang.system_flags.max_heap_size。
你日志里 Max Heap Size: 6291456(6MB)也说明当前生效阈值仍然很小。
先把当前生效值查出来:
emqx ctl conf show force_shutdown
emqx ctl conf show zones
emqx ctl conf show listeners
重点看监听器绑定的 zone(通常是 external)里有没有覆盖:zones.<zone>.force_shutdown.max_heap_size。
修配置用这两条(单位用 "256MB" 这种 Bytesize 字符串):
force_shutdown.max_heap_size = "256MB"
zones.external.force_shutdown.max_heap_size = "256MB"
改完重启 EMQX,再确认:
emqx ctl conf show force_shutdown
emqx ctl conf show zones | grep -n "max_heap_size"
emqx ctl conf show force_shutdown 这个命令是在bin目录下面执行吗?我执行了这个emqx ctl conf validate也报错
conf validate 报错是正常的,5.7.2 没有这个子命令;校验配置文件用 emqx check_config。
emqx ctl conf show force_shutdown 要在“运行中的 EMQX 节点环境”里执行,不是必须在 bin/ 目录,但命令路径要对。
- tar/zip 安装:
./bin/emqx ctl conf show force_shutdown
- DEB/RPM 安装:
emqx ctl conf show force_shutdown
- Docker:
docker exec -it <容器名> emqx ctl conf show force_shutdown
再把这几个输出贴一下,先确认生效值和是否有 zone 覆盖:
emqx ctl conf show force_shutdown
emqx ctl conf show zones
emqx ctl conf show listeners
,