zabbix 监控的内存溢出问题 out of memory

zabbix 由于是docker 建置 zabbix-server-server

在web端出现异常情况

经过检查发现docker status 显示Restarting (0) 4 seconds ago

频繁在重起

经过docker logs 分析查看到
__zbx_shmem_malloc(): out of memory (requested 256 bytes)
问题

   191:20250306:023902.993 === memory statistics for configuration cache ===
   191:20250306:023902.993 free chunks of size     24 bytes:        1
   191:20250306:023902.993 free chunks of size     40 bytes:        1
   191:20250306:023902.993 free chunks of size     48 bytes:        1
   191:20250306:023902.993 min chunk size:         24 bytes
   191:20250306:023902.993 max chunk size:         48 bytes
   191:20250306:023902.993 memory of total size 29259808 bytes fragmented into 268391 chunks
   191:20250306:023902.993 of those,        112 bytes are in        3 free chunks
   191:20250306:023902.993 of those,   29259696 bytes are in   268388 used chunks
   191:20250306:023902.993 of those,    4294240 bytes are used by allocation overhead
   191:20250306:023902.993 ================================
   191:20250306:023902.993 backtrace is not available for this platform
   191:20250306:023902.993 [file:dbconfig.c,line:239] __zbx_shmem_malloc(): out of memory (requested 256 bytes)
   191:20250306:023902.993 [file:dbconfig.c,line:239] __zbx_shmem_malloc(): please increase CacheSize configuration parameter
     1:20250306:023902.998 One child process died (PID:191,exitcode/signal:1). Exiting ...
   189:20250306:023902.999 HA manager has been paused
   189:20250306:023903.009 HA manager has been stopped
     1:20250306:023903.010 Zabbix Server stopped. Zabbix 7.0.2 (revision d1b0c33).

由于是docker 环境
查看下启动命令

# docker ps --no-trunc | grep zabbix-server-mysql
CONTAINER ID                                                       IMAGE                                       COMMAND                                                                                                                                CREATED        STATUS                          PORTS                                             NAMES
9024130eeb841c067c90b995f85c9362422ac0591394e00009185a0c4f99de0e   172.17.10.224:5000/zabbix-server-mysql      "/usr/bin/docker-entrypoint.sh /usr/sbin/zabbix_server --foreground -c /etc/zabbix/zabbix_server.conf"                                 6 months ago   Restarting (0) 52 seconds ago                                                     zabbix-server-mysql

看到docker 启动命令为
/usr/bin/docker-entrypoint.sh /usr/sbin/zabbix_server --foreground -c /etc/zabbix/zabbix_server.conf
得知文件是 /etc/zabbix/zabbix_server.conf

这里就偷懒不重新做映射
将配置文件复制出来后再复制进去

# docker cp zabbix-server-mysql:/etc/zabbix/zabbix_server.conf .
Successfully copied 31.7kB to /root/.

按照官方说明:https://www.zabbix.com/documentation/current/en/manual/appendix/config/zabbix_server
评估修改以下参数

# Size of VMware cache, in bytes.
--
# VMwareCacheSize=8M
VMwareCacheSize=64MB

--
### Option: CacheSize
# Size of configuration cache, in bytes.
--
# CacheSize=8M
CacheSize=2048M

--
### Option: HistoryCacheSize
# Size of history cache, in bytes.
--
# HistoryCacheSize=16M
HistoryCacheSize=512M

### Option: HistoryIndexCacheSize
# Size of history index cache, in bytes.
--
# HistoryIndexCacheSize=4M
HistoryIndexCacheSize=32M

### Option: TrendCacheSize
# Size of trend cache, in bytes.
--
# TrendCacheSize=4M
TrendCacheSize=128M

### Option: ValueCacheSize
# Size of history value cache, in bytes.
--
# ValueCacheSize=8M
ValueCacheSize=256M

修改后复制回去

docker cp /root/zabbix_server.conf zabbix-server-mysql:/etc/zabbix/zabbix_server.conf

再次查看

# docker ps --no-trunc | grep zabbix-server-mysql
9024130eeb841c067c90b995f85c9362422ac0591394e00009185a0c4f99de0e   172.17.10.224:5000/zabbix-server-mysql      "/usr/bin/docker-entrypoint.sh /usr/sbin/zabbix_server --foreground -c /etc/zabbix/zabbix_server.conf"                                 6 months ago   Up 11 minutes   0.0.0.0:10051->10051/tcp, :::10051->10051/tcp     zabbix-server-mysql

到此
系统均已恢复正常

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值