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?

More than 3 years have passed since last update.

Zabbix5.2をRHEL8にインストールする

Posted at

はじめに

Zabbix5.2をRHEL8にインストールした際の手順をまとめました。

Zabbix5.2は、2020年10月27日にリリースされ、2021年4月現在Zabbix5.2.6が最新となります。
Zabbix 5.2の新機能

システム構成

今回使用したソフトウェアとバージョンは、以下の通りです。

・Zabbix : Zabbix 5.2.6
・OS : RHEL8.3
・Webサーバー : Apache HTTP Server 2.4.37
・PHP : PHP 7.2.24
・DBMS : MariaDB 10.3.27

環境及び前提
・導入対象サーバーは、インターネットと疎通可能
・Zabbix Server、関連パッケージ、Zabbix Agentを1台のサーバーにAll-in-Oneで導入する
・SELinuxは、Permissiveの状態で導入
・各手順は、root権限を持つユーザで実施
・firewallは、HTTP(80/tcp) 、HTTPS(443/tcp) 、10050/tcp、10051/tcpを開放

1. MariaDBのインストール

Zabbix 5.2 のインストールの前に、MariaDB をインストールして設定します。

MariaDBのインストール

$ yum install mariadb-server
$ systemctl start mariadb
$ systemctl enable mariadb

mysqlのrootパスワード設定や不要な設定削除のため、mysql_secure_installationを利用してセキュリティの初期設定を行います。

$ mysql_secure_installation
(略)
In order to log into MariaDB to secure it, we'll need the current
password for the root user.  If you've just installed MariaDB, and
you haven't set the root password yet, the password will be blank,
so you should just press enter here.

Enter current password for root (enter for none):   <- Enterを入力
OK, successfully used password, moving on...

Setting the root password ensures that nobody can log into the MariaDB
root user without the proper authorisation.

Set root password? [Y/n] y           <- yを入力
New password:                                <- DBユーザ-rootのパスワードを入力
Re-enter new password:                       <- 再度パスワードを入力
Password updated successfully!
Reloading privilege tables..
 ... Success!


By default, a MariaDB installation has an anonymous user, allowing anyone
to log into MariaDB without having to have a user account created for
them.  This is intended only for testing, and to make the installation
go a bit smoother.  You should remove them before moving into a
production environment.

Remove anonymous users? [Y/n] y        <- yを入力(不要なユーザーを削除)
 ... Success!

Normally, root should only be allowed to connect from 'localhost'.  This
ensures that someone cannot guess at the root password from the network.

Disallow root login remotely? [Y/n] y     <- yを入力(rootのリモートログイン禁止)
 ... Success!

By default, MariaDB comes with a database named 'test' that anyone can
access.  This is also intended only for testing, and should be removed
before moving into a production environment.

Remove test database and access to it? [Y/n] y  <- yを入力(不要なDBを削除)
 - Dropping test database...
 ... Success!
 - Removing privileges on test database...
 ... Success!

Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.

Reload privilege tables now? [Y/n] y       <- yを入力
 ... Success!

Cleaning up...

All done!  If you've completed all of the above steps, your MariaDB
installation should now be secure.

Thanks for using MariaDB!

MariaDBの構成ファイルを編集し、デフォルト文字コードなどを設定します。

$ vi /etc/my.cnf.d/mariadb-server.cnf
(略)
[mysqld]
character-set-server = utf8
collation-server     = utf8_bin
skip-character-set-client-handshake
innodb_file_per_table
(略)

MariaDBの再起動します。

$ systemctl restart mariadb

2. Zabbixのインストール

公式サイトの手順を参考に導入していきます。

2.1 Zabbix LLCリポジトリの登録

※今後新しいバージョンのパッケージが公開される可能性がありますので、以下の公式リポジトリで、確認が必要です。
https://repo.zabbix.com/zabbix/5.2/rhel/8/x86_64/

リポジトリ登録後、キャッシュを削除しておきます。

$ rpm -Uvh https://repo.zabbix.com/zabbix/5.2/rhel/8/x86_64/zabbix-release-5.2-1.el8.noarch.rpm
$  dnf clean all

2.2 Zabbix Serverパッケージのインストール

Zabbix Server関連のパッケージをインストールします。

$ dnf -y install zabbix-server-mysql zabbix-web-japanese zabbix-apache-conf

2.3 Zabbix Agentのインストール

今回の構成では、Zabbix Agent2をインストールします。

