How to install Zabbix monitoring tools on CentOS 8

How to install Zabbix monitoring tools on CentOS 8

Zabbix is ​​an open source monitoring tool for network services, network hardware, servers and applications. Designed to track and monitor the status of systems and servers. Zabbix provides support for many database systems including MySQL, PostgreSQL, SQLite and IBM DB2 to store data. Zabbix backend is written in C, while the front end is written in PHP.

In this tutorial, we will show you step by step how to install and configure the open source monitoring system Zabbix 4.0 LTS on a CentOS 8 system. This guide will cover some topics, including the installation and configuration of the LAMP Stack for our Zabbix installation, and how to change the default password for the Zabbix Management Web UI.

prerequisites

  • CentOS 8 server
  • Root privilege
  • Basic knowledge about Linux CentOS commands

What we do:

  • Install Apache Httpd
  • Install and configure PHP
  • Install and configure MariaDB
  • Install and configure Zabbix 4.0 LTS
  • Configure firewall
  • Configure SELinux
  • After Zabbix installation
  • Change the default administrator of Zabbix

Step 1-install Apache Httpd

For this guide, we will use Apache / httpd for the web server. Zabbix server will run under Apache web server.

You can use the dnf command below to install the Apache / httpd package.

dnf install httpd

After the installation is complete, add the httpd service to the system boot and start the service using the following command.

systemctl enable httpdsystemctl start httpd

Now, use the netstat command below to check the httpd service and make sure the HTTP port “80” is in the “LISTEN” state.

netstat -plntu

The results are as follows.

As a result, the httpd service has started and is running on the default HTTP port “80” on the CentOS 8 server.

Step 2-install PHP

After installing the Apache / httpd web server, we will install the PHP packages and their extensions required for Zabbix installation. We will install and configure PHP according to the Zabbix installation requirements.

Use the following dnf command to install the PHP package.

dnf install php-cli php-common php-devel php-pear php-gd php-mbstring php-mysqlnd php-xml php-bcmath

After the installation is complete, use the vim editor to configure the PHP configuration ‘/etc/php.ini’.

vim /etc/php.ini

Change the configured values ​​as shown below.

date.timezone = Asia/Jakartamax_execution_time = 600max_input_time = 600memory_limit = 256Mpost_max_size = 32Mupload_max_filesize = 16M

Save and close.

Now restart the Apache / httpd service.

systemctl restart httpd

At this point, PHP installation and configuration on the CentOS 8 server has been completed.

Install PHP

Step 3-install and configure MariaDB

By default, Zabbix provides support for many databases installed, including MySQL, PostgreSQL, SQLite and Oracle databases. For this guide, we will use MariaDB as the database for Zabbix installation.

Install mariadb-server using the following dnf command.

dnf install mariadb-server

After the installation is complete, add the MariaDB service to the system boot and start the service using the following command.

systemctl enable mariadbsystemctl start mariadb

MariaDB server is up and running.

Next, we will configure the MariaDB root password. Run the “mysql_secure_installation” command below to configure the root password.

mysql_secure_installation

Enter your root password and press Enter.

Set a root password? [Y/n] YDisallow root login remotely? [Y/n] YRemove test database and access to it? [Y/n] YReload privilege tables now? [Y/n] Y

And MariaDB root password has been configured.

Install MariaDB

Next, we will create a new database and user for the Zabbix installation. We will create a new database with username “zabbix” and password “[email protected]’.

Login to MariaDB / mysql shell using the mysql command below.

mysql -u root -pTYPE YOUR ROOT PASSWORD:

And run the following MariaDB query under the shell.

create database zabbix; grant all privileges on zabbix.* to [email protected]'localhost' identified by '[email protected]'; grant all privileges on zabbix.* to [email protected]'%' identified by '[email protected]'; flush privileges;

Therefore, a new database and user have been created for Zabbix installation.

Create zabbix database

Step 4-install and configure Zabbix 4.0 LTS

In this step, we will install Zabbix 4.0 LTS. We will install the Zabbix LTS version from the official Zabbix repository.

-Add repositories and install packages

First, we need to add the Zabbix 4.0 LTS repository to the system using the rpm command below.

rpm -Uvh https://repo.zabbix.com/zabbix/4.0/rhel/8/x86_64/zabbix-release-4.0-2.el8.noarch.rpm

After that, delete the system package cache and check all available repositories on the system.

dnf clean alldnf repolist

Now you will get the following results.

Install Zabbix RPM file

As a result, the Zabbix repository has been added to the CentOS 8 system.

Now run the following dnf command to install Zabbix server and agent.

dnf -y install zabbix-server-mysql zabbix-web-mysql zabbix-agent

Wait for Zabbix installation to complete.

Gamba

-Import MySQL database scheme

After Zabbix installation is complete, we will import the MariaDB database solution for Zabbix.

Go to the “/ usr / share / doc / zabbix-server-mysql” directory and unzip the database scheme.

cd /usr/share/doc/zabbix-server-mysqlgunzip create.sql.gz

Now, import the database schema into our ‘zabbix’ database using the following MySQL command.

mysql -u root -p zabbix < create.sql

Enter your MariaDB superuser password and the database schema has been imported.

Import MySQL database scheme

-Configure Zabbix server and Zabbix proxy

The Zabbix server is the central process of the Zabbix software system. We will configure the Zabbix server by editing the configuration "/etc/zabbix/zabbix_server.conf".

