Installing and Configuring Zabbix 2.4.5 on Debian 8 and RHEL/CentOS 7

Thursday, December 3rd 2015. | monitoring, tutorial

Installing and Configuring Zabbix 2.4.5 on Debian 8 and RHEL/CentOS 7 –

Zabbix is an Open Source, high-level enterprise software designed to monitor and keep track of networks, servers and applications in real time. Build in a server-client model, Zabbix can collect different type of data than are used to create historical graphics and output performance or load trends of the monitored targets.

The server has the ability to check standard networking services (HTTP, FTP, SMTP, IMAP etc) without the need to install extra software on the monitored hosts.

However, in order to gather data and create statistics about local services or other specific system resources that run on remote instances, such as CPU, disks, internal system process, RAM, etc, you need to install and configure a Zabbix agent.

Install Zabbix on Debian CentOS and Red Hat

Following are the 4-article series about Zabbix Monitoring application:

Part 1: Installing and Configuring Zabbix 2.4.5 on Debian 8 and RHEL/CentOS 7
Part 2: How to Configure ‘Zabbix Monitoring’ to Send Email Alerts to Gmail Account
Part 3: How to Install and Configure Zabbix Agents on Remote Linux Systems
Part 4: How to Install Zabbix Agent and Add Windows Host to Zabbix Monitoring

This tutorial will focus on how to install and compile Zabbix server from sources on Debian 8 Jessie and RHEL/CentOS 7 with MySQL backend database to store collected data, PHP and Apache Web Server as the mainly web interface.

Important: The given Zabbix instructions also works on all Debian derivatives and RedHat based systems like RHEL/CentOS and Fedora.

Step 1: Install Initial Required Software and Dependencies

1. As for the moment, Zabbix does not provide any official pre-compiled binary package for Debian 8 and RHEL/CentOS 7, so the main solution remains to manually download and compile it for sources.

In order to compile and install Zabbix from sources, your box needs a series of tools and dependencies installed on the system, such as: build-essentials (required for compiling debian packages from sources), devlopment tools (for RedHat based systems) GCC (acronym for the GNU Compiler Collection), some cli network http tools such as curl and wget, and other necessary dependencies in order to add extra functionality (SNMP support).

Install all of this packages on system by issuing the following command:

On Debian 8 Jessie
$ sudo apt-get install build-essential gcc curl wget libsnmp-dev libcurl4-gnutls-dev libxml2-dev 
On RHEL/CentOS 7
# yum install gcc gcc-c++ make openssl-devel curl wget net-snmp net-snmp-utils net-snmp-libs net-snmp-devel gnutls gnutls-devel libxml2 libxml2-devel

Step 2: Install MariaDB Database and Library

2. On the next step install MariaDB database and MySQL development library from binary packages. As MariaDB installs on your system you will be asked to set a password for the database root user during installation (Only on Debian 8). Choose a strong password, repeat it and wait for the installation to finish.

$ sudo apt-get install mariadb-server mariadb-client libmysqld-dev		[On Debian 8] 
# yum install mariadb-server mariadb-client mariadb-devel			[On RHEL/CentOS 7]

Set MySQL root Password

3. When the installation of Mariadb finishes, secure the database by issuing mysql_secure_installation command with system root privileges ( answer with yes for removing anonymous users, disable root login remotely, remove test database and access to it and apply all changes).

# mysql_secure_installation

Use the below screenshot as a guide.

Secure MySQL Installation

Step 3: Install Apache Web Server and PHP

4. Next, install Apache Web Server alongside with PHP programming language in order to provide the web backed functionality for Zabbix Server by issuing the following command:

$ sudo apt-get install apache2 php5 php5-mysql php5-gd php5-cli php5-xmlrpc 		[On Debian 8] 
# yum install httpd php php-mysql php-gd pgp-cli php-xml php-bcmath php-mbstring mod_ssl openssl		[On RHEL/CentOS 7]

Install Apache and PHP

5. Next, you need to tune PHP interpreter and adjust some values in order to run Zabbix Server. So, open Apache php.ini configuration file for editing by issuing the following command:

