Operations 27 min read

Build an Enterprise‑Level Distributed Zabbix Monitoring System on CentOS

This step‑by‑step guide shows how to set up a full LNMP stack, compile and configure Zabbix server, proxy, and agents on CentOS 7, covering repository setup, service initialization, database preparation, UI initialization, and host registration for a robust distributed monitoring solution.

Full-Stack DevOps & Kubernetes
Full-Stack DevOps & Kubernetes
Full-Stack DevOps & Kubernetes
Build an Enterprise‑Level Distributed Zabbix Monitoring System on CentOS

Overview

The article provides a comprehensive, hands‑on tutorial for deploying Zabbix 6.4.8 as an enterprise‑grade distributed monitoring platform on a CentOS 7.9 environment. It walks through building the LNMP stack, creating the required databases, compiling Zabbix from source, configuring server, proxy, and agents, and finalizing the web UI.

Prepare the Base Environment

Disable the firewall:

systemctl stop firewalld
systemctl disable firewalld

Turn off SELinux:

setenforce 0
sed -i "s/^SELINUX=.*/SELINUX=disabled/g" /etc/selinux/config

Set hostnames for all nodes (zbx, proxy, server01, server02) using hostnamectl set-hostname <name>.

Add host entries to /etc/hosts for name resolution.

Synchronize time with NTP:

yum -y install ntpdate && ntpdate ntp1.aliyun.com

Build the LNMP Stack on the Zabbix Server (zbx)

1.1 Configure Yum Repositories

# curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo
# curl -o /etc/yum.repos.d/epel.repo https://mirrors.aliyun.com/repo/epel-7.repo
# yum makecache fast

1.2 Install PHP 7.4, Nginx, and MariaDB 10.11

# yum install -y --enablerepo=remi --enablerepo=remi-php74 \
    mod_php php-gd* php php-opcache php-mbstring php-mysqlnd php-phpunit-PHPUnit \
    php-pecl-xdebug php-pecl-xhprof php-fpm php-devel php-bcmath php-ldap gcc* \
    libxml2-devel net-snmp net-snmp-devel libevent-devel curl-devel
# yum -y install nginx
# yum -y install mariadb-server mariadb-devel

1.3 Configure Nginx

# cd /etc/nginx/
# cp nginx.conf nginx.conf.bak
# rm -f nginx.conf
# cp nginx.conf.default nginx.conf
# vim /etc/nginx/nginx.conf   # edit server block, root /www, PHP fastcgi settings
# nginx -t && systemctl start nginx && systemctl enable nginx

1.4 Start Services

# systemctl start php-fpm && systemctl enable php-fpm
# systemctl start mariadb && systemctl enable mariadb

1.5 Verify Listening Ports

# netstat -anpt | grep nginx   # 80
# netstat -anpt | grep php-fpm # 9000
# netstat -anpt | grep mariadb # 3306

1.6 Set Database Root Password

# mysqladmin -u root password 'wzh.2005'

1.7 Test LNMP

# mkdir /www && vim /www/test.php
<?php
$link = mysqli_connect('127.0.0.1','root','wzh.2005');
if ($link) echo "Database connection successful!";
mysqli_close($link);
?>
# curl 192.168.93.101/test.php   # should return success message

1.8 Adjust php.ini

# vim /etc/php.ini
post_max_size = 16M
max_execution_time = 300
max_input_time = 300
memory_limit = 128M
upload_max_filesize = 2M
date.timezone = Asia/Shanghai
bcmath.scale = 1

1.9 Modify php‑fpm

# useradd -M -s /sbin/nologin zabbix
# vim /etc/php-fpm.d/www.conf
user = zabbix
group = zabbix
# systemctl restart php-fpm

Install and Configure Zabbix Server

2.1 Create Databases and Import Schema

# mysql -u root -pwzh.2005
MariaDB [(none)]> create database zabbix character set utf8 collate utf8_bin;
MariaDB [(none)]> create database zabbix_proxy character set utf8 collate utf8_bin;
MariaDB [(none)]> grant all privileges on zabbix.* to zabbix@'%' identified by 'zabbix';
MariaDB [(none)]> grant all privileges on zabbix_proxy.* to zabbix@'%' identified by 'zabbix';
MariaDB [(none)]> flush privileges;
# tar -zxvf zabbix-6.4.8.tar.gz && cd zabbix-6.4.8/database/mysql/
# mysql -uzabbix -pzabbix zabbix < schema.sql
# mysql -uzabbix -pzabbix zabbix < images.sql
# mysql -uzabbix -pzabbix zabbix < data.sql
# mysql -uzabbix -pzabbix zabbix_proxy < schema.sql

2.2 Compile Zabbix from Source

# cd /root/zabbix-6.4.8/
# ./configure --prefix=/usr/local/zabbix/ \
    --enable-server --enable-agent --with-mysql \
    --with-libcurl --with-libxml2 --with-net-snmp --with-unixODBC --with-zabbix-get
# make && make install

2.3 Optimize Paths and Service Scripts

# ln -s /usr/local/zabbix/sbin/* /usr/local/sbin/
# ln -s /usr/local/zabbix/bin/* /usr/local/bin/
# cp misc/init.d/fedora/core/zabbix_agentd /etc/init.d/
# cp misc/init.d/fedora/core/zabbix_server /etc/init.d/
# vim /etc/init.d/zabbix_agentd   # set BASEDIR=/usr/local/zabbix
# vim /etc/init.d/zabbix_server   # set BASEDIR=/usr/local/zabbix

