Zabbix is Open Source cross platform Monitoring Tool for network and application, which provide fairly good features for various platforms.which can able to collect data from various hosts through various ways like SNMP, Zabbix agents, SSH, IPMI, HTTP and JMX etc.
zabbix_logo
In this post, we would see Zabbix Server Installation CentOS7. In earlier posts, we saw how we could install it in CentOS6. we would also cover how we could install it on CentOS7 later.
We are considering, that readers know how to install CentOS7

Setup

# cat /etc/redhat-release 
CentOS Linux release 7.3.1611 (Core)
# uname  -r
3.10.0-514.26.2.el7.x86_64

Installation

For Zabbix. we need to configure Apache – For hosting Zabbix Site, MySQL – For storing Zabbix database, PHP – Zabbix frontend written in PHP.
So installing it on Linux is configure LAMP (Linux Apache MySQL PHP) on one Host.

We can Install it with CentOS repositories, That will automatically resolve all dependencies and install Zabbix packages in one command. But I always recommend to install it from tar bundle downloaded from Zabbix website.

Installation of packages

Let’s Install some basic packages involved in the setup. Apache, Mysql-server and PHP. There are some other packages required for proper function of which we would see later during Zabbix code compilation.

# yum install httpd

# yum install mariadb 

# yum install  libapache2-mod-php php php-bcmath php-cli php-common php-gd php-json php-ldap php-mbstring php-mysql php-opcache php-readline php-xml

#yum install gcc make libssh2-devel-1.4.3-10.el7_2.1.x86_64 OpenIPMI-devel-2.0.19-15.el7.x86_64 libxml2-devel-2.9.1-6.el7_2.3.x86_64 net-snmp-devel-5.7.2-24.el7_3.2.x86_64 unixODBC-devel-2.3.1-11.el7.x86_64 openldap-devel-2.4.40-13.el7.x86_64 libcurl-devel-7.29.0-35.el7.centos.x86_64

Start apache service and enable it for boot.

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

Start MySQL Service and enable it for boot.

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

MySQL root password, it good to secure MySQL with root@loaclhost password.

[root@srv7-sec zabbix-3.2.7]# mysqladmin -u root password 'Passw0rd'
[root@srv7-sec zabbix-3.2.7]# mysql -u root -p
Enter password: 
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 6
Server version: 5.5.52-MariaDB MariaDB Server

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

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

MariaDB [(none)]> 

In above commands “Passw0rd” used as password for root@localhost

Creation of MySQL Database

For Zabbix, we need to create Zabbix database that will store data collected from monitoring devices and Host and will fetch from Apache2 running on Zabbix Apache machine to display on the browser.
So let’s start creating Zabbix database. For this, we need to login on MySQL and run below commands.

[root@srv7-master7-master ~]# mysql
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 4
Server version: 5.5.52-MariaDB MariaDB Server

Copyright (c) 2000, 2016, 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 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 'passw0rd';
Query OK, 0 rows affected (0.00 sec)

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

MariaDB [(none)]> Bye

Now we have zabbix database, in MySQL with zabbix user as defined above. Now we could download Zabbix tar ball from website, this need to extract and export database sql in database as below.

root@srv7-master:~# pwd
/root
root@srv7-master:~# ls
zabbix-3.2.7.tar.gz
root@srv7-master:~# tar -xzf zabbix-3.2.7.tar.gz
root@srv7-master:~# ls
zabbix-3.2.7  zabbix-3.2.7.tar.gz
root@srv7-master:~# cd zabbix-3.2.7/database/mysql/
root@srv7-master:~/zabbix-3.2.7/database/mysql# ls
data.sql  images.sql  schema.sql
root@srv7-master:~/zabbix-3.2.7/database/mysql# mysql -u zabbix zabbix -p < schema.sql
Enter password:
root@srv7-master:~/zabbix-3.2.7/database/mysql# mysql -u zabbix zabbix -p < images.sql
Enter password:
root@srv7-master:~/zabbix-3.2.7/database/mysql# mysql -u zabbix zabbix -p < data.sql
Enter password:

So this way, Zabbix database updates and create required tables in the database. Now we could work on Apache and PHP.

Zabbix code compilation

As we already have zabbix tar ball in system. we should compile tar ball and install Zabbix binares.

root@srv7-master:~/zabbix-3.2.7# pwd
/root/zabbix-3.2.7
root@srv7-master:~/zabbix-3.2.7# ./configure --enable-server --enable-agent --with-mysql --enable-ipv6 --with-net-snmp --with-libcurl --with-ldap --with-openipmi  --with-libxml2  --with-ssh2 --with-unixodbc

