How to install Zabbix monitoring server on CentOS 7

Try it in our public cloud & Get $5 Credit
CLAIM NOW

The Zabbix software package is a highly customizable and flexible server- and software-monitoring tool. A single instance of Zabbix on a server can be used to gather accurate statistics and performance data on multiple physical or virtual servers. Zabbix may also be used to monitor any device with an SNMP agent such as routers, switches, and even some cooling and power systems. When installed on a monitored server, Zabbix agent makes a vast array of data available for monitoring, including CPU load, memory usage, disk space, network load, and active processes. Zabbix can use HTTP/SNMP to retrieve basic monitoring information from other servers without installing any software on those hosts. Data collected by Zabbix are stored in a relational database for easy retrieval and ready analysis. In this tutorial, we will show you how to install Zabbix on CentOS 7 using MariaDB as our database backend.

Getting Started

Confirm that you have the following before you follow this guide:
• 1 Node (Cloud Server or Dedicated Server) running CentOS 7.
• Root access to the node or one sudo non-root user

Tutorial

Before you start to install Zabbix, make sure that SELinux is disabled.

setenforce 0
sed -i 's/enforcing/disabled/' /etc/sysconfig/selinux
sed -i 's/enforcing/disabled/' /etc/selinux/config

The EPEL repository contains packages upon which Zabbix is dependent. Use Yum to install these packages as follows:

yum install -y nano wget

All dependencies should now be installed.

Add the Zabbix repository to your instance of Yum:

rpm -ivh http://repo.zabbix.com/zabbix/3.0/rhel/7/x86_64/zabbix-release-3.0-1.el7.noarch.rpm

Zabbix has no capacity for data storage or analysis. Rather, it feeds all the data it retrieves to a relational database backend. We will use a fork of MySQL called MariDB as our backend in this tutorial.

To install MariaDB Database Server use Yum as follows:

yum install -y mariadb mariadb-server

To assure monitoring data collected by Zabbix is collected whenever the server is running, we will make MariaDB available immediately whenever the CentOS server restarts. To make it so execute the following commands:

systemctl start mariadb.service
systemctl enable mariadb.service

As a variant of MySQL, MariaDB is not inherently secure. The following commands will secure your database server and set your root password:

mysql_secure_installation

Zabbix will require its own dedicated database within your newly running and initialized instance of MariaDB. We recommend you create a unique user within MariaDB that uniquely has access to that database. To create the database and user for Zabbix enter these command, replacing “zabbixpassword” with your own secure password:

mysql -u root -p

create database zabbix character set utf8 collate utf8_bin;
grant all privileges on zabbix.* to zabbix@localhost identified by 'zabbixpassword';
exit

User : zabbix – Database : zabbix – Password : zabbixpassword

Now that the database is prepared, install Zabbix server with the correct MariaDB support packages as follows:

yum install -y zabbix-server-mysql zabbix-web-mysql

Import the contents (schema, images, and data) of the default database provided by Zabbix into your database server ( version installed here : 3.0.4 ):

cd /usr/share/doc/zabbix-server-mysql-3.0.4/
gunzip create.sql.gz
mysql -u root -p zabbix < create.sql

Zabbix server is installed and the database is properly configured. We are ready to configure PHP and the HTTP (Apache) server to work with Zabbix.

The default settings for a number of PHP parameters will not interact well with Zabbix. To maximize performance, open your php.ini file with a text editor (we use nano) and modify those lines with the parameters described in the following so that they have the values depicted there:

nano /etc/php.ini

max_execution_time = 600
max_input_time = 600
memory_limit = 256M
post_max_size = 32M
upload_max_filesize = 16M
date.timezone = America/Toronto

Don't forget to remove the comment in front of date.timezone.

Next, you need to tell the HTTP server how to access the zabbix database you created above. Find the line in the configuration file /etc/zabbix/zabbix_server.conf that corresponds to the database password you set above and add the correct value:

nano /etc/zabbix/zabbix_server.conf

When Yum installed Zabbix, it created the file /etc/httpd/conf.d/zabbix.conf. Edit this Zabbix configuration file so that it looks like this:

DBHost=localhost
DBName=zabbix
DBUser=zabbix
DBPassword=zabbixpassword

To use Zabbix restart your web server. If the HTTP Server has not been configured to launch when the CentOS server boots, use the following command to enable that behavior:

systemctl restart httpd.service
systemctl enable httpd.service

With the HTTP Server running, start the Zabbix server service and set it to start on boot:

systemctl start zabbix-server.service
systemctl enable zabbix-server.service

Zabbix is now available on your server.

You may finish your setup online by going to:

http://your_ip/zabbix

Replace your_ip with the IP address of your server. Click next repeatedly until you are prompted to enter the configuration data for the DB connection. Fill in the database information, using the parameters you defined earlier. Then continue to click through until installation is finished.

Use the default login information to log into your control panel

Login : Admin
Password : zabbix

Zabbix is installed and configured.

Conclusion

You have successfully installed Zabbix on a CentOS 7 server. With the MariaDB backend in place, you are ready to monitor all of your servers from one central location. If you liked this Knowledge Base article please share it with your friends.

If you found this article helpful, feel free to share it with your friends and let us know in the comments below!