わたしは2025年7月4日に開催された「第8回日本Zabbixユーザー会勉強会」に参加しました。
それまでの私は「Zabbix=監視ソフト」という程度の理解しか持っていませんでしたが、勉強会で紹介された多彩なユースケースを見て「これは触ってみたい!」と一気に興味が高まりました。
まずは全体像をつかむため、以下の3つのテーマでハンズオンを進めていく予定です。
-
Zabbixサーバの構築 ←今回
-
監視対象ホストへのエージェント導入と登録
-
検知・通知フローのテスト
本記事はシリーズ第1回として、Amazon EC2(Ubuntu24.04)でZabbix サーバを構築する手順を紹介します。
Zabbixサーバを構築してみた
■そもそもZabbixとは?
Zabbixとは、
Zabbixは、ネットワークの多数のパラメーターと、サーバーや仮想マシン、アプリケーション、サービス、データベース、Webサイト、クラウドなどの稼働状態と整合性を監視するためのソフトウェアです。Zabbixは柔軟な通知メカニズムを備え、すべてのイベントに対して電子メールによるアラートを設定できます。これによって、サーバーの問題に迅速に対応できます。Zabbixは、保存されたデータをもとに優れたレポート機能とデータ視覚化機能を提供し、キャパシティプランニングに最適なソフトウェアとなっています。 Zabbix公式
今回ハンズオンで使用する、Zabixの用語は以下の通りです。
- Zabbix Server: データ収集・トリガー判定・通知を統括する中枢。履歴は RDBMS(MySQL など)に保存。
- Zabbix Agent/Agent2: 監視対象ホストに常駐し、OS やミドルウェアのメトリクスを取得。
- Frontend (Web UI): PHP製。設定・グラフ・ダッシュボード・レポートをブラウザで操作。
この“サーバ+エージェント+DB+Web”というモジュール構成により、1台〜数十万ホストまでスケールできます。
■ハンズオン概要
本ハンズオンでは、「Ubuntu 24.04+MySQL+Zabbix7.4」という、今すぐ試せる最小構成でZabbixサーバを立ち上げる手順を紹介します。
Zabbixに触れたことがないが、監視ツールの仕組みをまずは体感したい方向けです。AWSのAmazon EC2をもとに、以下の流れで進めます。
- 環境準備
- パッケージインストール
- MySQL 初期化
- サービス起動&自動起動設定
- WebUI初期ウィザード
- ログイン
Zabbixの公式webページに、構成ごとのインストール方法が公開されています。(https://www.zabbix.com/download?zabbix=7.4&os_distribution=ubuntu&os_version=24.04&components=server_frontend_agent&db=mysql&ws=apache)
COMPONENTは次の構成にしています。
- Zabbix version: "7.4"
- OS Distribution: "Ubuntu"
- OS Version: "24.04 Noble"
- Database: "MySQL"
- Web Server: "Apache"
- ZABBIX COMPONENT: "Server, Frontend, Agent 2"
■EC2インスタンス準備
AWSクラウド環境で以下の構成で、EC2インスタンスを起動しましょう。
項目 | 設定値 |
---|---|
OS | Ubuntu Server 24.04 |
ボリュームサイズ | 32 GiB |
■パッケージリポジトリ追加
まずは、パッケージリポジトリ追加を追加します。
【コマンド】
wget https://repo.zabbix.com/zabbix/7.4/release/ubuntu/pool/main/z/zabbix-release/zabbix-release_latest_7.4+ubuntu24.04_all.deb
dpkg -i zabbix-release_latest_7.4+ubuntu24.04_all.deb
apt update
【実行結果】
root@ip-10-0-1-139:~# wget https://repo.zabbix.com/zabbix/7.4/release/ubuntu/pool/main/z/zabbix-release/zabbix-release_latest_7.4+ubuntu24.04_all.deb
--2025-07-21 07:36:58-- https://repo.zabbix.com/zabbix/7.4/release/ubuntu/pool/main/z/zabbix-release/zabbix-release_latest_7.4+ubuntu24.04_all.deb
Resolving repo.zabbix.com (repo.zabbix.com)... 178.128.6.101, 2604:a880:2:d0::2062:d001
Connecting to repo.zabbix.com (repo.zabbix.com)|178.128.6.101|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 7144 (7.0K) [application/octet-stream]
Saving to: ‘zabbix-release_latest_7.4+ubuntu24.04_all.deb’
zabbix-release_latest_7.4+ubuntu24.04_al 100%[=================================================================================>] 6.98K --.-KB/s in 0s
2025-07-21 07:36:59 (724 MB/s) - ‘zabbix-release_latest_7.4+ubuntu24.04_all.deb’ saved [7144/7144]
root@ip-10-0-1-139:~# dpkg -i zabbix-release_latest_7.4+ubuntu24.04_all.deb
Selecting previously unselected package zabbix-release.
(Reading database ... 70681 files and directories currently installed.)
Preparing to unpack zabbix-release_latest_7.4+ubuntu24.04_all.deb ...
Unpacking zabbix-release (1:7.4-1+ubuntu24.04) ...
Setting up zabbix-release (1:7.4-1+ubuntu24.04) ...
root@ip-10-0-1-139:~# apt update
Hit:1 http://ap-southeast-1.ec2.archive.ubuntu.com/ubuntu noble InRelease
Get:2 http://ap-southeast-1.ec2.archive.ubuntu.com/ubuntu noble-updates InRelease [126 kB]
Get:3 http://ap-southeast-1.ec2.archive.ubuntu.com/ubuntu noble-backports InRelease [126 kB]
Get:4 http://ap-southeast-1.ec2.archive.ubuntu.com/ubuntu noble/universe amd64 Packages [15.0 MB]
Get:5 http://security.ubuntu.com/ubuntu noble-security InRelease [126 kB]
Get:6 http://ap-southeast-1.ec2.archive.ubuntu.com/ubuntu noble/universe Translation-en [5982 kB]
Get:7 http://ap-southeast-1.ec2.archive.ubuntu.com/ubuntu noble/universe amd64 Components [3871 kB]
Get:8 http://ap-southeast-1.ec2.archive.ubuntu.com/ubuntu noble/universe amd64 c-n-f Metadata [301 kB]
Get:9 http://ap-southeast-1.ec2.archive.ubuntu.com/ubuntu noble/multiverse amd64 Packages [269 kB]
<省略>
Get:60 http://security.ubuntu.com/ubuntu noble-security/multiverse Translation-en [4288 B]
Get:61 http://security.ubuntu.com/ubuntu noble-security/multiverse amd64 Components [208 B]
Get:62 http://security.ubuntu.com/ubuntu noble-security/multiverse amd64 c-n-f Metadata [380 B]
Fetched 35.7 MB in 6s (6063 kB/s)
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
84 packages can be upgraded. Run 'apt list --upgradable' to see them.
■必要パッケージのインストール
つづいて、パッケージをインストールします。
【コマンド】
apt install zabbix-server-mysql zabbix-frontend-php zabbix-apache-conf zabbix-sql-scripts zabbix-agent2 mysql-server
【実行結果】
root@ip-10-0-1-139:~# apt install zabbix-server-mysql zabbix-frontend-php zabbix-apache-conf zabbix-sql-scripts zabbix-agent2 mysql-server
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following additional packages will be installed:
apache2 apache2-bin apache2-data apache2-utils fontconfig-config fonts-dejavu fonts-dejavu-core fonts-dejavu-extra fonts-dejavu-mono fping libaom3
libapache2-mod-php libapache2-mod-php8.3 libapr1t64 libaprutil1-dbd-sqlite3 libaprutil1-ldap libaprutil1t64 libcares2 libcgi-fast-perl libcgi-pm-perl
libclone-perl libde265-0 libdeflate0 libencode-locale-perl libevent-extra-2.1-7t64 libevent-pthreads-2.1-7t64 libfcgi-bin libfcgi-perl libfcgi0t64
libfontconfig1 libgd3 libheif-plugin-aomdec libheif-plugin-aomenc libheif-plugin-libde265 libheif1 libhtml-parser-perl libhtml-tagset-perl
libhtml-template-perl libhttp-date-perl libhttp-message-perl libio-html-perl libjbig0 libjpeg-turbo8 libjpeg8 liblerc4 libltdl7 liblua5.4-0
liblwp-mediatypes-perl libmecab2 libmysqlclient21 libodbc2 libopenipmi0t64 libprotobuf-lite32t64 libsharpyuv0 libsnmp-base libsnmp40t64 libtiff6
libtimedate-perl liburi-perl libwebp7 libxpm4 mecab-ipadic mecab-ipadic-utf8 mecab-utils mysql-client mysql-client-8.0 mysql-client-core-8.0 mysql-common
mysql-server-8.0 mysql-server-core-8.0 php-bcmath php-common php-curl php-gd php-ldap php-mbstring php-mysql php-xml php8.3-bcmath php8.3-cli php8.3-common
php8.3-curl php8.3-gd php8.3-ldap php8.3-mbstring php8.3-mysql php8.3-opcache php8.3-readline php8.3-xml snmpd ssl-cert
Suggested packages:
apache2-doc apache2-suexec-pristine | apache2-suexec-custom www-browser php-pear libgd-tools libheif-plugin-x265 libheif-plugin-ffmpegdec
libheif-plugin-jpegdec libheif-plugin-jpegenc libheif-plugin-j2kdec libheif-plugin-j2kenc libheif-plugin-rav1e libheif-plugin-svtenc libdata-dump-perl
libipc-sharedcache-perl libio-compress-brotli-perl odbc-postgresql tdsodbc snmp-mibs-downloader libbusiness-isbn-perl libregexp-ipv6-perl libwww-perl mailx
tinyca snmptrapd zabbix-nginx-conf
The following NEW packages will be installed:
apache2 apache2-bin apache2-data apache2-utils fontconfig-config fonts-dejavu fonts-dejavu-core fonts-dejavu-extra fonts-dejavu-mono fping libaom3
libapache2-mod-php libapache2-mod-php8.3 libapr1t64 libaprutil1-dbd-sqlite3 libaprutil1-ldap libaprutil1t64 libcares2 libcgi-fast-perl libcgi-pm-perl
libclone-perl libde265-0 libdeflate0 libencode-locale-perl libevent-extra-2.1-7t64 libevent-pthreads-2.1-7t64 libfcgi-bin libfcgi-perl libfcgi0t64
libfontconfig1 libgd3 libheif-plugin-aomdec libheif-plugin-aomenc libheif-plugin-libde265 libheif1 libhtml-parser-perl libhtml-tagset-perl
libhtml-template-perl libhttp-date-perl libhttp-message-perl libio-html-perl libjbig0 libjpeg-turbo8 libjpeg8 liblerc4 libltdl7 liblua5.4-0
liblwp-mediatypes-perl libmecab2 libmysqlclient21 libodbc2 libopenipmi0t64 libprotobuf-lite32t64 libsharpyuv0 libsnmp-base libsnmp40t64 libtiff6
libtimedate-perl liburi-perl libwebp7 libxpm4 mecab-ipadic mecab-ipadic-utf8 mecab-utils mysql-client mysql-client-8.0 mysql-client-core-8.0 mysql-common
mysql-server mysql-server-8.0 mysql-server-core-8.0 php-bcmath php-common php-curl php-gd php-ldap php-mbstring php-mysql php-xml php8.3-bcmath php8.3-cli
php8.3-common php8.3-curl php8.3-gd php8.3-ldap php8.3-mbstring php8.3-mysql php8.3-opcache php8.3-readline php8.3-xml snmpd ssl-cert zabbix-agent2
zabbix-apache-conf zabbix-frontend-php zabbix-server-mysql zabbix-sql-scripts
0 upgraded, 97 newly installed, 0 to remove and 84 not upgraded.
Need to get 72.2 MB of archives.
After this operation, 432 MB of additional disk space will be used.
Do you want to continue? [Y/n] Y
<省略>
Creating config file /etc/php/8.3/mods-available/gd.ini with new version
Setting up zabbix-frontend-php (1:7.4.0-1+ubuntu24.04) ...
update-alternatives: using /usr/share/fonts/truetype/dejavu/DejaVuSans.ttf to provide /usr/share/zabbix/ui/assets/fonts/graphfont.ttf (zabbix-frontend-font) in auto mode
Setting up php-gd (2:8.3+93ubuntu2) ...
Setting up zabbix-apache-conf (1:7.4.0-1+ubuntu24.04) ...
Enabling conf zabbix.
To activate the new configuration, you need to run:
systemctl reload apache2
Processing triggers for php8.3-cli (8.3.6-0ubuntu0.24.04.5) ...
Processing triggers for libapache2-mod-php8.3 (8.3.6-0ubuntu0.24.04.5) ...
Processing triggers for libc-bin (2.39-0ubuntu8.4) ...
Scanning processes...
Scanning linux images...
Running kernel seems to be up-to-date.
No services need to be restarted.
No containers need to be restarted.
No user sessions are running outdated binaries.
No VM guests are running outdated hypervisor (qemu) binaries on this host.
■プラグインのインストール
つぎにプラグインをインストールします。
【コマンド】
apt install zabbix-agent2-plugin-mongodb zabbix-agent2-plugin-mssql zabbix-agent2-plugin-postgresql
【実行結果】
root@ip-10-0-1-139:~# apt install zabbix-agent2-plugin-mongodb zabbix-agent2-plugin-mssql zabbix-agent2-plugin-postgresql
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following NEW packages will be installed:
zabbix-agent2-plugin-mongodb zabbix-agent2-plugin-mssql zabbix-agent2-plugin-postgresql
0 upgraded, 3 newly installed, 0 to remove and 84 not upgraded.
Need to get 8667 kB of archives.
After this operation, 29.4 MB of additional disk space will be used.
Get:1 https://repo.zabbix.com/zabbix/7.4/stable/ubuntu noble/main amd64 zabbix-agent2-plugin-mongodb amd64 1:7.4.0-1+ubuntu24.04 [3434 kB]
Get:2 https://repo.zabbix.com/zabbix/7.4/stable/ubuntu noble/main amd64 zabbix-agent2-plugin-mssql amd64 1:7.4.0-1+ubuntu24.04 [2416 kB]
Get:3 https://repo.zabbix.com/zabbix/7.4/stable/ubuntu noble/main amd64 zabbix-agent2-plugin-postgresql amd64 1:7.4.0-1+ubuntu24.04 [2817 kB]
Fetched 8667 kB in 3s (3364 kB/s)
Selecting previously unselected package zabbix-agent2-plugin-mongodb.
(Reading database ... 75332 files and directories currently installed.)
Preparing to unpack .../zabbix-agent2-plugin-mongodb_1%3a7.4.0-1+ubuntu24.04_amd64.deb ...
Unpacking zabbix-agent2-plugin-mongodb (1:7.4.0-1+ubuntu24.04) ...
Selecting previously unselected package zabbix-agent2-plugin-mssql.
Preparing to unpack .../zabbix-agent2-plugin-mssql_1%3a7.4.0-1+ubuntu24.04_amd64.deb ...
Unpacking zabbix-agent2-plugin-mssql (1:7.4.0-1+ubuntu24.04) ...
Selecting previously unselected package zabbix-agent2-plugin-postgresql.
Preparing to unpack .../zabbix-agent2-plugin-postgresql_1%3a7.4.0-1+ubuntu24.04_amd64.deb ...
Unpacking zabbix-agent2-plugin-postgresql (1:7.4.0-1+ubuntu24.04) ...
Setting up zabbix-agent2-plugin-postgresql (1:7.4.0-1+ubuntu24.04) ...
Setting up zabbix-agent2-plugin-mssql (1:7.4.0-1+ubuntu24.04) ...
Setting up zabbix-agent2-plugin-mongodb (1:7.4.0-1+ubuntu24.04) ...
Scanning processes...
Scanning linux images...
Running kernel seems to be up-to-date.
No services need to be restarted.
No containers need to be restarted.
No user sessions are running outdated binaries.
No VM guests are running outdated hypervisor (qemu) binaries on this host.
■MySQL初期化
Create initial database
データベースサーバーが起動して実行されていることを確認してください。
【コマンド】
systemctl status mysql
【実行結果】
root@ip-10-0-1-139:~# systemctl status mysql
● mysql.service - MySQL Community Server
Loaded: loaded (/usr/lib/systemd/system/mysql.service; enabled; preset: enabled)
Active: active (running) since Mon 2025-07-21 07:40:55 UTC; 7min ago
Main PID: 11352 (mysqld)
Status: "Server is operational"
Tasks: 37 (limit: 9260)
Memory: 363.7M (peak: 377.8M)
CPU: 1.631s
CGroup: /system.slice/mysql.service
└─11352 /usr/sbin/mysqld
Jul 21 07:40:54 ip-10-0-1-139 systemd[1]: Starting mysql.service - MySQL Community Server...
Jul 21 07:40:55 ip-10-0-1-139 systemd[1]: Started mysql.service - MySQL Community Server.
次のコマンドを実行します。
【コマンド】
mysql -uroot
mysql> create database zabbix character set utf8mb4 collate utf8mb4_bin;
mysql> create user zabbix@localhost identified by 'password';
mysql> grant all privileges on zabbix.* to zabbix@localhost;
mysql> set global log_bin_trust_function_creators = 1;
mysql> quit;
【実行結果】
root@ip-10-0-1-139:~# mysql -uroot
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 8
Server version: 8.0.42-0ubuntu0.24.04.2 (Ubuntu)
Copyright (c) 2000, 2025, Oracle and/or its affiliates.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> create database zabbix character set utf8mb4 collate utf8mb4_bin;
Query OK, 1 row affected (0.01 sec)
mysql> create user zabbix@localhost identified by 'password';
Query OK, 0 rows affected (0.02 sec)
mysql> grant all privileges on zabbix.* to zabbix@localhost;
Query OK, 0 rows affected (0.00 sec)
mysql> set global log_bin_trust_function_creators = 1;
Query OK, 0 rows affected, 1 warning (0.00 sec)
mysql> quit;
Bye
Zabbixサーバーホストに初期スキーマとデータをインポートします。新しく作成したパスワードの入力を求められます。
【コマンド】
zcat /usr/share/zabbix/sql-scripts/mysql/server.sql.gz | mysql --default-character-set=utf8mb4 -uzabbix -p zabbix
【実行結果】
root@ip-10-0-1-139:~# zcat /usr/share/zabbix/sql-scripts/mysql/server.sql.gz | mysql --default-character-set=utf8mb4 -uzabbix -p zabbix
Enter password:
root@ip-10-0-1-139:~#
Disable log_bin_trust_function_creators option after importing database schema.データベース スキーマをインポートした後、log_bin_trust_function_creators オプションを無効にします。
【コマンド】
mysql -uroot
mysql> set global log_bin_trust_function_creators = 0;
mysql> quit;
【実行結果】
root@ip-10-0-1-139:~# mysql -uroot
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 10
Server version: 8.0.42-0ubuntu0.24.04.2 (Ubuntu)
Copyright (c) 2000, 2025, Oracle and/or its affiliates.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> set global log_bin_trust_function_creators = 0;
Query OK, 0 rows affected, 1 warning (0.00 sec)
mysql> quit;
Bye
root@ip-10-0-1-139:~#
etc/zabbix/zabbix_server.conf
編集します。
【コマンド】
sed -i 's/^# DBPassword=.*/DBPassword=password/' /etc/zabbix/zabbix_server.conf
【実行結果】
root@ip-10-0-1-139:~# sed -i 's/^# DBPassword=.*/DBPassword=password/' /etc/zabbix/zabbix_server.conf
root@ip-10-0-1-139:~#
■サービス起動と自動起動設定
Zabbixサーバおよびエージェントのプロセスを起動し、システムの起動時に起動するようにします。
【コマンド】
systemctl restart zabbix-server zabbix-agent2 apache2
systemctl enable zabbix-server zabbix-agent2 apache2 mysql
【実行結果】
root@ip-10-0-1-139:~# systemctl restart zabbix-server zabbix-agent2 apache2
root@ip-10-0-1-139:~# systemctl enable zabbix-server zabbix-agent2 apache2 mysql
Synchronizing state of zabbix-server.service with SysV service script with /usr/lib/systemd/systemd-sysv-install.
Executing: /usr/lib/systemd/systemd-sysv-install enable zabbix-server
Synchronizing state of zabbix-agent2.service with SysV service script with /usr/lib/systemd/systemd-sysv-install.
Executing: /usr/lib/systemd/systemd-sysv-install enable zabbix-agent2
Synchronizing state of apache2.service with SysV service script with /usr/lib/systemd/systemd-sysv-install.
Executing: /usr/lib/systemd/systemd-sysv-install enable apache2
Synchronizing state of mysql.service with SysV service script with /usr/lib/systemd/systemd-sysv-install.
Executing: /usr/lib/systemd/systemd-sysv-install enable mysql
Created symlink /etc/systemd/system/multi-user.target.wants/zabbix-server.service → /usr/lib/systemd/system/zabbix-server.service.
root@ip-10-0-1-139:~#
■Zabbix WebUI初期ウィザード
Zabbixサーバを動かすために必要なコマンドライン上でのパッケージのインストールおよび設定が完了しました。
つづいて、ZabbixのWebUIで初期設定を実施していきましょう。
ブラウザから、以下にアクセスしてください。
http:///zabbix
↓まずは、言語設定画面です。お好みの言語を選択し、[ Next step ]を押下します。
↓続いて、Zabbixサーバに必要な要件の確認ページです。問題なければ、[ Next step ]を押下します。
↓
↓データベースへの接続設定です。[ Password ]の項目には、MySQL初期化
の章で設定したパスワードを入力し、[ Next step ]を押下します。
↓つぎに[ Settings ]ページです。こちらもお好みの設定で問題ないです。
↓さいごに設定を確認し、[ Next step ]を押下します。
↓設定に成功しましたら、[ Finish ]を押下します。
↓ログイン画面が表示されますので、ログインしてみましょう。
デフォルトでは、以下の入力値でログインできます。
- Username: Admin
- Password: zabbix
↓ログインに成功しますと、つぎのようなダッシュボード画面が表示されます。
Zabbixサーバ構築は以上です。
まとめ
これで Ubuntu24.04上にZabbix7.4サーバを構築し、WebUIにログインしてローカルホストのメトリクスが流れ始めるところ まで到達しました。
これでもう「Zabbix サーバの立ち上げ」はクリア済みです。
次回は 監視対象ホストに Zabbix Agent 2を導入し、データが自動収集されることを確認します。
参考リンク: Zabbix マニュアル
↓ほかの協栄情報メンバーもZabbixについての記事を公開しています。ぜひ参考にしてみてください。
■Zabbixサーバーの構築手順 (Ubuntu22.04/Zabbix6.4)(mochizuki.t)