$ dnf -y install zabbix-agent2

3. Zabbixの初期設定

3.1 Zabbix用のDB作成

MariaDB上にデータベースとユーザを作成します。

$ mysql -uroot -p
Enter password:    <- DBユーザ-rootのパスワードを入力
(略)
MariaDB [(none)]> create database zabbix character set utf8 collate utf8_bin;
Query OK, 1 row affected (0.001 sec)

MariaDB [(none)]> create user zabbix@localhost identified by 'DBユーザzabbixのパスワードを入力';
Query OK, 0 rows affected (0.001 sec)

MariaDB [(none)]> grant all privileges on zabbix.* to zabbix@localhost;
Query OK, 0 rows affected (0.001 sec)

MariaDB [(none)]> quit;
Bye

Zabbix用のDBスキーマと初期データをインポートします。

$ zcat /usr/share/doc/zabbix-server-mysql*/create.sql.gz | mysql -uzabbix -p zabbix
Enter password:    <- DBユーザーzabbixのパスワードを入力 

3.2 Zabbix Serverの構成

Zabbix Serverの構成ファイルを編集し、Zabbix用DBのパスワードをDBPasswordに設定します。

$ vi /etc/zabbix/zabbix_server.conf
DBPassword=<DBユーザzabbixのパスワード>

3.3 PHPのタイムゾーンを日本に設定

PHP-FPM の構成ファイルでタイムゾーン行のコメントアウトを外し、Asia/Tokyoに変更します。

$ vi /etc/php-fpm.d/zabbix.conf
; php_value[date.timezone] = Europe/Riga
↓
php_value[date.timezone] = Asia/Tokyo

3.4 Zabbix Agentの構成

Zabbix Agentの構成ファイルを編集し、接続先Zabbix ServerとAgentホスト名を設定します。

$ vi /etc/zabbix/zabbix_agent2.conf
# 監視通信を許可するZabbix ServerのIPアドレス
# 今回の構成では、Zabbix Server自身にAgentを導入しているので値を変更しない
# Zabbix Server以外のマシンにAgentを構成する場合は、Zabbix ServerのIPアドレスを指定する
Server=127.0.0.1

# ActiveCheckのデータ送信先Zabbix Server IPアドレス
# 今回の構成では、Zabbix Server自身にAgentを導入しているので値を変更しない
ServerActive=127.0.0.1

# Agentのホスト名(OSのhostnameではなく、zabbixに登録するホスト名)
Hostname=Zabbix server
↓
Hostname=<ホスト名>

3.4 サービス再起動と自動起動の有効化

$ systemctl restart zabbix-server zabbix-agent2 httpd php-fpm
$ systemctl enable zabbix-server zabbix-agent2 httpd php-fpm

3.5 Zabbixフロントエンドの構成

ブラウザで下記URLを開き、設定を行います。
http://<Zabbix ServerのIPアドレス>/zabbix
スクリーンショット 2021-04-07 15.29.07.png

「Default language」で、「日本語 (ja_JP)」を選択します。
言語表示が日本語に切り替わるので、「次のステップ」をクリックします。
スクリーンショット 2021-04-07 15.29.22.png
前提条件のチェックで、全ての項目が「OK」になっていることを確認して、「次のステップ」をクリックします。
スクリーンショット 2021-04-07 15.29.36.png
「パスワード」欄に、DBユーザzabbixのパスワードを入力を入力し「次のステップ」をクリックします。
スクリーンショット 2021-04-07 15.30.12.png
サーバーの詳細は、デフォルトのまま「次のステップ」をクリックします。
スクリーンショット 2021-04-07 15.30.50.png
タイムゾーンとテーマはデフォルトのままとし、「次のステップ」をクリックします。
スクリーンショット 2021-04-07 15.33.29.png

最終確認画面で間違いがなければ「次のステップ」をクリックします。
スクリーンショット 2021-04-07 15.33.44.png

「おめでとうございます!Webインターフェースのインストールが終了しました。」が表示されていることを確認し、「終了」をクリックします。
スクリーンショット 2021-04-07 15.34.28.png

ログイン画面が表示されるので、下の初期ユーザーとパスワードでログインします。
ユーザ:   Admin
パスワード: zabbix

スクリーンショット 2021-04-07 15.36.48.png
ダッシュボードが表示されることを確認し、インストールは完了です。
スクリーンショット 2021-04-07 15.37.49.png

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?