Compilation completed of Zabbix, will show below output

Configuration:

  Detected OS:           linux-gnu
  Install path:          /usr/local
  Compilation arch:      linux

  Compiler:              gcc
  Compiler flags:         -g -O2

  Library-specific flags:
    database:               -I/usr/include/mysql   
    libXML2:               -I/usr/include/libxml2
    unixODBC:              -I/usr/include
    Net-SNMP:               -I/usr/local/include -I/usr/lib64/perl5/CORE -I. -I/usr/include
    OpenIPMI:              -I/usr/include
    libssh2:               -I/usr/include
    LDAP:                  -I/usr/include

  Enable server:         yes
  Server details:
    With database:         MySQL
    WEB Monitoring:        cURL
    Native Jabber:         no
    SNMP:                  yes
    IPMI:                  yes
    SSH:                   yes
    TLS:                   no
    ODBC:                  yes
    Linker flags:             -L/usr/lib64/mysql      -L/usr/lib64  -L/usr/lib64 -L/usr/lib -L/usr/lib  -L/usr/lib  -rdynamic  
    Libraries:               -lmysqlclient      -lxml2  -lodbc  -lnetsnmp -lssh2 -lOpenIPMI -lOpenIPMIposix  -lldap -llber   -lcurl -lm -ldl  -lresolv 

  Enable proxy:          no

  Enable agent:          yes
  Agent details:
    TLS:                   no
    Linker flags:            -L/usr/lib  -rdynamic  
    Libraries:               -lldap -llber   -lcurl -lm -ldl  -lresolv 

  Enable Java gateway:   no

  LDAP support:          yes
  IPv6 support:          yes

***********************************************************
*            Now run 'make install'                       *
*                                                         *
*            Thank you for using Zabbix!                  *
*              <http://www.zabbix.com>                    *
***********************************************************

Now run make install as shown in above output

#make install

We can see further that Zabbix installed properly.

[root@srv7-master zabbix-3.2.7]# ls -l /usr/local/*/zabbix_*
-rwxr-xr-x 1 root root  404240 Aug 12 16:54 /usr/local/bin/zabbix_get
-rwxr-xr-x 1 root root  479560 Aug 12 16:54 /usr/local/bin/zabbix_sender
-rw-r--r-- 1 root root   10234 Aug 12 16:54 /usr/local/etc/zabbix_agentd.conf
-rw-r--r-- 1 root root   14663 Aug 12 16:54 /usr/local/etc/zabbix_server.conf
-rwxr-xr-x 1 root root 1416296 Aug 12 16:54 /usr/local/sbin/zabbix_agentd
-rwxr-xr-x 1 root root 5088600 Aug 12 16:54 /usr/local/sbin/zabbix_server

/usr/local/etc/zabbix_agentd.conf.d:
total 0

/usr/local/etc/zabbix_server.conf.d:
total 0

Create Zabbix user and group which run Zabbix Server binary.

groupadd zabbix
useradd -g zabbix zabbix

Now we should need to edit Zabbix Server and Zabbix Agent configuration file.

DBPassword needd to mention in Zabbix_Server configuration file, otherwise Zabbix Server process can’t able to connect MySQL to fill-up databases.

First edit Zabbix_server configuration file “/usr/local/etc/zabbix_server.conf”, These are very common changes that effect Zabbix Server function.

[root@srv7-master ~]# egrep -v "^#|^$" /usr/local/etc/zabbix_server.conf
ListenPort=10051
LogFile=/tmp/zabbix_server.log
PidFile=/tmp/zabbix_server.pid
DBHost=localhost
DBName=zabbix
DBUser=zabbix
DBPassword=Passw0rd
DBSocket=/tmp/mysql.sock
DBPort=3306

Let’s talk some of above derivatives, except DBPassword all derivatives are default and very well drafted in file like
port(Server listening port)
log-file(Zabbix Server log-file )
pid-file(Zabbix Server pid file)
DBHost(Database Host)
DBName(Database Name)
DBUser(Database User name, which has all access on mentioned database name)
DBPassword(Database User password through which it will going to access Database)
DOSocket(Database Server Socket file)
DBPort(Database Sever port on which we need to connect).

So These derivatives are very important to match with you setup, otherwise your Zabbix Server will not work accordingly.

Let’s edit Agent configuration file. It’s important to work on this file because of this Agent process Zabbix server will collect details and show on Zabbix Server web console.

