0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Debian12 に ZabbixServer を構築する

Last updated at Posted at 2025-05-20

環境

  • ProxmoxVE 8.2.4 上にある Virtual Machine
  • Debian 12.6.0-amd64-netinst.iso

構築予定の環境

image.png

Zabbix 公式サイトより https://www.zabbix.com/jp/download

作業内容

1. 初期設定

2. Zabbix

a.リポジトリ?レポジトリ?をwgetしてくる

manager@debian:~$ wget https://repo.zabbix.com/zabbix/7.2/release/debian/pool/main/z/zabbix-release/zabbix-release_latest_7.2+debian12_all.deb

ここら辺はZabbix公式サイトにも書いてある

dpkg.deb のインストールを行う

manager@debian:~$ sudo dpkg -i zabbix-release_latest_7.2+debian12_all.deb

b. Zabbix 関連をインストールする

パッケージを更新

manager@debian:~$ sudo apt update

インストール

manager@debian:~$ sudo apt install zabbix-server-mysql zabbix-frontend-php zabbix-nginx-conf zabbix-sql-scripts zabbix-agent

3. MySQL

ここら辺の作業が公式サイトでは省略されていたので手順を書くことにした

a. リポジトリ?レポジトリ?をwgetしてくる

MySQL の公式サイトから .deb のダウンロードリンクをコピーする

image.png

image.png

manager@debian:~$ wget https://dev.mysql.com/get/mysql-apt-config_0.8.34-1_all.deb

b. MySQL をインストールする

dpkgでwgetした .deb のインストールを行う

manager@debian:~$ sudo dpkg -i mysql-apt-config_0.8.34-1_all.deb

ところがエラーが出ました
image.png

どうやら gnupg に依存してるらしい

gnupgで検索をしてみる

manager@debian:~$ sudo apt search gnupg

発見

image.png

これで安心してインストールできます

gnupgをインストールする

manager@debian:~$ sudo apt install gnupg

再度 sudo dpkg -i mysql-apt-config_0.8.34-1_all.deb を実行

何か出てきました
"OK" を押す
image.png

十字キーを操作し"OK" を選択する
image.png

CLIに戻されます

パッケージをインストールしたので apt update を行いパッケージを更新してあげます

manager@debian:~$ sudo apt update

mysql-serverのインストールを行っていきます

mysql-server を検索してみる

manager@debian:~$ sudo apt search mysql-server

発見

image.png

mysql-server をインストール

manager@debian:~$ sudo apt install mysql-server

ところがエラーが出ました
image.png

すでに入っているパッケージと競合を起こしているみたい

一応 mariadb-client-core で検索をしてみる

manager@debian:~$ sudo apt list | grep mariadb-client-core

発見
image.png

mariadb-client-coreapt remove --purge で消します

manager@debian:~$ sudo apt remove --purge mariadb-client-core

再度 sudo apt install mysql-server を実行

image.png

MySQL database で使うパスワードを入力します

ここで決めたパスワードは PASSWORD ということにしておきます

再度入力
image.png

入力がただしく行われればプロセスの続きが始まります

これで MySQL のインストールは終了しました。

c. MySQL の初期データベースを作成する

ここからの作業はZabbix公式サイトにも載っています
https://www.zabbix.com/jp/download

manager@debian:~$ mysql -u root -p

PASSWORD を入力しログイン

成功すればmysqlのコンソール的な画面に切り替わります
image.png

これらを実行

mysql> create database zabbix character set utf8mb4 collate utf8mb4_bin;

ここで入力したパスワードはpasswordということにしておきます

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;

mysqlコンソールを閉じたら

Zabbixサーバーホストに初期スキーマとデータをインポートします

manager@debian:~$ zcat /usr/share/zabbix/sql-scripts/mysql/server.sql.gz | mysql --default-character-set=utf8mb4 -uzabbix -p zabbix 

パスワードの入力を求めらるので先ほど指定した password を入力

log_bin_trust_function_creators オプションを無効にする

manager@debian:~$ mysql -u root -p

PASSWORD を入力

mysql> set global log_bin_trust_function_creators = 0;
mysql> quit;

image.png

4. 各種設定ファイルの編集

zabbix_server.conf を編集する

manager@debian:~$ nano /etc/zabbix/zabbix_server.conf

DBPasswordpassword を入力

zabbix_server.conf
# This is a configuration file for Zabbix server daemon
# To get more information about Zabbix, visit https://www.zabbix.com

############ GENERAL PARAMETERS #################

~~~~~~~省略~~~~~~~

### Option: DBUser
#       Database user.
#
# Mandatory: no
# Default:
# DBUser=

DBUser=zabbix

### Option: DBPassword
#       Database password.
#       Comment this line if no password is used.
#
# Mandatory: no
# Default:
- # DBPassword=
+ DBPassword=password

保存して閉じる

nginx.conf を編集する

manager@debian:~$ sudo nano /etc/zabbix/nginx.conf

listenserver_name をコメント解除する

nginx.conf
server {
- #     listen          8080;
- #     server_name     example.com;
+       listen          8080;
+       server_name     example.com;

        root    /usr/share/zabbix/ui;

        index   index.php;

~~~~~~~省略~~~~~~~

保存して閉じる

各サービスの再起動

manager@debian:~$ sudo systemctl restart zabbix-server zabbix-agent nginx php8.2-fpm

各サービスの自動起動を有効化

manager@debian:~$ sudo systemctl enable zabbix-server zabbix-agent nginx php8.2-fpm 

5. Webインターフェースにアクセス

まず ufw で接続ポートを許可しておきます

manager@debian:~$ sudo ufw allow 8080/tcp

nginx.conflisten で指定したポートで鯖のIPにアクセス

image.png

うまくいけばこのようなサイトが表示されているはずです。

6. Wellcome to Zabbix

a. Wellcome

image.png

Next step を押して次へ

b. Check of pre-requisites

image.png

全部 OK になっていることを確認する

Next step を押して次へ

c. Configure DB connection

image.png

Password = password

Next step を押して次へ

d. Settings

image.png

Zabbix server name = 任意の名前を入力する

Default time zone = 日本に住んでいる方はAsia/Tokyoを気合で探して選択してください

Default theme = 任意のテーマを選ぶ

Next step を押して次へ

e. Pre-installation summary

image.png

設定に誤りがないか確認してください

Next step を押して次へ

f. Install

image.png

Congratulations! You have successfully installed Zabbix frontend

Finish を押してログイン画面へ

g. ZABBIX

image.png

初期パスワードを用いてAdminユーザーでログインします

Username = Admin

Password = zabbix

Sign in を押してサインイン

image.png

これにて Debian12 に ZabbixServer を構築する のすべての作業が終了しました

お疲れさまでした。

引用

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?