Use the vim editor to edit the "/etc/zabbix/zabbix_server.conf" configuration file.

vim /etc/zabbix/zabbix_server.conf

In the database row configuration, type the following configuration, and then change the "DBPassword" value with your own database password.

DBHost=localhost[email protected]

Save and close.

After that, add zabbix-server to the system boot.

systemctl enable zabbix-server

And zabbix-server configuration is complete.

Next, we will show you the zabbix-agent configuration. Zabbix-agent must be installed on all computers that will be monitored.

Edit the zabbix-agent configuration '/etc/zabbix/zabbix_agentd.conf' using vim editor.

vim /etc/zabbix/zabbix_agentd.conf

Now, change the "Server" and "ServerActive" values ​​using the zabbix-server IP address as shown below.

Server=10.5.5.50ServerActive=10.5.5.50

Save and close.

Now, add the zabbix-agent service to the system boot.

systemctl enable zabbix-agent

And zabbix-agent configuration is complete.

Configure Zabbix server

Step 5-configure the firewall

For configurations using a firewall, we will add new services, including HTTP, HTTPS, and ports used by Zabbix servers and proxies.

Add the HTTP, HTTP, and Zabbix ports "10050-10051" to Firewalld using the following command.

firewall-cmd --add-service={http,https} --permanentfirewall-cmd --add-port={10051/tcp,10050/tcp} --permanent

After that, reload firewalld and check all available services and ports on it.

firewall-cmd --reloadfirewall-cmd --list-all

The result will be shown below.

Configure firewall

As a result, HTTP, HTTPS, and Zabbix ports "10050-10051" have been added to Firewalld.

Step 6-configure SELinux

If you want to run Zabbix on CentOS 8 with SELinux enabled, you must execute all commands in this section.

Use the following dnf command to install the SELinux utility.

dnf install policycoreutils checkpolicy setroubleshoot-server

After the installation is complete, create a new directory '~ / zabbix-linux' and enter.

mkdir -p ~/zabbix-selinuxcd ~/zabbix-selinux/

Now use vim editor to create a new SELinux policy module file 'zabbix_server_add.te'.

vim zabbix_server_add.te

Paste the following configuration.

module zabbix_server_add 1.1;require {        type zabbix_var_run_t;        type tmp_t;        type zabbix_t;        class sock_file { create unlink write };        class unix_stream_socket connectto;        class process setrlimit;        class capability dac_override;}#============= zabbix_t ==============#!!!! This avc is allowed in the current policyallow zabbix_t self:process setrlimit;#!!!! This avc is allowed in the current policyallow zabbix_t self:unix_stream_socket connectto;#!!!! This avc is allowed in the current policyallow zabbix_t tmp_t:sock_file { create unlink write };#!!!! This avc is allowed in the current policyallow zabbix_t zabbix_var_run_t:sock_file { create unlink write };#!!!! This avc is allowed in the current policyallow zabbix_t self:capability dac_override;

Save and close.

Now, use the following checkmodule command to convert 'zabbix_server_add.te' to a policy module.

checkmodule -M -m -o zabbix_server_add.mod zabbix_server_add.te

Now, compile the policy module 'zabbix_server_add.mod' using the semodule_package command.

semodule_package -m zabbix_server_add.mod -o zabbix_server_add.pp

After that, load the compiled policy module "zabbix_server_add.pp" into the system.

semodule -i zabbix_server_add.pp

Zabbix's local custom strategy module is loaded.

Configure SELinux

Next, perform other SELinux configurations. Run the setsbool command below.

setsebool -P httpd_can_network_connect 1setsebool -P httpd_can_connect_zabbix 1setsebool zabbix_can_network on

Zabbix's SELinux configuration is complete.

Step 7-Zabbix initial setup

First, start zabbix-server using the following command.

systemctl start zabbix-serversystemctl status zabbix-server

Now start the zabbix-agent service.

systemctl start zabbix-agentsystemctl status zabbix-agent

Then restart the httpd service.

systemctl restart httpd

Next, open your web browser and type the server IP address as shown below.

http://10.5.5.50/zabbix/

You will receive a welcome message from Zabbix.

Zabbix web installer

Click the "Next" button.

Zabbix will now check all system requirements for installation. Make sure there are no errors.

Checking prerequisites

Click the "Next" button.

For database information, type all database settings.

Configuration database

Then click the "Next" button.

Now it is Zabbix server detail configuration. In the Host field, type your own server IP address and change the name with your own domain name or host name.

Zabbix server details

Click the "Next" button again.

Make sure all these configurations are correct, then click Next to install Zabbix.

Pre-installation summary

After the installation is complete, you will get the page shown below.

Successful installation

Click the "Finish" button and you will be redirected to the Zabbix login page.

Log in with the default user "admin" and password "zabbix".

Zabbix login

You will get the default Zabbix dashboard.

Zabbix Dashboard

The installation of Zabbix is ​​complete.

Step 8-change the default administrator password

For the last step, we will change zabbix's default administrator password.

On the Zabbix management console, click the user icon in the upper right corner.

change the password

Click the "Change Password" button and enter a new password.

confirm password

Now click the Update button and the default administrator password has changed.

Zabbix installation and configuration on CentOS 8 system has been successfully completed.

reference

  • https://www.zabbix.com/
Sidebar