$ sudo nano /etc/php5/apache2/php.ini 		[On Debian 8] 
# nano /etc/php.ini				[On RHEL/CentOS 7]

Now, search with CTRL+C and replace the following PHP values as it follows:

post_max_size = 16M
max_execution_time = 300
max_input_time = 300
date.timezone = Continent/City  
always_populate_raw_post_data = -1

The list of PHP supported Timezones can be found here http://php.net/manual/en/timezones.php.

6. After you’re done, save the file (Ctrl+o) and exit (Ctrl+x) and restart Apache daemon in order to reflect changes by issuing the below command.

$ sudo systemctl restart apache2.service		[On Debian 8] 
# systemctl restart httpd.service			[On RHEL/CentOS 7]


Step 4: Download, Compile and Install Zabbix Server

7. Now your system is ready for compiling and installing Zabbix server from sources. First, using the wget utility, grab the latest version of Zabbix archive ( 2.4.5 current version when writing the guide) by issuing the following command:

# wget http://sourceforge.net/projects/zabbix/files/ZABBIX Latest Stable/2.4.5/zabbix-2.4.5.tar.gz

Download Zabbix Monitoring

If you want to download and compile an older version, please visit Zabbix official Sourceforge repositories.

8. Next, decompress and extract zabbix archive, enter into the extracted directory and list its contents.

# tar xfz zabbix-2.4.5.tar.gz
# cd zabbix-2.4.5.tar.gz/
# ls

Extract Zabbix Archive

9. While your placed into zabbix sources directory, get a list of compiling parameters for zabbix by running ./configure -h command.

Once you decided on your Zabbix server configuration, run ./configure command with the appropriate compiling parameters and wait for the compilation process to finish.

For this setup and for a standard Zabbix server compilation from sources use the following parameters as below:

# ./configure --enable-server --enable-agent --with-mysql --enable-ipv6 --with-net-snmp --with-libcurl --with-libxml2 

Compile Zabbix from Source

10. Once the software has been configured, run the make command in order to create the installable binaries (usually this step takes longer than configuring command to finish) and install Zabbix by issuing the make install command with root privileges:

# make  
# make install

Install Zabbix From Source

Zabbix Source Installation

Step 5: Zabbix Post-Installation System Settings

11. On the next step you need to create an unprivileged system account that will run Zabbix daemon process. Issue the below commands to create zabbix group and system account:

# groupadd zabbix
# useradd -g zabbix -d /usr/local/share/zabbix -s /bin/false zabbix

Create Zabbix User and Group

Step 6: Configure MariaDB Database for Zabbix

12. Next, enter Mariadb database command line and create a MySQL database for Zabbix server with a privileged user to manage the database by issuing the following commands:

mysql -u root -p 
MariaDB> create database zabbix;
MariaDB> grant all privileges on zabbix.* to 'zabbix'@'localhost' identified by 'your_password';
MariaDB> flush privileges;
MariaDB> exit

If your zabbix server runs on a different system than MariaDB server, add the following line to MariaDB server in order for zabbix user to access the database remotely (you can replace % with the IP Address of the zabbix host):

MariaDB> grant all privileges on zabbix.* to 'zabbix'@'%' identified by 'your_password';

Configure Mariadb for Zabbix

13. On the next step enter zabbix extracted source directory (in case you left the location meantime), list the available MySQL tables and import all of them into the newly created zabbix database by running the following commands:

# cd zabbix-2.4.5/
# ls database/mysql/
# mysql -u zabbix -p zabbix < database/mysql/schema.sql
# mysql -u zabbix -p zabbix < database/mysql/images.sql
# mysql -u zabbix -p zabbix < database/mysql/data.sql

Import Tables to Zabbix Database

Step 7: Configure Apache Webserver for Zabbix

14. After importing MySQL tables, copy all the sources PHP frontend configuration files into Apache webserver document root by issuing the below command. Also, make sure that you previously delete the default Apache index.html file.

# rm /var/www/html/index.html15.
# cp -rf frontends/php/* /var/www/html/

Configure Apache for Zabbix

