Zabbixインストール先
Zabbixをインストールするには下記サイトから使用するミドルウェアを選択の上
パッケージのダウンロードが必要になってきます。
【Zabbixダウンロード先】
https://www.zabbix.com/jp/download
Zabbix構成
今回作成するZabbixの構成としては以下となります。
Zabbix 5.0.45
Apache 2.4.62
Mariadb 5.5.68
PHP rh-php72-1-2
手順1 事前準備
まず最初にパッケージのアップデートを行います。
[root@localhost ~]# yum -y update
Zabbixのインストールされていない確認する
[root@localhost ~]# rpm -qa |grep zabbix
[root@localhost ~]#
SELinuxが無効化となっていることを確認する。デフォルトでは「Disabled」
Permissiveでも動作に問題ないが今回は無効化にしておく。
[root@localhost ~]# getenforce
Disabled
手順2 パッケージインストール
Apache,Mariadb,PHP,Zabbixのパッケージをインストールしていきます。
■Apache
[root@localhost ~]# yum install httpd
■PHP
PHPについてはデフォルトのパッケージバージョンがPHP5.4となり、
Zabbixの要件ではSCLのPHP7.2が必要になってくるため必要なRPMパッケージを個別にする
■RH-PHP
https://ftp.iij.ad.jp/pub/linux/centos-vault/7.6.1810/sclo/x86_64/rh/rh-php72
[root@localhost ~]# rpm -qa |grep rh-php
rh-php72-php-zip-7.2.10-3.el7.x86_64
rh-php72-php-process-7.2.10-3.el7.x86_64
rh-php72-php-mysqlnd-7.2.10-3.el7.x86_64
rh-php72-php-ldap-7.2.10-3.el7.x86_64
rh-php72-php-json-7.2.10-3.el7.x86_64
rh-php72-php-common-7.2.10-3.el7.x86_64
rh-php72-php-pdo-7.2.10-3.el7.x86_64
rh-php72-php-xml-7.2.10-3.el7.x86_64
rh-php72-1-2.el7.x86_64
rh-php72-php-bcmath-7.2.10-3.el7.x86_64
rh-php72-php-gd-7.2.10-3.el7.x86_64
rh-php72-php-mbstring-7.2.10-3.el7.x86_64
rh-php72-runtime-1-2.el7.x86_64
rh-php72-php-cli-7.2.10-3.el7.x86_64
rh-php72-php-pear-1.10.5-1.el7.noarch
rh-php72-php-fpm-7.2.10-3.el7.x86_64
■Mariadb
[root@localhost ~]# yum install mariadb-server
■Zabbix
[root@localhost ~]# rpm -Uvh https://repo.zabbix.com/zabbix/5.0/rhel/7/x86_64/zabbix-release-latest.el7.noarch.rpm
[root@localhost ~]# yum clean all
# キャッシュの削除
[root@localhost ~]# yum install zabbix-server-mysql zabbix-agent
[root@localhost ~]# vi /etc/yum.repos.d/zabbix.repo
[zabbix-frontend]
name=Zabbix Official Repository frontend - $basearch
baseurl=http://repo.zabbix.com/zabbix/5.0/rhel/7/$basearch/frontend
enabled=0 # 0から1へ変更
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX-A14FE591
[root@localhost ~]# yum install zabbix-server-mysql zabbix-agent zabbix-web-japanese.noarch zabbix-web-mysql-scl zabbix-apache-conf-scl
手順3.DB設定手順
DBの初期設定を実施します。
[root@localhost ~]# mysql_secure_installation
NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB
SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY!
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):
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)
初期設定時にMariadbのプロセスを未起動状態だと上記のエラーが出力されてしまいます。
■プロセス起動
[root@localhost ~]# systemctl start mariadb
[root@localhost ~]# systemctl status mariadb
● mariadb.service - MariaDB database server
Loaded: loaded (/usr/lib/systemd/system/mariadb.service; disabled; vendor preset: disabled)
Active: active (running) since Mon 2024-12-02 07:15:21 UTC; 4s ago
Process: 3556 ExecStartPost=/usr/libexec/mariadb-wait-ready $MAINPID (code=exited, status=0/SUCCESS)
Process: 3473 ExecStartPre=/usr/libexec/mariadb-prepare-db-dir %n (code=exited, status=0/SUCCESS)
Main PID: 3555 (mysqld_safe)
CGroup: /system.slice/mariadb.service
tq3555 /bin/sh /usr/bin/mysqld_safe --basedir=/usr
mq3721 /usr/libexec/mysqld --basedir=/usr --datadir=/var/lib/mysql --...
Dec 02 07:15:19 localhost mariadb-prepare-db-dir[3473]: MySQL manual for more in...
Dec 02 07:15:19 localhost mariadb-prepare-db-dir[3473]: Please report any proble...
Dec 02 07:15:19 localhost mariadb-prepare-db-dir[3473]: The latest information a...
Dec 02 07:15:19 localhost mariadb-prepare-db-dir[3473]: You can find additional ...
Dec 02 07:15:19 localhost mariadb-prepare-db-dir[3473]: http://dev.mysql.com
Dec 02 07:15:19 localhost mariadb-prepare-db-dir[3473]: Consider joining MariaDB...
Dec 02 07:15:19 localhost mariadb-prepare-db-dir[3473]: https://mariadb.org/get-...
Dec 02 07:15:19 localhost mysqld_safe[3555]: 241202 07:15:19 mysqld_safe Loggin....
Dec 02 07:15:19 localhost mysqld_safe[3555]: 241202 07:15:19 mysqld_safe Starti...l
Dec 02 07:15:21 localhost systemd[1]: Started MariaDB database server.
Hint: Some lines were ellipsized, use -l to show in full.
[root@localhost ~]#
[root@localhost ~]# mysql_secure_installation
NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB
SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY!
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):
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
New password:
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
... 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
... 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
- 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
... 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!
[root@localhost ~]#
■ログイン確認・DB設定
[root@localhost ~]# mysql -u root -p
Enter password: #先ほど作成したパスワードを入力
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 10
Server version: 5.5.68-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)]>
MariaDB [(none)]> create database zabbix character set utf8 collate utf8_bin;
Query OK, 1 row affected (0.01 sec)
MariaDB [(none)]> create user zabbix@localhost identified by 'password';
#'password'はご自由にお決めください
Query OK, 0 rows affected (0.00 sec)
MariaDB [(none)]> grant all privileges on zabbix.* to zabbix@localhost;
Query OK, 0 rows affected (0.00 sec)
MariaDB [(none)]> set global log_bin_trust_function_creators = 1;
Query OK, 0 rows affected (0.00 sec)
MariaDB [(none)]> quit;
Bye
■スキーマの投入
「create.sql.gz」ファイルは、Zabbix のテーブルやインデックス、ビュー、初期データを MySQL データベースに作成するために使用されます。
[root@localhost ~]# zcat /usr/share/doc/zabbix-server-mysql-5.0.45/create.sql.gz | mysql -uzabbix -p zabbix
Enter password: #ここに先ほどのDBのパスワードを投入する
[root@localhost ~]#
手順4.PHP設定
[root@localhost ~]# vi /etc/opt/rh/rh-php72/php-fpm.d/zabbix.conf
; php_value[date.timezone] = Europe/Riga
↓
php_value[date.timezone] = Asia/Tokyo
手順5.Zabbix設定
[root@localhost ~]# vi /etc/zabbix/zabbix_server.conf
# DBPassword=
↓
DBPassword=password
手順6.サービス起動
[root@localhost ~]# systemctl restart zabbix-server zabbix-agent httpd rh-php72-php-fpm
[root@localhost ~]#
[root@localhost ~]#
[root@localhost ~]# systemctl status zabbix-server zabbix-agent httpd rh-php72-php-
fpm
● zabbix-server.service - Zabbix Server
Loaded: loaded (/usr/lib/systemd/system/zabbix-server.service; disabled; vendor preset: disabled)
Active: active (running) since Mon 2024-12-02 07:32:43 UTC; 29s ago
Process: 3993 ExecStart=/usr/sbin/zabbix_server -c $CONFFILE (code=exited, status=0/SUCCESS)
Main PID: 4005 (zabbix_server)
CGroup: /system.slice/zabbix-server.service
mq4005 /usr/sbin/zabbix_server -c /etc/zabbix/zabbix_server.conf
Dec 02 07:32:43 localhost systemd[1]: Starting Zabbix Server...
Dec 02 07:32:43 localhost systemd[1]: Started Zabbix Server.
● zabbix-agent.service - Zabbix Agent
Loaded: loaded (/usr/lib/systemd/system/zabbix-agent.service; disabled; vendor preset: disabled)
Active: active (running) since Mon 2024-12-02 07:32:43 UTC; 29s ago
Process: 3994 ExecStart=/usr/sbin/zabbix_agentd -c $CONFFILE (code=exited, status=0/SUCCESS)
Main PID: 3998 (zabbix_agentd)
CGroup: /system.slice/zabbix-agent.service
tq3998 /usr/sbin/zabbix_agentd -c /etc/zabbix/zabbix_agentd.conf
tq3999 /usr/sbin/zabbix_agentd: collector [idle 1 sec]
tq4000 /usr/sbin/zabbix_agentd: listener #1 [waiting for connection]
tq4001 /usr/sbin/zabbix_agentd: listener #2 [waiting for connection]
tq4002 /usr/sbin/zabbix_agentd: listener #3 [waiting for connection]
mq4003 /usr/sbin/zabbix_agentd: active checks #1 [idle 1 sec]
Dec 02 07:32:43 localhost systemd[1]: Starting Zabbix Agent...
Dec 02 07:32:43 localhost systemd[1]: Started Zabbix Agent.
● httpd.service - The Apache HTTP Server
Loaded: loaded (/usr/lib/systemd/system/httpd.service; disabled; vendor preset: disabled)
Active: active (running) since Mon 2024-12-02 07:32:43 UTC; 29s ago
Docs: man:httpd.service(8)
Main PID: 3996 (httpd)
Status: "Total requests: 0; Idle/Busy workers 100/0;Requests/sec: 0; Bytes served/sec: 0 B/sec"
CGroup: /system.slice/httpd.service
tq3996 /usr/sbin/httpd -DFOREGROUND
tq4007 /usr/sbin/httpd -DFOREGROUND
tq4008 /usr/sbin/httpd -DFOREGROUND
tq4009 /usr/sbin/httpd -DFOREGROUND
tq4010 /usr/sbin/httpd -DFOREGROUND
mq4012 /usr/sbin/httpd -DFOREGROUND
Dec 02 07:32:43 localhost systemd[1]: Starting The Apache HTTP Server...
Dec 02 07:32:43 localhost httpd[3996]: AH00558: httpd: Could not reliably dete...ge
Dec 02 07:32:43 localhost systemd[1]: Started The Apache HTTP Server.
● rh-php72-php-fpm.service - The PHP FastCGI Process Manager
Loaded: loaded (/usr/lib/systemd/system/rh-php72-php-fpm.service; disabled; vendor preset: disabled)
Active: active (running) since Mon 2024-12-02 07:32:43 UTC; 29s ago
Main PID: 3995 (php-fpm)
Status: "Processes active: 0, idle: 10, Requests: 0, slow: 0, Traffic: 0req/sec"
CGroup: /system.slice/rh-php72-php-fpm.service
tq3995 php-fpm: master process (/etc/opt/rh/rh-php72/php-fpm.conf)
tq4054 php-fpm: pool www
tq4055 php-fpm: pool www
tq4056 php-fpm: pool www
tq4057 php-fpm: pool www
tq4058 php-fpm: pool www
tq4059 php-fpm: pool zabbix
tq4060 php-fpm: pool zabbix
tq4061 php-fpm: pool zabbix
tq4062 php-fpm: pool zabbix
mq4063 php-fpm: pool zabbix
Dec 02 07:32:43 localhost systemd[1]: Starting The PHP FastCGI Process Manager...
Dec 02 07:32:43 localhost systemd[1]: Started The PHP FastCGI Process Manager.
Hint: Some lines were ellipsized, use -l to show in full.
[root@localhost ~]#
手順7.Zabbix GUI設定
http://[サーバIP]/zabbix 入力後、下記画面に遷移する
「Next Step」をクリックする
Required列の右横にある「OK」がすべての項目にあることを確認する
問題なければ「Next Step」をクリックする
「Password」の箇所にzabbix_server.confに記載したパスワードを入力する
入力後に「Next Step」をクリックする
この画面はそのまま「Next Step」をクリックする
設定内容に問題なければ「Next Step」をクリックする
完了後に下記ログイン画面が表示されます。
ユーザー名は「Admin」・パスワードは「zabbix」でログインできます。
Zabbixの基本的な用語はこちらで紹介しておりますので、
ご確認してみてはいかがでしょうか。