[LINUX] Environment construction of monitoring server Zabbix 4.4 on CentOS7 (Apache2.4 / PHP5.4 / MariaDB5.5)

Introduction

This article describes the steps to install Zabbix 4.4 on CentOS 7.

What is Zabbix

Zabbix is an open source (OSS) integrated monitoring software developed for centralized monitoring of server monitoring, network monitoring, etc., and has established a de facto standard position as monitoring software.

Zabbix has the monitoring, failure detection and notification functions required for integrated monitoring. Since it supports Zabbix agent and SNMP for many platforms, it is possible to monitor the entire system with one Zabbix.

Zabbix web interface is written in PHP and runs as a web application on Apache. All monitoring settings and information display can be easily done from a web browser.

environment

--Host OS: Windows10 --Guest OS: CentOS7 (CentOS Linux release 7.6.1810 (Core)) --How to build a virtual machine: VirtualBox, Vagrant --Web server: Apache2.4

Zabbix server construction procedure (overview)

  1. OS update for CentOS
  2. Installation of Web server (Apache), PHP, DB (MariaDB)
  3. Install Zabbix
  4. Various settings (database, web server, etc.)
  5. Display Zabbix monitoring / setting screen on web browser

Zabbix server construction procedure (details)

Build the CentOS 7 environment in advance. There is no problem with the minimum package for the OS to be installed.

The built CentOS 7 will be ready for internet connection, yum commands, and communication with other guest OS machines. In addition, the following Zabbix environment construction is done with root privileges.

Connect to CentOS

SSH connection to CentOS environment built with Vagrant from the command prompt of Windows.

command prompt


D:\hoge>vagrant ssh zabbix
Last login: Tue Oct 20 16:40:47 2020 from 10.0.2.2
[vagrant@zabbix ~]$ su -
Password:
Last login: Tue Oct 20 16:43:52 UTC 2020 on pts/0
[root@zabbix ~]#

OS update & OS restart

First, update the OS to the latest state with the yum update command.

CentOS7


[root@zabbix ~]# yum update
Loaded plugins: fastestmirror
Determining fastest mirrors
 * base: ftp.iij.ad.jp
 * extras: ftp.iij.ad.jp
 * updates: ftp.iij.ad.jp
~~~ Omitted ~~~
  tuned.noarch 0:2.11.0-8.el7                                 tzdata.noarch 0:2020a-1.el7
  util-linux.x86_64 0:2.23.2-63.el7                           vim-minimal.x86_64 2:7.4.629-6.el7
  xfsprogs.x86_64 0:4.5.0-20.el7                              yum.noarch 0:3.4.3-167.el7.centos
  yum-plugin-fastestmirror.noarch 0:1.1.31-54.el7_8           yum-utils.noarch 0:1.1.31-54.el7_8

Complete!

When the OS update is complete, restart the OS and SSH into CentOS 7.

command prompt


[root@zabbix ~]# reboot
Connection to 127.0.0.1 closed by remote host.
Connection to 127.0.0.1 closed.

D:\hoge>vagrant ssh zabbix
Last login: Tue Oct 20 16:40:47 2020 from 10.0.2.2
[vagrant@zabbix ~]$ su -
Password:
Last login: Tue Oct 20 16:43:52 UTC 2020 on pts/0
[root@zabbix ~]#

Install the software (Apache, PHP, MariaDB) required for Zabbix to work

Install the software (Apache, PHP, MariaDB) required to run Zabbix with the following command.

CentOS7


[root@zabbix ~]# yum -y install httpd-devel php php-devel php-pdo php-mysqlnd php-mbstring php-mcrypt php-gd php-pear php-pecl-apc-devel zlib-devel mariadb-devel mariadb-server

Check the version of each software

Check the version of the web server (Apache).

CentOS7


[root@zabbix ~]# httpd -v
Server version: Apache/2.4.6 (CentOS)

Check the PHP version.

CentOS7


[root@zabbix ~]# php -v
PHP 5.4.16 (cli) (built: Apr  1 2020 04:07:17)
Copyright (c) 1997-2013 The PHP Group
Zend Engine v2.4.0, Copyright (c) 1998-2013 Zend Technologies

Check the MariaDB version.

CentOS7


[root@zabbix ~]# mysql -V
mysql  Ver 15.1 Distrib 5.5.65-MariaDB, for Linux (x86_64) using readline 5.1

Zabbix installation