[root@srv7-master ~]# egrep -v "^#|^$" /usr/local/etc/zabbix_agentd.conf
LogFile=/tmp/zabbix_agentd.log
Server=127.0.0.1
ServerActive=127.0.0.1
Hostname=srv7-master

I didn’t change any derivatives except Hostname, its always good to mention correct Hostname in this file. Now we could start Zabbix Server and Zabbix agent process.

Now we should run Zabbix server with below command.

[root@srv7-master ~]# /usr/local/sbin/zabbix_server -c /usr/local/etc/zabbix_server.conf
[root@srv7-master ~]# ps -fC zabbix_server
UID        PID  PPID  C STIME TTY          TIME CMD
zabbix    8929     1  0 13:41 ?        00:00:00 /usr/local/sbin/zabbix_server -c /usr/local/etc/zabbix_server.conf
zabbix    8934  8929  0 13:41 ?        00:00:00 /usr/local/sbin/zabbix_server: configuration syncer [synced configuration in 0.013774 sec, idle 60 sec]
zabbix    8935  8929  0 13:41 ?        00:00:00 /usr/local/sbin/zabbix_server: db watchdog [synced alerts config in 0.000578 sec, idle 60 sec]
zabbix    8936  8929  0 13:41 ?        00:00:00 /usr/local/sbin/zabbix_server: poller #1 [got 0 values in 0.000002 sec, idle 1 sec]
zabbix    8937  8929  0 13:41 ?        00:00:00 /usr/local/sbin/zabbix_server: poller #2 [got 0 values in 0.000002 sec, idle 1 sec]
zabbix    8938  8929  0 13:41 ?        00:00:00 /usr/local/sbin/zabbix_server: poller #3 [got 0 values in 0.000002 sec, idle 1 sec]
zabbix    8939  8929  0 13:41 ?        00:00:00 /usr/local/sbin/zabbix_server: poller #4 [got 1 values in 0.000028 sec, idle 1 sec]
zabbix    8940  8929  0 13:41 ?        00:00:00 /usr/local/sbin/zabbix_server: poller #5 [got 0 values in 0.000002 sec, idle 1 sec]
zabbix    8941  8929  0 13:41 ?        00:00:00 /usr/local/sbin/zabbix_server: unreachable poller #1 [got 0 values in 0.000005 sec, idle 5 sec]
zabbix    8942  8929  0 13:41 ?        00:00:00 /usr/local/sbin/zabbix_server: trapper #1 [processed data in 0.000000 sec, waiting for connection]
zabbix    8943  8929  0 13:41 ?        00:00:00 /usr/local/sbin/zabbix_server: trapper #2 [processed data in 0.000000 sec, waiting for connection]
zabbix    8944  8929  0 13:41 ?        00:00:00 /usr/local/sbin/zabbix_server: trapper #3 [processed data in 0.000000 sec, waiting for connection]
zabbix    8945  8929  0 13:41 ?        00:00:00 /usr/local/sbin/zabbix_server: trapper #4 [processed data in 0.000006 sec, waiting for connection]
zabbix    8946  8929  0 13:41 ?        00:00:00 /usr/local/sbin/zabbix_server: trapper #5 [processed data in 0.000000 sec, waiting for connection]
zabbix    8947  8929  0 13:41 ?        00:00:00 /usr/local/sbin/zabbix_server: icmp pinger #1 [got 0 values in 0.000003 sec, idle 5 sec]
zabbix    8954  8929  0 13:41 ?        00:00:00 /usr/local/sbin/zabbix_server: alerter [sent alerts: 0 success, 0 fail in 0.000825 sec, idle 30 sec]
zabbix    8955  8929  0 13:41 ?        00:00:00 /usr/local/sbin/zabbix_server: housekeeper [deleted 0 hist/trends, 0 items, 0 events, 0 sessions, 0 alarms, 0 audit items in 0.009892 sec, id
zabbix    8956  8929  0 13:41 ?        00:00:00 /usr/local/sbin/zabbix_server: timer #1 [processed 1 triggers, 0 events in 0.000144 sec, 0 maintenances in 0.000000 sec, idle 30 sec]
zabbix    8957  8929  0 13:41 ?        00:00:00 /usr/local/sbin/zabbix_server: http poller #1 [got 0 values in 0.000313 sec, idle 5 sec]
zabbix    8958  8929  0 13:41 ?        00:00:00 /usr/local/sbin/zabbix_server: discoverer #1 [processed 0 rules in 0.000434 sec, idle 60 sec]
zabbix    8959  8929  0 13:41 ?        00:00:00 /usr/local/sbin/zabbix_server: history syncer #1 [synced 0 items in 0.000001 sec, idle 1 sec]
zabbix    8960  8929  0 13:41 ?        00:00:00 /usr/local/sbin/zabbix_server: history syncer #2 [synced 0 items in 0.000001 sec, idle 1 sec]
zabbix    8966  8929  0 13:41 ?        00:00:00 /usr/local/sbin/zabbix_server: history syncer #3 [synced 0 items in 0.000002 sec, idle 1 sec]
zabbix    8967  8929  0 13:41 ?        00:00:00 /usr/local/sbin/zabbix_server: history syncer #4 [synced 0 items in 0.000001 sec, idle 1 sec]
zabbix    8968  8929  0 13:41 ?        00:00:00 /usr/local/sbin/zabbix_server: escalator #1 [processed 0 escalations in 0.000382 sec, idle 3 sec]
zabbix    8969  8929  0 13:41 ?        00:00:00 /usr/local/sbin/zabbix_server: proxy poller #1 [exchanged data with 0 proxies in 0.000002 sec, idle 5 sec]
zabbix    8970  8929  0 13:41 ?        00:00:00 /usr/local/sbin/zabbix_server: self-monitoring [processed data in 0.000002 sec, idle 1 sec]
zabbix    8972  8929  0 13:41 ?        00:00:00 /usr/local/sbin/zabbix_server: task manager [processed 0 task(s) in 0.000201 sec, idle 5 sec]

Now we should also start Zabbix Agent as well

[root@srv7-master ~]# /usr/local/sbin/zabbix_agentd -c /usr/local/etc/zabbix_agentd.conf
[root@srv7-master ~]# ps -fC zabbix_agentd
UID        PID  PPID  C STIME TTY          TIME CMD
zabbix    9153     1  0 13:49 ?        00:00:00 /usr/local/sbin/zabbix_agentd -c /usr/local/etc/zabbix_agentd.conf
zabbix    9154  9153  0 13:49 ?        00:00:01 /usr/local/sbin/zabbix_agentd: collector [idle 1 sec]
zabbix    9155  9153  0 13:49 ?        00:00:00 /usr/local/sbin/zabbix_agentd: listener #1 [waiting for connection]
zabbix    9156  9153  0 13:49 ?        00:00:00 /usr/local/sbin/zabbix_agentd: listener #2 [waiting for connection]
zabbix    9157  9153  0 13:49 ?        00:00:00 /usr/local/sbin/zabbix_agentd: listener #3 [waiting for connection]
zabbix    9158  9153  0 13:49 ?        00:00:00 /usr/local/sbin/zabbix_agentd: active checks #1 [idle 1 sec]

As we have already installed Apache, MySQL and PHP. Configure MySQL, zabbix Server and Zabbix Agent as above and started MySQL,Apache, Zabbix Server and Zabbix Agent process.Now we need to see how things works for Zabbix web console.
For web console we also need to prepare PHP for same, below are settings that should apply for PHP

PHP settings

Edit /etc/php/7.0/apache2/php.ini file for below derivatives. On Error window as well it shows you clearly about derivatives and their required values.

date.timezone = 'Asia/Kolkata'
max_execution_time = 300
post_max_size = 32M
max_input_time = 300

Restart Apache once more

[root@srv7-master ~]# systemctl restart httpd

We need to copy Zabbix PHP frontend file in “/var/www/html” and configure it in such way that it could connect MySQL to fetch data from it.

root@srv7-master:~/zabbix-3.2.7/frontends/php
# pwd
/root/zabbix-3.2.7/frontends/php
root@srv7-master:~/zabbix-3.2.7/frontends/php# cp -rfp * /var/www/html/
root@srv7-master:~/zabbix-3.2.7/frontends/php# chown -R www-data:www-data /var/www/html/

Now the time comes when we could start work on Zabbix web console for its configuration. So open http://IP-Address from local browser.
Installation_1

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Click on Next.

Installation_3

 

 

 

 

 

 

 

 

 

 

 

 

 

 

provide MySQL Zabbix password and click Next

Installation_4

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Put Zabbix Hostname, Better to have the good significant hostname or DNS Record. Click Next

Installation_5

 

 

 

 

 

 

 

 

 

 

 

 

 

installation Summary, Click Next.

Installation_6

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Congratulations, It’s Done.

 

Installation_7

 

 

 

 

 

 

 

 

 

 

 

 

Now we could open Zabbix Admin Panel.

User     - Admin
Password - zabbix

In case you faced any issues while login, can change Admin (Upper case A) user password, Try this