2022年12月22日木曜日

Zabbix 6.0 をインストールしてみる

稼働機器の監視用に Zabbix 6.0 をインストールしてみました。設定は別記事で書くことにします。

スモールスタートで、どんな事ができるかの確認用となります。ゴールとしては、稼働機器に対し

  • pingによる稼働確認
  • 障害発生時のメール送信

とします。

インストール対象の OSは RockyLinux 8 です。

【apacheのインストールと起動】
dnf install httpd
systemctl start httpd
systemctl enable httpd

【epelリポジトリの追加】
dnf install https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm

【php関連のインストール】
 dnf install php php-fpm php-mysqlnd php-ldap php-bcmath php-mbstring php-gd php-pdo php-xml

【MariaDBのインストールと起動】
MySQL ではなく MariaDB を使うこととします。Zabbix は DB のバージョンにうるさいので、デフォルトの 10.3 から 10.5 に切り替えてインストールします。
※依存関係のインストールで perl関連がゴッチャリ追加されます。

dnf module list mariadb
メタデータの期限切れの最終確認: 0:10:11 時間前の 2022年12月21日 23時17分56秒 に実施しました。
Rocky Linux 8 - AppStream
Name                 Stream                Profiles                               Summary
mariadb              10.3 [d]              client, galera, server [d]             MariaDB Module
mariadb              10.5                  client, galera, server [d]             MariaDB Module

dnf module enable mariadb:10.5
dnf install mariadb mariadb-server mariadb-devel
mysql --version (10.5.x なことを確認)
systemctl start mariadb
systemctl enable mariadb


【MariaDBのセキュリティ設定】
mariadb-secure-installation
デフォルトが 'Y' なので、Enterキーの押下のみでok。ただし、Change the root password? と聞かれた場合はお好みのパスワードをセットすること。(パスワードを設定しないと先に進みません。)

【Zabbixリポジトリの追加】
追加用のリポジトリを https://repo.zabbix.com/zabbix/6.0/rhel/8/x86_64 で確認。複数あると思うので、最新のものを設定することとする。
dnf install https://repo.zabbix.com/zabbix/6.0/rhel/8/x86_64/zabbix-release-6.0-4.el8.noarch.rpm

【Zabbix及び関連パッケージのインストール】
dnf install zabbix-server-mysql zabbix-web-mysql zabbix-web-japanese zabbix-apache-conf zabbix-sql-scripts

【/etc/php-fpm.d/zabbix.conf の設定変更】
php_value[date.timezone] = Asia/Tokyo
を最下行に追加し保存して終了

【/etc/php.ini の設定変更】
902行目あたり、行頭の ; を外しタイムゾーンの設定をする。
date.timezone = Asia/Tokyo
に変更し保存して終了

【php-fpm の起動】
systemctl start php-fpm
systemctl enable php-fpm

【Zabbix用データベースの作成】
mysql -uroot -p

Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 15
Server version: 10.6.10-MariaDB MariaDB Server

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MariaDB [(none)]> CREATE DATABASE zabbix character set utf8 collate utf8_bin;
Query OK, 1 row affected (0.002 sec)

MariaDB [(none)]> CREATE USER zabbix@localhost IDENTIFIED BY 'TEST1234';
Query OK, 0 rows affected (0.005 sec)

MariaDB [(none)]> GRANT ALL ON zabbix.* TO zabbix@localhost;
Query OK, 0 rows affected (0.001 sec)

MariaDB [(none)]> quit;
Bye

※パスワードは TEST1234 にしてみました。 

zcat /usr/share/zabbix-sql-scripts/mysql/server.sql.gz | mysql -u zabbix -p zabbix
Enter password: (この例では TEST1234 ですね)

mysql -u zabbix -p zabbix
Enter password: (この例では TEST1234 ですね)

Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 17
Server version: 10.6.10-MariaDB MariaDB Server

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [zabbix]> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| zabbix             |  ← zabbix があること
+--------------------+
2 rows in set (0.002 sec)

MariaDB [zabbix]> use zabbix;
Database changed
MariaDB [zabbix]> show tables;
+----------------------------+
| Tables_in_zabbix           |
+----------------------------+
| acknowledges               |
| actions                    |
(中略)
| widget                     |
| widget_field               |
+----------------------------+
173 rows in set (0.004 sec)  ← 概ね170個程度あればok
MariaDB [zabbix]> quit;
Bye

【zabbix_server.conf の設定変更】
129行目あたり、行頭の # を外し、設定したパスワードを記述する。
DBPassword= (この例では TEST1234 ですね)
保存して終了

【zabbix_server の起動】
systemctl start zabbix-server
systemctl enable zabbix-server

【Zabbix Agent 2のインストール】
Zabbix Server自体をエージェント監視してみる。
dnf install zabbix-agent2

【/etc/zabbix/zabbix_agent2.conf の設定変更】
自身の監視のみのため特になし。好みにより144行目あたりの Hostname を変更する。

【Zabbix Agent 2の起動】
systemctl start zabbix-agent2
systemctl enable zabbix-agent2

【net-snmp のインストール】
dnf install net-snmp net-snmp-utils

【snmpd.conf  の設定変更】
テストなのでデフォルトでも ok。ちょっとセキュリティを高めたい場合は 14行目あたりの default を特定のセグメント、コミュニティ名をお好みに変更する。

トラップも受信したいときは /etc/snmp/snmptrapd.conf の編集と snmptrapd の起動・有効化を忘れずに。 

【net-snmp の起動】
systemctl start snmpd
systemctl enable snmpd

ここまでで一通り完了。次は GUI の管理画面から Zabbix の設定を行います。ブラウザを起動し、次の URL を入力。
http://[Zabbixをインストールした機器のIPアドレス]/zabbix

ようこそ
デフォルトの言語を日本語にして[次のステップ]をクリック。(日本語必須ではありませんが、せっかく多言語対応しているので使いましょう。)


前提条件のチェック
すべて OK が表示されていることを確認。スクロールして一番下まで確認したら[次のステップ]をクリック。

データベース接続設定
DBの認証情報はHashiCorp Vaultから取得することも可能ですが、今回は「プレーンテキスト」を選択し、Zabbix自身に認証情報の設定を行います。「パスワード」は各人の設定したものを入力し(この例では TEST1234 ですね)[次のステップ]をクリック。


設定
[Zabbixサーバー名]に任意の名前を設定。
「デフォルトのタイムゾーン」の箇所に、「(UTC+09:00) Asia/Tokyo」を選択し、「次のステップ」をクリック。
※「デフォルトのテーマ」は Blue で。別のものに変えたいときはテーマを選ぶと画面が変化するのでお好きなものを。



インストール事前準備概要
設定した内容が表示されるので、問題がなければ「次のステップ」をクリック。



インストール
おめでとうございます!Webインターフェースのインストールが終了しました。
が表示されたら[終了]をクリック。

お疲れさまでした。


0 件のコメント:

コメントを投稿