Zabbix HA Monitoring with Galera and HAProxy

Zabbix is another enterprise grade open source monitoring tool that has the advantage to be MySQL/PostgreSQL/SQLite/Oracle backed for storing
all the configurations and collected data.

As an alternative to installing agent on hosts it includes support for SNMP, TCP and ICMP checks, also JMX, SSH, Telnet, IPMI.

List of interesting features:

  • High performance, high capacity
  • Auto-discovery support
  • Distributed monitoring
  • Web based interface
  • Agent and Agent-less support

Setup prerequisites:

  • 2 LXC containers for Zabbix instances
  • Pre-installed and working Galera cluster
  • Pre-installed and working HAProxy cluster


Steps to create Zabbix HA:


Install Zabbix on both containers

for host in {zabbix01,zabbix02}; do ssh [email protected]$host 'rpm -ivh'; done

for host in {zabbix01,zabbix02}; do ssh [email protected]$host 'yum -y install zabbix-server-mysql zabbix-web-mysql'; done


Create database user on the Galera cluster

create database zabbix;
grant all privileges on zabbix.* to [email protected]'192.168.%' identified by 'Password123';


Populate the database with initial configuration

zcat /usr/share/doc/zabbix-server-mysql-3.0.0/create.sql.gz | mysql -u root -p zabbix -h galera.domain.tld


Configure Zabbix

vi /etc/zabbix/zabbix_server.conf

and change the lines below to march your Galera informations



Enable and start Zabbix

for host in {zabbix01,zabbix02}; do ssh [email protected]$host 'systemctl enable zabbix && systemctl start zabbix'; done

for host in {zabbix01,zabbix02}; do ssh [email protected]$host 'systemctl enable httpd && systemctl start httpd'; done


Avoid deadlocks because of HAProxy and Zabbix internals

Login to your HAProxy cluster nodes and make sure you are not using round robin load balancing but active-backup for Galera nodes

vi /etc/haproxy/haproxy.cfg

And change it to be similar to the setup below:

# Zabbix web frontend
listen http *:80
         option httplog
         option httpclose
         option forwardfor
         reqadd X-Forwarded-Proto:\ http

# define hosts
acl zabbix hdr(host) -i zabbix.domain.tld

# figure out what backends to use based on request
use_backend zabbix_cluster if zabbix

backend zabbix_cluster
          balance roundrobin
          server zabbix01 check
          server zabbix02 check

# Galera backend
listen galera *:3306
         mode tcp
         option httpchk
         balance leastconn
         server galera01 check port 9200
         server galera02 check port 9200 backup
         server galera03 check port 9200 backup


For HAProxy health check on Galera nodes go at paragraph HAProxy monitoring for Galera.


Restart HAProxy

systecmtl restart haproxy


Now access you Zabbix setup

Point your browser to http://zabbix.domain.tld

Default credentials are: Admin / zabbix

Now you can start customizing and using it.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.