Install Zabbix 3.0 (Monitoring Server) on CentOS 7.x / RHEL 7.x

Zabbix is a free and open source monitoring tool which is used to monitor and track the availability & performance of servers, network devices and other IT assets which are on network.

Zabbix uses database like MySQL, MariaDB, Oracle and IBM DB2 to store its data. Zabbix web interface is written in PHP.

Some of its key features are listed below :

  • Monitor everything which is on network like Servers, applications, database instance and network devices.
  • Zabbix provides Web based administration interface.
  • Monitoring CPU utilization of a particular process or a group of process ( proc.cpu.util)
  • Using low-level discovery rules, zabbix can discover Vmware hypervisor ( ESXI ) and Virtual machines.
  • Zabbix also supports agentless monitoring
  • Monitoring of database servers like MySQL, PostgreSQL, Oracle and Microsoft SQL Server.
  • Zabbix can also perform the task of capacity planning for your environment.
  • Zabbix is Open Source so no cost involved and can be deployed on small and large environment.
  • Hardware Monitoring using Zabbix via IPMI credentials.
  • Network Device monitoring using snmp agents.

In this article we will install the latest version of Zabbix 3.0 on CentOS 7.x and RHEL 7.x. Below are the details of my server on which i will install Zabbix.

  • Hostname = zabbix.linuxtechi.com
  • IP Address = 192.168.1.7
  • OS = CentOS 7.x / RHEL 7.x

Before Starting Installation, first update your system using below command :

[[email protected] ~]# yum -y update
[[email protected] ~]# reboot

Step:1 Enable EPEL and Zabbix Repository

Zabbix package is not available in the default yum repository, so we will enable zabbix  and epel repository using below commands.

[[email protected] ~]# yum install epel-release
[[email protected] ~]# rpm -ivh http://repo.zabbix.com/zabbix/3.0/rhel/7/x86_64/zabbix-release-3.0-1.el7.noarch.rpm

Step:2 Install Zabbix Server, Database, Web Server and PHP packages

Use the below command to install rpm package of Zabbix server, Database Sever (MariaDB) , Web Server ( http) and PHP.

[[email protected] ~]# yum -y install zabbix-server-mysql zabbix-web-mysql mysql mariadb-server httpd php

Step:3 Configure Zabbix Database.

Start the Database (MariaDB) service

[[email protected] ~]# systemctl start mariadb
[[email protected] ~]# systemctl enable mariadb
ln -s '/usr/lib/systemd/system/mariadb.service' '/etc/systemd/system/multi-user.target.wants/mariadb.service'
[[email protected] ~]#

Use ‘mysql_secure_installation‘ command to set the root password of mariadb database and configure other parameters like ‘Remove anonymous users‘, ‘Disallow root login remotely‘ and ‘Remove test database and access to it

[[email protected] ~]# mysql_secure_installation

Now create the Zabbix Database (zabbix_db) and database user (zabbix_user) and grant all privileges to the user on the Zabbix database.

[[email protected] ~]# 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.47-MariaDB MariaDB Server

Copyright (c) 2000, 2015, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]> create database zabbix_db;
Query OK, 1 row affected (0.00 sec)

MariaDB [(none)]> grant all privileges on zabbix_db.* to [email protected] identified by <new_password>;
Query OK, 0 rows affected (0.00 sec)

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

MariaDB [(none)]> exit
Bye
[[email protected] ~]#

Now import the database Schema using below commands,

[[email protected] ~]# cd /usr/share/doc/zabbix-server-mysql-3.0.1
[[email protected] zabbix-server-mysql-3.0.1]# gunzip create.sql.gz
[[email protected] zabbix-server-mysql-3.0.1]# mysql -u root -p zabbix_db < create.sql
Enter password:
[[email protected] zabbix-server-mysql-3.0.1]#

Step:4 Edit Zabbix Server Configuration file

Edit the Zabbix Server’s config file (/etc/zabbix/zabbix_server.conf) and specify the database name for zabbix , database user name & its password.