15. Next, add zabbix system user to Apache system group www-data, enable SSL Apache module and host in order to run Zabbix web interface securely and restart Apache daemon to apply changes.

On Debian 8 System
# usermod -aG www-data zabbix 
# a2enmod ssl
# a2ensite default-ssl
# systemctl restart apache2.service
On RHEL/CentOS 7 System
# usermod -aG apache zabbix
# systemctl restart httpd.service

Add Zabbix User to Apache

Step 8: Configure Zabbix Server

16. On this step open zabbix server configuration file for editing by issuing the following command:

# nano /usr/local/etc/zabbix_server.conf

Once the file is opened for editing search and replace the following values accordingly:

ListenPort=10051
LogFile=/var/log/zabbix_server.log
DBHost=localhost   ## Replace with the IP of the remote database in case MySQL server is located on a different host
DBName=zabbix  ## Use the name of the Zabbix MySQL database
DBUser =zabbix   ## Use the name of the Zabbix MySQL database User
DBPassword=password  ## Zabbix MYSQL database password
DBSocket=/var/run/mysqld/mysqld.sock
DBPort=3306

17. As the configuration file of the Zabbix server suggests you need to create the log file and add permissions to Zabbix server to write the log by issuing the following commands:

# touch /var/log/zabbix_server.log
# chmod 775 /var/log/zabbix_server.log
# chgrp zabbix /var/log/zabbix_server.log

18. Finally, after all the server configurations are in place, start Zabbix Server and Agent (to collect data about localhost) by issuing the following commands:

# /usr/local/sbin/zabbix_server
# /usr/local/sbin/zabbix_agentd
# /usr/local/sbin/zabbix_agent

You can get the status of the Zabbix daemons and their listening ports by running netstat command.

# netstat -tulpn

Start Zabbix Server and Agent

Step 9: Install Zabbix Web Frontend Interface

19. Now it’s time to install Zabbix Server Frontend web interface. In order to accomplish this step open a browser and navigate to your server IP Address using HTTP or HTTPS protocol and the welcome screen should appear. Hit the Next button to move forward.

http://192.168.1.221/setup.php
OR
https://192.168.1.221/setup.php

Zabbix Welcome Screen

20. After a series of checks, if all pre-requires values are satisfied, hit the Next button to proceed further.

Check Zabbix Pre-Requisites

21. On the next step provide the settings for MySQL database (supply the same values as above on step 16), hit the Test connection button to test MySQL connectivity and move to the step by pressing the Next button.

Zabbix DB Configuration

22. Next, supply the Host (or IP Address) and the Port of the Zabbix server (use the host localhost and the port 10051 because zabbix server is configured to run on the same host as the zabbix frontend web interface in this tutorial) and a Name for Zabbix frontend installation. When you’re done hit Next to continue.

Configure Zabbix Server

23. Next, check all the configurations parameters, enter command line and issue the following command to grant zabbix permissions to write the apache web configuration file in conf directory.

Then switch back to web interface and hit Next button to write zabbix configuration file.

# chown -R www-data /var/www/html/conf/		[on Debian 8]
# chown -R apache /var/www/html/conf/		[on RHEL/CentOS 7]

Zabbix Installation Summary

Zabbix Installation Completed

24. After the configuration file has been written, hit Finish button to complete the installation process and enter command line to revert changes made to zabbix conf directory.

# chown -R root /var/www/html/conf/

25. Now you can log in to Zabbix web interface using the default credentials:

Username: admin
Password: zabbix

Zabbix Login

Zabbix Dashboard

26. In order to start Zabbix daemons after system reboot, open /etc/rc.local file for editing and add the following lines before exit 0 statement:

# /usr/local/sbin/zabbix_agentd
# /usr/local/sbin/zabbix_agent
# /usr/local/sbin/zabbix_server

Start Zabbix System Boot

That’all! On the next series concerning Zabbix monitoring system will discuss how to setup the server further using the web interface and how to install and configure Zabbix agents on different Linux distributions or even Windows systems.

 

http://www.tecmint.com/install-and-configure-zabbix-monitoring-on-debian-centos-rhel/

Source link