2.4 Server Configuration (zabbix_server.conf)

# vim /usr/local/zabbix/etc/zabbix_server.conf
LogFile=/tmp/zabbix_server.log
LogFileSize=1024
DBHost=localhost
DBName=zabbix
DBUser=zabbix
DBPassword=zabbix
Timeout=10
CacheSize=256M
HistoryCacheSize=256M
TrendCacheSize=256M
ValueCacheSize=8M
StartTrappers=30
StartPollers=10

2.5 Agent Configuration (zabbix_agentd.conf)

# vim /usr/local/zabbix/etc/zabbix_agentd.conf
Server=127.0.0.1
ServerActive=127.0.0.1
Hostname=Zabbix server

2.6 Start Zabbix Services

# chkconfig --add zabbix_server
# chkconfig --add zabbix_agentd
# systemctl start zabbix_server && systemctl enable zabbix_server
# systemctl start zabbix_agentd && systemctl enable zabbix_agentd
# netstat -anpt | grep zabbix   # ports 10050 (agent) and 10051 (server) should be LISTEN

Initialize Zabbix Web UI

Open http://192.168.93.101/index.php, select Simplified Chinese, verify that all pre‑checks show “OK”, configure the database connection (host = localhost, DB = zabbix, user = zabbix, password = zabbix), keep the default hostname, and finish the wizard. Login with default credentials Admin / zabbix .

Zabbix login screen
Zabbix login screen

Install Zabbix Agents on Monitored Hosts

Agent on server01

# rpm -ivh pcre2-10.23-2.el7.x86_64.rpm
# rpm -ivh zabbix-agent-6.4.8-release2.el7.x86_64.rpm
# vim /etc/zabbix/zabbix_agentd.conf
Server=192.168.93.101
ServerActive=192.168.93.101
Hostname=server01
# systemctl start zabbix-agent && systemctl enable zabbix-agent

Add Host in Zabbix UI

Navigate to *Data collection → Hosts → Create host*, fill the name, assign the “Zabbix agent” template, and confirm. After a few minutes the host status turns green, indicating successful data collection.

Deploy Zabbix Proxy (proxy host)

3.1 Prepare Proxy Host

# curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo
# curl -o /etc/yum.repos.d/epel.repo https://mirrors.aliyun.com/repo/epel-7.repo
# yum makecache fast
# yum -y install gcc libxml2-devel unixODBC-devel net-snmp-devel libcurl-devel libssh2-devel OpenIPMI-devel openssl-devel openldap-devel libevent libevent-devel mariadb-devel
# tar -zxvf zabbix-6.4.8.tar.gz && cd zabbix-6.4.8/
# ./configure --prefix=/usr/local/zabbix --enable-proxy --with-mysql --with-net-snmp --with-libcurl --with-libxml2 --with-unixODBC
# make && make install

3.2 Configure Proxy

# vim /usr/local/zabbix/etc/zabbix_proxy.conf
ProxyMode=0
Server=192.168.93.101
Hostname=Zabbix proxy
ListenPort=10051
LogFile=/tmp/zabbix_proxy.log
LogFileSize=0
PidFile=/tmp/zabbix_proxy.pid
SocketDir=/tmp
DBHost=192.168.93.101
DBName=zabbix_proxy
DBUser=zabbix
DBPassword=zabbix
ProxyConfigFrequency=60
DataSenderFrequency=3
Timeout=4
LogSlowQueries=3000
TmpDir=/tmp
StatsAllowedIP=127.0.0.1

3.3 Start Proxy

# useradd -M -s /sbin/nologin zabbix
# /usr/local/zabbix/sbin/zabbix_proxy &
# netstat -anpt | grep zabbix_proxy   # port 10051 should be LISTEN

3.4 Register Proxy in UI

In the web UI go to *Management → Proxy → Create proxy*, choose “Active” mode, set the proxy name, and save. The proxy will appear as online after a short interval.

Add proxy UI
Add proxy UI

Configure Additional Agents via Proxy (server02)

# rpm -ivh pcre2-10.23-2.el7.x86_64.rpm
# rpm -ivh zabbix-agent-6.4.8-release2.el7.x86_64.rpm
# vim /etc/zabbix/zabbix_agentd.conf
Server=192.168.93.102
ServerActive=192.168.93.102
Hostname=server02
# systemctl start zabbix-agent && systemctl enable zabbix-agent

After configuring the agent, add the host in the Zabbix UI the same way as for server01. The proxy will forward the metrics to the central server.

Conclusion

Following the steps above results in a fully functional, enterprise‑scale Zabbix monitoring deployment with a central server, an active proxy, and multiple agents. The guide covers environment preparation, LNMP stack installation, source compilation, service tuning, database setup, UI initialization, and host registration, providing a reproducible blueprint for production environments.

DistributedCentOSZabbixLNMP
Full-Stack DevOps & Kubernetes
Written by

Full-Stack DevOps & Kubernetes

Focused on sharing DevOps, Kubernetes, Linux, Docker, Istio, microservices, Spring Cloud, Python, Go, databases, Nginx, Tomcat, cloud computing, and related technologies.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.