[[email protected] ~]# vi /etc/zabbix/zabbix_server.conf
...................................
DBHost=localhost
DBName=zabbix_db
DBUser=zabbix_user
DBPassword=XXXXXXX
...................................

Save & exit the file.

Configure PHP Setting

Set the below parameters in the PHP config file (/etc/php.ini )

[[email protected] ~]# vi /etc/php.ini
................................
max_execution_time = 600
max_input_time = 600
memory_limit = 256M
post_max_size = 32M
upload_max_filesize = 16M
date.timezone = Asia/Kolkata
...............................

Allow the ports in the Firewall

[[email protected] ~]# firewall-cmd --permanent --add-port=10050/tcp
success
[[email protected] ~]# firewall-cmd --permanent --add-port=10051/tcp
success
[[email protected] ~]# firewall-cmd --permanent --add-port=80/tcp
success
[[email protected] ~]# firewall-cmd --reload 
success
[[email protected] ~]# systemctl restart firewalld
[[email protected] ~]#

Set the below Selinux rule.

[[email protected] ~]# setsebool -P httpd_can_connect_zabbix=1
[[email protected] ~]#

Start the Zabbix and Web Server Service and make sure it is enable across the reboot.

[[email protected] ~]# systemctl start zabbix-server
[[email protected] ~]# systemctl enable zabbix-server
ln -s '/usr/lib/systemd/system/zabbix-server.service' '/etc/systemd/system/multi-user.target.wants/zabbix-server.service'
[[email protected] ~]# 
[[email protected] ~]# systemctl start httpd
[[email protected] ~]# systemctl enable httpd
ln -s '/usr/lib/systemd/system/httpd.service' '/etc/systemd/system/multi-user.target.wants/httpd.service'
[[email protected] ~]#

Step:5 Browse the Zabbix Web interface using below URL

http://192.168.1.7/zabbix/ or http://zabbix.linuxtechi.com/zabbix

Replace the IP address or hostname as per your setup.

Zabbix-Server-Installation

Click on ‘Next step’

On this Step Zabbix Pre-requisites are checked and verified

Zabbix-pre-requisites

Click on ‘Next step’

Specify the Zabbix Database name, database user and its password.

Zabbix-installation-DB-connection

Click on ‘Next step’ to continue.

Specify the Zabbix Server details and Port number.

Zabbix-Server-Details

Click on ‘Next step’ to continue.

Pre-installation summary of Zabbix Servers, click on ‘Next step’ to continue.

Pre-installation-summary-zabbix-server

As we can see that Zabbix installation is completed successfully

zabbix-installation-successfully

When we click on ‘finish’ , it will re-direct us to the Zabbix web interface Console.

Use user name as ‘admin‘ and password ‘zabbix

Zabbix-Web-Console

Zabbix Server Dashboard :

Zabbix-Monitoring-Server-Dashboard

Step:6 Add a node to Zabbix Server for Monitoring.

Let’s assume i want to add my Ubuntu 16.04 Machine to Zabbix Server for monitoring. Login to the machine and perform the following tasks .

[email protected]:~$ sudo apt-get install zabbix-agent

Edit the Agent file and specify the Zabbix Server address.

[email protected]:~$ sudo vi /etc/zabbix/zabbix_agentd.conf
..................................
Server=192.168.1.7
ServerActive=192.168.1.7
Hostname=cloud.linuxtechi.com
..................................

Start Zabbix Agent Service

[email protected]:~$ sudo systemctl start zabbix-agent
[email protected]:~$ sudo systemctl enable zabbix-agent
Synchronizing state of zabbix-agent.service with SysV init with /lib/systemd/systemd-sysv-install...
Executing /lib/systemd/systemd-sysv-install enable zabbix-agent
[email protected]:~$

Now Go to the Zabbix Web Interface .

Click on Configuration —> Hosts –> Create Host

Zabbix-Configuration- hosts

Specify the Host name, IP address and Group names. In Templates Tab, search appropriate templates and click on Add.

Zabbix-OS-Templates

To View the events for all the hosts or a particular host, Click on Monitoring —> Triggers

Zabbix-Server-Status-triggers