This time install Zabbix version 4.4. You can check the latest version of Zabbix server from the official repository below. https://repo.zabbix.com/zabbix/

Zabbix Server installation

Install version 4.4 from Zabbix official repository.

CentOS7


[root@zabbix ~]# yum -y install https://repo.zabbix.com/zabbix/4.4/rhel/7/x86_64/zabbix-release-4.4-1.el7.noarch.rpm

Execute the following command to install Zabbix Server related packages.

CentOS7


yum install zabbix-web-mysql zabbix-web-japanese zabbix-server-mysql

Check Zabbix server version. You have successfully installed version 4.4.

CentOS7


[root@zabbix ~]# zabbix_server -V
zabbix_server (Zabbix) 4.4.10
Revision 4db30afc70 29 June 2020, compilation time: Jun 29 2020 11:55:57

Copyright (C) 2020 Zabbix SIA
License GPLv2+: GNU GPL version 2 or later <http://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it according to
the license. There is NO WARRANTY, to the extent permitted by law.

This product includes software developed by the OpenSSL Project
for use in the OpenSSL Toolkit (http://www.openssl.org/).

Compiled with OpenSSL 1.0.1e-fips 11 Feb 2013
Running with OpenSSL 1.0.1e-fips 11 Feb 2013

Installation of Zabbix Agent

Execute the following command to install Zabbix Agent. (Zabbix-agent is software that is originally installed on the monitored server)

CentOS7


[root@zabbix ~]# yum -y install zabbix-agent

Check the version of Zabbix agent. You have successfully installed version 4.4.

CentOS7


[root@zabbix ~]# zabbix_agentd -V
zabbix_agentd (daemon) (Zabbix) 4.4.10
Revision 4db30afc70 29 June 2020, compilation time: Jun 29 2020 11:56:26

Copyright (C) 2020 Zabbix SIA
License GPLv2+: GNU GPL version 2 or later <http://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it according to
the license. There is NO WARRANTY, to the extent permitted by law.

This product includes software developed by the OpenSSL Project
for use in the OpenSSL Toolkit (http://www.openssl.org/).

Compiled with OpenSSL 1.0.1e-fips 11 Feb 2013
Running with OpenSSL 1.0.1e-fips 11 Feb 2013

MariaDB launch & login

Start MariaDB and log in.

CentOS7


[root@zabbix ~]# systemctl start mariadb
[root@zabbix ~]# systemctl enable mariadb
Created symlink from /etc/systemd/system/multi-user.target.wants/mariadb.service to /usr/lib/systemd/system/mariadb.service.
[root@zabbix ~]# mysql -u root
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 2
Server version: 5.5.65-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 settings

Create database "zabbix" and user "zabbix" used by zabbix-server.

Replace the new-password part with an arbitrary password and execute the command.

MariaDB


MariaDB [(none)]> create database zabbix character set utf8 collate utf8_bin;
Query OK, 1 row affected (0.00 sec)

MariaDB [(none)]> grant all on zabbix.* to zabbix@localhost identified by 'new-password';
Query OK, 0 rows affected (0.00 sec)

MariaDB [(none)]> UPDATE mysql.user SET Password=PASSWORD('new-password') WHERE User='root';
Query OK, 4 rows affected (0.00 sec)
Rows matched: 4  Changed: 4  Warnings: 0

MariaDB [(none)]> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.00 sec)

MariaDB [(none)]> quit;
Bye

Then execute the following command to import the initialization SQL into zabbix database.

CentOS


[root@zabbix ~]# cd /usr/share/doc/zabbix-server-mysql-4.4.10/
[root@zabbix zabbix-server-mysql-4.4.10]# zcat create.sql.gz | mysql -u zabbix -p zabbix
Enter password:
[root@zabbix zabbix-server-mysql-4.4.10]#

Enter the password of the zabbix user created earlier in the Zabbix server configuration file zabbix_server.conf. Replace the new-password part with an arbitrary password and execute the command.

CentOS7


# vi /etc/zabbix/zabbix_server.conf
---

# DBPassword=
↓
DBPassword=new-password

Web server settings and startup

Set the time zone to "Asia / Tokyo (Japan / Tokyo)" in the Apache configuration file zabbix.conf so that it will be displayed in Japan time on Zabbix browser.

CentOS7


# vi /etc/httpd/conf.d/zabbix.conf
---

# php_value date.timezone Europe/Riga
↓
php_value date.timezone Asia/Tokyo

Run Apache startup and autostart settings.

CentOS7


[root@zabbix ~]# systemctl start httpd
[root@zabbix ~]# systemctl enable httpd
Created symlink from /etc/systemd/system/multi-user.target.wants/httpd.service to /usr/lib/systemd/system/httpd.service.

Start Zabbix server

Execute zabbix-server startup and autostart settings.

CentOS7


[root@zabbix ~]# systemctl start zabbix-server
[root@zabbix ~]# systemctl enable zabbix-server
Created symlink from /etc/systemd/system/multi-user.target.wants/zabbix-server.service to /usr/lib/systemd/system/zabbix-server.service.

Firewall (FW) startup / setting

After starting the firewall, allow communication to http (80 / TCP) so that Zabbix web interface can be displayed.

CentOS7


[root@zabbix ~]# systemctl start firewalld
[root@zabbix ~]# systemctl enable firewalld
Created symlink from /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service to /usr/lib/systemd/system/firewalld.service.
Created symlink from /etc/systemd/system/multi-user.target.wants/firewalld.service to /usr/lib/systemd/system/firewalld.service.
[root@zabbix ~]# firewall-cmd --add-service=http --zone=public --permanent
success
[root@zabbix ~]# firewall-cmd --reload
success
[root@zabbix ~]#

Zabbix screen display

After that, work on the Web browser.

Access the URL of Zabbix management screen. Enter the IP address of CentOS 7 in the IP address part. http://[IPアドレス]/zabbix/

When the following screen is displayed, click "Next Step" to proceed.

zabbix01.jpg

Enter the password you decided when setting MariaDB in "Password" on the screen below. zabbix03.jpg

The following login screen will be displayed as you proceed in sequence. You can log in with the following initial settings. -Username: Admin ・ Password: zabbix zabbix_login.png

If the following screen (Zabbix dashboard) is displayed, login is successful. zabbix_top.jpg

that's all.

Referenced articles

Introduction to IT Infrastructure Monitoring-Zabbix Installation- "Basic knowledge of IT infrastructure required in the cloud era" (5) https://knowledge.sakura.ad.jp/12446/

Recommended Posts

Environment construction of monitoring server Zabbix 4.4 on CentOS7 (Apache2.4 / PHP5.4 / MariaDB5.5)
Anaconda environment construction on CentOS7
Environment construction of python3.8 on mac
Environment construction of "Tello_Video" on Ubuntu
[Note] Python environment construction on rental server "CORESERVER"
Web server construction with Apache 2.4 (httpd 2.4.43) + PHP 7.4 on Linux ―― 4. Security (chown and firewalld)
Memo of python + numpy/scipy/pandas/matplotlib/jupyterlab environment construction on M1 macOS (as of 2020/12/24)
Memo of Linux environment construction using VirtualBox + Vagrant on Windows 10
Super simple! centos7, sendmail in local environment, DNS server construction
Build a python environment on CentOS 7.7 for your home server
About Linux environment construction (CentOS)
Apache installation fails on CentOS 8.2
[Memo] Construction of cygwin environment
[Tensorflow] Tensorflow environment construction on Windows 10
Linux environment construction (on WSL environment)
Environment construction of python2 & 3 (OSX)
Environment construction of TensorFlow + JupyterNotebook + Matplotlib on Windows version Anaconda (August 2017 version)
Python environment construction memo on Windows 10
Anaconda python environment construction on Windows 10
Anaconda environment construction on Mac (2018 version)
[Django] Memorandum of environment construction procedure
Python environment construction memo on Mac
Server construction with CONOHA VPS (CentOS)
Environment construction memo of pyenv + conda
Python development environment construction on macOS
Set up Python environment on CentOS
Create a python environment on centos
[Linux] Docker environment construction on Redhat
Python3 environment construction with pyenv-virtualenv (CentOS 7.3)
Using Chainer with CentOS7 [Environment construction]
Build a python3 environment on CentOS7
Linux server construction link summary (CentOS7)
OpenCV3 & Python3 environment construction on Ubuntu
Environment construction of Flask / MySql / Apache / mod_wsgi / virtualenv with Redhat7 (Python2.7) November 2020
I tried Linux (CentOS 7) life and death monitoring (Ping) with monitoring server Zabbix
Build a CentOS Linux 8 environment with Docker and start Apache HTTP Server