Zabbix Proxies on CentOS 7

Overview

A Zabbix proxy can collect performance and availability data on behalf of the Zabbix server. This way, a proxy can take on itself some of the load of collecting data and offload the Zabbix server.
Also, using a proxy is the easiest way of implementing centralized and distributed monitoring, when all agents and proxies report to one Zabbix server and all data is collected centrally.
A Zabbix proxy can be used to:
  • Monitor remote locations
  • Monitor locations having unreliable communications
  • Offload the Zabbix server when monitoring thousands of devices
  • Simplify the maintenance of distributed monitoring

Setting up Proxy Server

We will be using a separate Linux server with CentOS 7 as the base operating system with MariaDB database server installed on it that will be used as a local database for Proxy server. So in this article we assume that you already had set up your Zabbix Server.

[root@localhost ~]# rpm --import http://repo.zabbix.com/RPM-GPG-KEY-ZABBIX

[root@localhost ~]# rpm -Uv http://repo.zabbix.com/zabbix/3.0/rhel/7/x86_64/zabbix-release-3.0-1.el7.noarch.rpm

Installing Zabbix Proxy

We have to create a separate user and group that will be used for zabbix running processes.
Let's create a group and a user with name "zabbix" as:
[root@localhost ~]# groupadd zabbix
[root@localhost ~]# useradd -g zabbix zabbix

Now run the zabbix proxy installation command with yum installer.
[root@localhost etc]# yum -y install zabbix-proxy-mysql

Configure & Install MariaDB

Adding the MariaDB YUM Repository

MariaDB.repo entry, add it to a file under /etc/yum.repos.d/. (suggest something like/etc/yum.repos.d/MariaDB.repo.)
An example MariaDB.repo file for CentOS 7 is:
[mariadb]
name = MariaDB
baseurl = http://yum.mariadb.org/10.1/centos7-amd64
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
gpgcheck=1

Installing MariaDB with YUM

With the repo file in place you can now install MariaDB like so:
sudo yum install MariaDB-server MariaDB-client
If you don't have the MariaDB GPG Signing key installed, YUM will prompt you to install it after downloading the packages (but before installing them).


Database Setup for Zabbix Proxy

As we had done with installation of all prerequisite packages necessary for zabbix proxy, now we will setup its database using mysql. Proceeding to the database settings first check that your mysql server is up and you can login with your root password.
[root@localhost ~]# systemctl start mariadb


[root@localhost ~]# mysql -uroot -p


Creating new database

Once your mysql server is up and you are logged into it, create a new database for zabbix proxy.
MariaDB [(none)]> create database zabbix_proxy character set utf8;
Query OK, 1 row affected (0.01 sec)

Assigning Privileges

In order to grant user level privileges on databases to zabbix user run the following command.
MariaDB [(none)]> GRANT all privileges ON zabbix_proxy.* TO 'zabbix'@'127.0.0.1' IDENTIFIED BY 'abc123';
Query OK, 1 row affected (0.01 sec)

MariaDB [(none)]> GRANT all privileges ON zabbix_proxy.* TO 'zabbix'@'localhost' IDENTIFIED BY 'abc123';
Query OK, 1 row affected (0.01 sec)

MariaDB [(none)]> flush privileges;
Query OK, 1 row affected (0.01 sec)

Loading Zabbix Schema

Exit from the mysql database server and from the shell we need to import zabbix schema into newly created database for zabbix proxy. Run the below commands to load zabbix schema from the zabbix database source for its latest version.
[root@localhost zabbix-proxy-mysql-3.0.2]# pwd
/usr/share/doc/zabbix-proxy-mysql-3.0.2

The above command states that we are currently in mysql directory of zabbix source, here we run the command to import its schema into the newly created database for zabbix proxy.
[root@localhost zabbix-proxy-mysql-3.0.2]# zcat schema.sql.gz | mysql -uroot zabbix_proxy

Zabbix Proxy Configuration

We are going to configure zabbix proxy configurations now, to do so let's open up the zabbix proxy conf file placed in "/etc/zabbix/" directory with your file editor.
[root@localhost zabbix]# vim zabbix_proxy.conf

Now configure it with following options:
ProxyMode=0
Server="IP Of Your Zabbix Server"
ServerPort="Define Your Port"
Hostname="Hostname For This Zabbix Proxy"
LogFile=/var/log/zabbix/zabbix_proxy.log
LogFileSize=512
DebugLevel=3
PidFile=/var/run/zabbix/zabbix_proxy.pid
DBHost=localhost
DBName=zabbix_proxy
DBUser=zabbix
DBPassword=abc123
DBSocket=/var/lib/mysql/mysql.sock
HeartbeatFrequency=15
ConfigFrequency=1800
DataSenderFrequency=1
SNMPTrapperFile=/var/log/snmptrap/snmptrap.log
Timeout=4
ExternalScripts=/usr/lib/zabbix/externalscripts
LogSlowQueries=3000

Now save the changes to the zabbix configurations file and close it with "wq!".

Start Zabbix Proxy Services
Run the "systemctl start zabbix-proxy" command to start its service.
[root@localhost zabbix]# systemctl start zabbix-proxy

Configure Zabbix Proxy on Master Server
Please refer following link to configure zabbix proxy on Master Server

Comments

Popular posts from this blog

Configure & Install WMIC for Observium

Join CentOS 7 into Active Directory using realm and sssd