[ #zabbix ][自分用メモ] ARMボードにZabbix-agentを導入したところ、cannot allocate shared memoryが発生した。

AIX、UNIX、LinuxARMzabbix
Zabbix Community Area
The shared knowledge is priceless when there is a friendly and open community, that makes it grow. Join co-thinkers at Z...

自宅環境のARMボードにZabbix-agentを導入したところ掲題のようなエラーメッセージが。

問題のメッセージ

16042:20150401:233544.949 Starting Zabbix Agent [dns02.kometch.local]. Zabbix 2.4.4 (revision 52341).
16042:20150401:233544.951 using configuration file: /etc/zabbix/zabbix_agentd.conf
16042:20150401:233544.952 cannot allocate shared memory of size 175768: [22] Invalid argument
16042:20150401:233544.953 cannot allocate shared memory for collector

確認環境:

$ lsb_release -a
No LSB modules are available.
Distributor ID:Ubuntu
Description:Ubuntu 14.04.2 LTS
Release:14.04
Codename:trusty

どうやら共有メモリが確保出来無いらしい。
ということでKernelパラメータをチューニングする必要があるそうです。

その前に幾つか値の確認

$ ipcs -l
------ Shared Memory Limits --------
max number of segments = 4096
max seg size (kbytes) = 0
max total shared memory (kbytes) = 16777216
min seg size (bytes) = 1
------ Semaphore Limits --------
max number of arrays = 1024
max semaphores per array = 250
max semaphores system wide = 32000
max ops per semop call = 128
semaphore max value = 32767
------ Messages Limits --------
max queues system wide = 32000
max size of message (bytes) = 65536
default max size of queue (bytes) = 65536
$ sudo sysctl -a | grep shm
kernel.shm_rmid_forced = 0
kernel.shmall = 4194304
kernel.shmmax = 0
kernel.shmmni = 4096

対応方法

sysctl.confに以下のパラメータを追記する。

kernel.shmall = 2097152
kernel.shmmax = 33554432

そして有効にして、再度値を確認する。

$ sudo sysctl -p
$ sudo sysctl -a | grep shm
kernel.shm_rmid_forced = 0
kernel.shmall = 2097152
kernel.shmmax = 33554432
kernel.shmmni = 4096
$ sudo ipcs -l
------ Shared Memory Limits --------
max number of segments = 4096
max seg size (kbytes) = 32768
max total shared memory (kbytes) = 8388608
min seg size (bytes) = 1
------ Semaphore Limits --------
max number of arrays = 1024
max semaphores per array = 250
max semaphores system wide = 32000
max ops per semop call = 128
semaphore max value = 32767
------ Messages Limits --------
max queues system wide = 32000
max size of message (bytes) = 65536
default max size of queue (bytes) = 65536

zabbix-agentを起動させ、問題なく起動することを確認する。(logの確認など)

$ sudo ipcs -m
------ Shared Memory Segments --------
key        shmid      owner      perms      bytes      nattch     status
0x6c011121 65536      zabbix     600        175768     6  
https://www.programering.com/a/MjM3cTNwATA.html

今更ですが(2020年2月18日:追記)

この件ってZabbix wikiでも専用のページが用意されていたんですね。

Zabbix Community Area
The shared knowledge is priceless when there is a friendly and open community, that makes it grow. Join co-thinkers at Z...

Configuration of shared memory for zabbix_server daemon

General information

If you need to use significantly increased values of caches (CacheSize, HistoryCacheSize, HistoryTextCacheSize, TrendCacheSize) for zabbix_server daemon then you have to configure (increase) kernel parameters.

Some operating systems, like FreeBSD, require increased kernel parameters to start zabbix_server daemon even with the default configuration file. For example: zabbix_server requires 36 Mbytes total (defaulf Zabbix caches), but FreeBSD by default allows to allocate only 8192*4096 = 32 Mbytes

Note that if other programs are using shared memory as well (PostgreSQL for example), you will have to coordinate the size settings between them. Note that the amount of total size of shared memory (shmall) is measured in Pages and one page size is the value of PAGE_SIZE (normally 4096 bytes).

この記事を書いた人

kometchtech

うつ病を患いながら、IT業界の末席にいるおっさんエンジニア。科学計算をしたことがないのに、HPC分野にお邪魔している。興味のある分野で学習したことをblogにまとめつつ、うつ病の経過症状のメモも置いておく日々。じつはRouterboard User Group JPの中の人でもある。 Amazon欲しいものリスト / Arm板を恵んでくれる人募集中

kometchtechをフォローする
タイトルとURLをコピーしました