linux / zabbix · 2021年7月4日 0

Zabbix错误“zbx_mem_malloc() out of memory(requested 256 bytes)” 解决方法

Zabbix错误”zbx_mem_malloc() out of memory (requested 256 bytes)”解决方法

今天下午13点的时候,同事添加了几台网络设备,Zabbix Server突然挂了,查看log报错如下:

...
339435:20200911:163056.717 Zabbix Server stopped. Zabbix 5.0.3 (revision 146855bff3).
339585:20200911:163309.398 Starting Zabbix Server. Zabbix 5.0.3 (revision 146855bff3).
339585:20200911:163309.398 ****** Enabled features ******
339585:20200911:163309.398 SNMP monitoring:           YES
339585:20200911:163309.398 IPMI monitoring:           YES
339585:20200911:163309.398 Web monitoring:            YES
339585:20200911:163309.398 VMware monitoring:         YES
339585:20200911:163309.398 SMTP authentication:       YES
339585:20200911:163309.398 ODBC:                      YES
339585:20200911:163309.398 SSH support:               YES
339585:20200911:163309.398 IPv6 support:              YES
339585:20200911:163309.398 TLS support:               YES
339585:20200911:163309.398 ******************************
339585:20200911:163309.398 using configuration file: /etc/zabbix/zabbix_server.conf
339585:20200911:163309.406 current database version (mandatory/optional): 05000000/05000002
339585:20200911:163309.406 required mandatory version: 05000000
339585:20200911:163309.423 server #0 started [main process]
339586:20200911:163309.424 server #1 started [configuration syncer #1]
339586:20200911:163310.138 __mem_malloc: skipped 0 asked 256 skip_min 18446744073709551615 skip_max 0
339586:20200911:163310.138 [file:dbconfig.c,line:96] __zbx_mem_malloc(): out of memory (requested 256 bytes)
339586:20200911:163310.138 [file:dbconfig.c,line:96] __zbx_mem_malloc(): please increase CacheSize configuration parameter
339586:20200911:163310.138 === memory statistics for configuration cache ===
339586:20200911:163310.138 free chunks of size     24 bytes:       94
339586:20200911:163310.138 free chunks of size     32 bytes:        1
339586:20200911:163310.138 free chunks of size     40 bytes:        3
339586:20200911:163310.138 free chunks of size     48 bytes:        1
339586:20200911:163310.138 free chunks of size     56 bytes:        5
339586:20200911:163310.139 free chunks of size     64 bytes:        1
339586:20200911:163310.139 free chunks of size     72 bytes:        2
339586:20200911:163310.139 min chunk size:         24 bytes
339586:20200911:163310.139 max chunk size:         72 bytes
339586:20200911:163310.139 memory of total size 8388232 bytes fragmented into 72645 chunks
339586:20200911:163310.139 of those,       2944 bytes are in      107 free chunks
339586:20200911:163310.139 of those,    7222984 bytes are in    72538 used chunks
339586:20200911:163310.139 ================================
339586:20200911:163310.139 === Backtrace: ===
339586:20200911:163310.140 13: /usr/sbin/zabbix_server: configuration syncer [syncing configuration](zbx_backtrace+0x3f) [0x56265121bc1f]
339586:20200911:163310.140 12: /usr/sbin/zabbix_server: configuration syncer [syncing configuration](__zbx_mem_malloc+0x180) [0x562651216c6b]
339586:20200911:163310.140 11: /usr/sbin/zabbix_server: configuration syncer [syncing configuration](+0x18c3b6) [0x5626511de3b6]
339586:20200911:163310.140 10: /usr/sbin/zabbix_server: configuration syncer [syncing configuration](+0x1d6295) [0x562651228295]
339586:20200911:163310.140 9: /usr/sbin/zabbix_server: configuration syncer [syncing configuration](zbx_vector_ptr_append+0x1c) [0x562651228457]
339586:20200911:163310.140 8: /usr/sbin/zabbix_server: configuration syncer [syncing configuration](+0x194c10) [0x5626511e6c10]
339586:20200911:163310.140 7: /usr/sbin/zabbix_server: configuration syncer [syncing configuration](DCsync_configuration+0xee4) [0x5626511ead22]
339586:20200911:163310.140 6: /usr/sbin/zabbix_server: configuration syncer [syncing configuration](dbconfig_thread+0x116) [0x5626510a6102]
339586:20200911:163310.140 5: /usr/sbin/zabbix_server: configuration syncer [syncing configuration](zbx_thread_start+0x37) [0x56265122a91a]
339586:20200911:163310.140 4: /usr/sbin/zabbix_server: configuration syncer [syncing configuration](MAIN_ZABBIX_ENTRY+0x9cb) [0x562651098b08]
339586:20200911:163310.140 3: /usr/sbin/zabbix_server: configuration syncer [syncing configuration](daemon_start+0x2ff) [0x56265121b82b]
339586:20200911:163310.140 2: /usr/sbin/zabbix_server: configuration syncer [syncing configuration](main+0x2f5) [0x56265109813b]
339586:20200911:163310.140 1: /lib64/libc.so.6(__libc_start_main+0xf3) [0x7fc09d0dc6a3]
339586:20200911:163310.140 0: /usr/sbin/zabbix_server: configuration syncer [syncing configuration](_start+0x2e) [0x5626510971ee]
339585:20200911:163310.143 One child process died (PID:339586,exitcode/signal:1). Exiting 
...

重点:

339586:20200911:163310.138 [file:dbconfig.c,line:96] __zbx_mem_malloc(): out of memory (requested 256 bytes)

339586:20200911:163310.138 [file:dbconfig.c,line:96] __zbx_mem_malloc(): please increase CacheSize configuration parameter

报错里已经很明确的提示了修复办法:please increase CacheSize configuration parameter

所以,我们就去zabbix_server.conf中找到CacheSize字段

### Option: CacheSize
#       Size of configuration cache, in bytes.
#       Shared memory size for storing host, item and trigger data.
#
# Mandatory: no
# Range: 128K-64G
# Default:
# CacheSize=8M

根据服务器配置情况,修改CacheSize

### Option: CacheSize
#       Size of configuration cache, in bytes.
#       Shared memory size for storing host, item and trigger data.
#
# Mandatory: no
# Range: 128K-64G
# Default:
CacheSize=2048M

重启Zabbix Server即可恢复