Zabbixサーバーのパフォーマンスチューニング
概要
100台程度のホストを監視する想定で、パフォーマンスチューニングします。 今回は、簡易的にZabbixサーバー自身の監視設定をコピーして負荷をかけていきます。
環境
ハードウェア
- ECS Liva Q1L
- CPU Intel® Celeron® N3350
- メモリ 4GB
- 内蔵ストレージ eMMC 64GB
- 有線LAN 2×Gigabit LAN (10BASE-T/100BASE-TX/1000BASE-T)
- 無線LAN Wi-Fi 802.11ac
ソフトウェア
- Debian 11 (bullseys)
- Zabbix 5.4
- PostgreSQL 13
- nginx
- PHP 7.4
テスト環境の作成
監視設定をYAML形式でエキスポートする
エキスポートしたファイルを元に100台分の新規ホストとして編集する
サンプルファイル(zbx_export_hosts-0-99.yaml) ※注意※ 利用する場合は、groups > uuid を自身の環境に合わせて書き換えてください。
作成したファイルをインポートしてホストを作成する
「設定」→「ホスト」の右上にある「インポート」をクリックし、作成したファイルを選択する。
Zabbixサーバーの設定を修正する
ホストを100台追加するとZabbixサーバーが停止してしまいます。ログを確認して原因を確認していきます。
47586:20211107:190121.261 Starting Zabbix Server. Zabbix 5.4.7 (revision 84dc2ec5dc). 47586:20211107:190121.261 ****** Enabled features ****** 47586:20211107:190121.261 SNMP monitoring: YES 47586:20211107:190121.261 IPMI monitoring: YES 47586:20211107:190121.261 Web monitoring: YES 47586:20211107:190121.261 VMware monitoring: YES 47586:20211107:190121.261 SMTP authentication: YES 47586:20211107:190121.261 ODBC: YES 47586:20211107:190121.261 SSH support: YES 47586:20211107:190121.261 IPv6 support: YES 47586:20211107:190121.261 TLS support: YES 47586:20211107:190121.261 ****************************** 47586:20211107:190121.261 using configuration file: /etc/zabbix/zabbix_server.conf 47586:20211107:190121.351 TimescaleDB version: 20500 47586:20211107:190121.380 current database version (mandatory/optional): 05040000/05040000 47586:20211107:190121.380 required mandatory version: 05040000 47586:20211107:190121.542 server #0 started [main process] 47595:20211107:190121.543 server #1 started [configuration syncer #1] 47595:20211107:190122.230 __mem_malloc: skipped 7 asked 6296 skip_min 264 skip_max 5000 47595:20211107:190122.231 [file:dbconfig.c,line:102] __zbx_mem_realloc(): out of memory (requested 6296 bytes) 47595:20211107:190122.231 [file:dbconfig.c,line:102] __zbx_mem_realloc(): please increase CacheSize configuration parameter 47595:20211107:190122.231 === memory statistics for configuration cache === 47595:20211107:190122.231 free chunks of size 24 bytes: 24 47595:20211107:190122.231 free chunks of size >= 256 bytes: 7 47595:20211107:190122.231 min chunk size: 24 bytes 47595:20211107:190122.231 max chunk size: 5000 bytes 47595:20211107:190122.231 memory of total size 7257720 bytes fragmented into 70658 chunks 47595:20211107:190122.231 of those, 15480 bytes are in 31 free chunks 47595:20211107:190122.231 of those, 7242240 bytes are in 70627 used chunks 47595:20211107:190122.231 of those, 1130512 bytes are used by allocation overhead 47595:20211107:190122.231 ================================ 47595:20211107:190122.231 === Backtrace: === 47595:20211107:190122.232 15: /usr/sbin/zabbix_server: configuration syncer [syncing configuration](zbx_backtrace+0x3f) [0x56428eb0f601] 47595:20211107:190122.232 14: /usr/sbin/zabbix_server: configuration syncer [syncing configuration](__zbx_mem_realloc+0x160) [0x56428eb0a2c4] 47595:20211107:190122.232 13: /usr/sbin/zabbix_server: configuration syncer [syncing configuration](+0x1a2b54) [0x56428ea94b54] 47595:20211107:190122.232 12: /usr/sbin/zabbix_server: configuration syncer [syncing configuration](zbx_hashset_reserve+0xc1) [0x56428eb1557f] 47595:20211107:190122.232 11: /usr/sbin/zabbix_server: configuration syncer [syncing configuration](zbx_hashset_insert_ext+0xee) [0x56428eb157f0] 47595:20211107:190122.232 10: /usr/sbin/zabbix_server: configuration syncer [syncing configuration](zbx_hashset_insert+0x2d) [0x56428eb15700] 47595:20211107:190122.232 9: /usr/sbin/zabbix_server: configuration syncer [syncing configuration](DCfind_id+0x86) [0x56428ea95387] 47595:20211107:190122.232 8: /usr/sbin/zabbix_server: configuration syncer [syncing configuration](+0x1abc78) [0x56428ea9dc78] 47595:20211107:190122.232 7: /usr/sbin/zabbix_server: configuration syncer [syncing configuration](DCsync_configuration+0x11d9) [0x56428eaa3a08] 47595:20211107:190122.232 6: /usr/sbin/zabbix_server: configuration syncer [syncing configuration](dbconfig_thread+0x122) [0x56428e95937a] 47595:20211107:190122.232 5: /usr/sbin/zabbix_server: configuration syncer [syncing configuration](zbx_thread_start+0x37) [0x56428eb1f97a] 47595:20211107:190122.232 4: /usr/sbin/zabbix_server: configuration syncer [syncing configuration](MAIN_ZABBIX_ENTRY+0xb3b) [0x56428e9479fe] 47595:20211107:190122.232 3: /usr/sbin/zabbix_server: configuration syncer [syncing configuration](daemon_start+0x2f5) [0x56428eb0f20f] 47595:20211107:190122.232 2: /usr/sbin/zabbix_server: configuration syncer [syncing configuration](main+0x2f5) [0x56428e946ded] 47595:20211107:190122.232 1: /lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xea) [0x7f72d9fc4d0a] 47595:20211107:190122.232 0: /usr/sbin/zabbix_server: configuration syncer [syncing configuration](_start+0x2a) [0x56428e945cca] 47586:20211107:190122.237 One child process died (PID:47595,exitcode/signal:1). Exiting ... 47586:20211107:190122.260 syncing trend data... 47586:20211107:190122.261 syncing trend data done 47586:20211107:190122.261 Zabbix Server stopped. Zabbix 5.4.7 (revision 84dc2ec5dc).
このようなログが何度も繰り返して出力されていることが分かります。 この中で、以下の行に「メモリが不足しているから CacheSize 設定を増やしてね」と記載されています。
47595:20211107:190122.231 [file:dbconfig.c,line:102] __zbx_mem_realloc(): out of memory (requested 6296 bytes) 47595:20211107:190122.231 [file:dbconfig.c,line:102] __zbx_mem_realloc(): please increase CacheSize configuration parameter
このため、Zabbixサーバーの設定ファイルを変更します。 デフォルトは8Mなので、とりあえず32Mにして様子を見てみます。 /etc/zabbix/zabbix_server.conf
CacheSize 32M
変更したらサーバーを再起動します。
# systemctl restart zabbix-server
上手く起動したら30分くらい様子見をしてからパフォーマンスを確認していきます。
32MBだと75%ギリギリなので、64MBまで増やして様子を見ていきます。 /etc/zabbix/zabbix_server.conf
CacheSize 64M
問題なさそうなので、これで行きます。
他の項目を確認していく
ポイント:queueがたまっているということは処理しきれていないということなのでチューニングが必要な状態です。
ポイント:データを収集するプロセスの稼働率をチェックします。75%を超えていると余裕がないので対応するプロセスを増やす必要があります。 遠隔地にあるサーバーを監視する場合は、途中の回線が混みあっている場合などにチェックに時間がかかりプロセスが消費されることがあります。
詳細は、以下の記事で詳細に解説されています。。 blog.serverworks.co.jp
お疲れさまでした。