はじめに
-
Ubuntu 24.04
上で 公式の資料に沿ったDocker Compose
によるZabbix
の監視環境を構築 - Docker Compose で起動している Zabbix のサービス化も行います
- 記事作成環境は
Proxmox VE 8.3
上のUbuntu 24.04
環境
$ uname -a
Linux zabbix 6.8.0-53-generic #55-Ubuntu SMP PREEMPT_DYNAMIC Fri Jan 17 15:37:52 UTC 2025 x86_64 x86_64 x86_64 GNU/Linux
$ cat /etc/lsb-release
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=24.04
DISTRIB_CODENAME=noble
DISTRIB_DESCRIPTION="Ubuntu 24.04.2 LTS"
$ cat /etc/os-release
PRETTY_NAME="Ubuntu 24.04.2 LTS"
NAME="Ubuntu"
VERSION_ID="24.04"
VERSION="24.04.2 LTS (Noble Numbat)"
VERSION_CODENAME=noble
ID=ubuntu
ID_LIKE=debian
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
UBUNTU_CODENAME=noble
LOGO=ubuntu-logo
Docker, Docker Composeのインストール
以下の記事に従ってインストール
Zabbix (7.2) のインストール(コンテナ)
- 後のサービス化を考慮して、
/usr/local/bin
にインストールを行う。
$ cd /usr/local/bin
$ sudo git clone https://github.com/zabbix/zabbix-docker.git
$ cd zabbix-docker
$ sudo git branch
* 7.2
$ docker compose pull
[+] Pulling 28/28
✔ server-db-init Skipped - Image is already being pulled by zabbix-server 0.0s
✔ db-data-mysql Pulled 9.9s
✔ 9c0abc9c5bd3 Pull complete 6.1s
✔ zabbix-web-nginx-mysql Pulled 11.9s
✔ 1f3e46996e29 Pull complete 1.1s
✔ 7a1b5df8fa79 Pull complete 2.7s
✔ 0d2fd0a95e93 Pull complete 2.8s
✔ 7744d086dfcc Pull complete 8.1s
✔ 4f4fb700ef54 Pull complete 9.2s
✔ c761ad0bf1c6 Pull complete 8.3s
✔ zabbix-server Pulled 12.9s
✔ e1f07e99006c Pull complete 6.2s
✔ 2074a21df4fc Pull complete 6.4s
✔ bf301a638547 Pull complete 6.7s
✔ 12d27eb5c895 Pull complete 7.2s
✔ 180c8e0a79a0 Pull complete 8.9s
✔ c02ace620a69 Pull complete 9.1s
✔ mysql-server Pulled 18.7s
✔ 43759093d4f6 Pull complete 7.8s
✔ 8f4990895e9b Pull complete 7.8s
✔ ea8168080d59 Pull complete 8.1s
✔ 995a8777e754 Pull complete 8.5s
✔ 80cf8eab0d72 Pull complete 8.6s
✔ dd6d73b138d4 Pull complete 8.7s
✔ 6966698f1fbd Pull complete 10.0s
✔ 227358103edf Pull complete 10.1s
✔ c155d1f8af49 Pull complete 15.0s
✔ f0bda43a95fb Pull complete
$ docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
zabbix/zabbix-web-nginx-mysql alpine-7.2-latest 881b3c605112 8 days ago 266MB
zabbix/zabbix-server-mysql alpine-7.2-latest 318e84e2cff3 8 days ago 106MB
hello-world latest 74cc54e27dc4 4 weeks ago 10.1kB
mysql 8.4-oracle 9755c387b39e 4 weeks ago 769MB
busybox latest 31311c5853a2 4 months ago 4.27MB
Zabibxの起動
$ docker compose up -d
[+] Running 11/11
✔ Network zabbix-docker_default Created 0.0s
✔ Network zabbix-docker_database Created 0.0s
✔ Network zabbix-docker_tools_frontend Created 0.0s
✔ Network zabbix-docker_backend Created 0.0s
✔ Network zabbix-docker_frontend Created 0.0s
✔ Volume "zabbix-docker_snmptraps" Created 0.0s
✔ Container zabbix-docker-db-data-mysql-1 Started 0.5s
✔ Container zabbix-docker-mysql-server-1 Started 0.5s
✔ Container zabbix-docker-server-db-init-1 Exited 84.7s
✔ Container zabbix-docker-zabbix-web-nginx-mysql-1 Started 85.2s
✔ Container zabbix-docker-zabbix-server-1 Started 85.2s
$ docker compose ps
Name Command State Ports
---------------------------------------------------------------------------------------------------------------------------------------------------------------------
zabbix-docker_db_data_mysql_1 sh Exit 0
zabbix-docker_mysql-server_1 docker-entrypoint.sh mysql ... Up
zabbix-docker_zabbix-server_1 /usr/bin/tini -- /usr/bin/ ... Up 0.0.0.0:10051->10051/tcp,:::10051->10051/tcp
zabbix-docker_zabbix-web-nginx-mysql_1 docker-entrypoint.sh Up (healthy) 0.0.0.0:80->8080/tcp,:::80->8080/tcp, 0.0.0.0:443->8443/tcp,:::443->8443/tcp
起動ログの確認
$ docker compose logs -f
ブラウザでアクセス
http://<IPアドレスまたはホスト名>
- 初期ユーザIDとパスワードは、Admin/zabbix
サービス化
systemd のユニットファイルを作成
- ユニットファイル
/etc/systemd/system/docker-compose-service@.service
を作成する
/etc/systemd/system/docker-compose-service@.service
[Unit]
Description=%i managed by docker compose
Requires=docker.service
[Service]
Type=simple
Environment=COMPOSE_FILE=/usr/local/bin/%i/compose.yaml
ExecStartPre=-/usr/bin/docker compose -f ${COMPOSE_FILE} down --volumes
ExecStart=/usr/bin/docker compose -f ${COMPOSE_FILE} up
ExecStop=/usr/bin/docker compose -f ${COMPOSE_FILE} down --volumes
[Install]
WantedBy=multi-user.target
systemd のサービス登録
$ sudo systemctl enable docker-compose-service@zabbix-docker
systemd でサービス化した zabbix を起動
$ sudo systemctl start docker-compose-service@zabbix-docker
systemd でサービス化した zabbix の動作確認
- terminal で確認
$ sudo systemctl status docker-compose-service@zabbix-docker
または compose.yaml
のあるディレクトリで
$ docker-compose logs -f
- ブラウザでもAdmin/zabbixでログインして確認
systemd でサービス化した zabbix を停止
$ sudo systemctl stop docker-compose-service@zabbix-docker
systemd のサービス解除
$ sudo systemctl disable docker-compose-service@zabbix-docker
監視対象への Zabiix Agent 2
のインストール
以下の記事に従ってインストール
データベースの削除
- コンテナを削除してもデータベースが残るので、以下を削除
$ sudo rm -rf zbx_env/var/lib/mysql/*
リンク
- Zabbix Documentation (7.2) - 5 Installation from containers - Docker Compose
- 【2024年08月版】Ubuntu への Docker / DockerCompose インストールメモ
- 【2025年02月版】Zabbix Agent 2 のインストール メモ
終わりに
かんたんでしたね