That’s it, Basic Monitoring and Configuration is Completed. Explore the Zabbix and have fun 🙂

17 Responses

  1. oulou says:

    Hi!

    First of all great guide.
    I’m having an issue with this install, namely on the Zabbix Server Dashboard it shows me that “Zabbix server is running No localhost:10051”
    What could be the issue here? Also i’m using Azure to host the VM, so could it be something related to their config?

    • isbat says:

      Hi…

      I managed to follow your guide, but after everything was finished (parameter: Zabbix server is running value: No localhost: 100510) please help resolve this

  2. Balaraju says:

    i am not able to start the zabbix-server

    [[email protected] zabbix-server-mysql-3.0.3]# systemctl start zabbix-server
    Job for zabbix-server.service failed. See ‘systemctl status zabbix-server.service’ and ‘journalctl -xn’ for details.

    • playboy says:

      did u disable selinux ?

      • Laurynas Ovsiukas says:

        Hi,
        things you need to do:
        setsebool -P httpd_can_connect_zabbix on
        If you get an error like below,
        Job for zabbix-server.service failed because a configured resource limit was exceeded. See “systemctl status zabbix-server.service” and “journalctl -xe” for details.

        You may need to create custom exceptions and allow those through SELinux.
        yum install policycoreutils-python
        cat /var/log/audit/audit.log | grep zab | audit2allow -M zabbix-server
        semodule -i zabbix-server.pp

  3. Balaraju says:

    when i am checking the status it s giving the below status

    [[email protected] ~]# systemctl status zabbix-server.service
    zabbix-server.service – Zabbix Server
    Loaded: loaded (/usr/lib/systemd/system/zabbix-server.service; disabled)
    Active: activating (auto-restart) (Result: signal) since Wed 2016-06-08 02:05:56 EDT; 2s ago
    Process: 2642 ExecStart=/usr/sbin/zabbix_server -c $CONFFILE (code=killed, signal=SEGV)

    Jun 08 02:05:56 localhost.localdomain systemd[1]: zabbix-server.service: control process exited, code=killed status=11
    Jun 08 02:05:56 localhost.localdomain systemd[1]: Failed to start Zabbix Server.
    Jun 08 02:05:56 localhost.localdomain systemd[1]: Unit zabbix-server.service entered failed state.

  4. Balaraju says:

    Hello Pradeep,

    It’ Done.

    Why after updating it’s resolved. Which packages is required to zabbix-server to resolve this.

    Thanks pradeep

  5. Hello Pradeep,
    On CentOS 7, I did update before and after, but the problem is still the same on zabbix web console. How ever when I check the zabbix server status, it is running. Can you provide some hints to troubleshoot this situation?
    Thanks

  6. Toni H says:

    Hello,

    I had the same problem with MySQL not connecting and I found out that I needed to give httpd permission.

    setsebool -P httpd_can_network_connect=true

    Or you can just disable SELinux as well, but we don’t want that do we? 🙂

  7. papon says:

    this is how to solve “zabbix-server.service failed. See ‘systemctl status zabbix-server.service’ and ‘journalctl -xn’ for details.” problem.
    sudo yum install policycoreutils-python
    sudo grep zabbix_server /var/log/audit/audit.log | audit2allow
    sudo grep zabbix_server /var/log/audit/audit.log | audit2allow -M zabbix-limit
    sudo semodule -i zabbix-limit.pp
    sudo systemctl start zabbix-server

  8. RonP says:

    Another issue I encountered: After creating the database zabbix_db, I ran the command ant all privileges on zabbix_db.* to [email protected] identified by ; I got the error: ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near ” at line 1
    Any ideas on this? Thanks!

  9. Tinram says:

    Excellent and detailed tutorial, thank you.

    The only extra thing I needed to do was:
    mkdir /etc/zabbix/zabbix_server.conf.d/
    which is apparently due to a Zabbix bug.

  10. siow says:

    tried admin/zabbix upon first login but it does not work. I changed to Admin/zabbix and it worked. I am not sure why.

Leave a Reply to Tinram Cancel reply

Your email address will not be published. Required fields are marked *

Pin It on Pinterest