How to Install Zabbix 7 on CentOS Stream 9: Real-World Infrastructure Monitoring

CentOS tutorial - IT technology blog
CentOS tutorial - IT technology blog

The Nightmare Called “Server Down at Dawn”

This scenario is likely familiar to any SysAdmin: 2 AM, the phone vibrates incessantly. The system is down, customers are complaining, and you spend an hour just to discover the disk is full. A basic error, yet it causes significant damage if not alerted in time.

After CentOS 8 reached End of Life (EOL), I pivoted to CentOS Stream 9 and AlmaLinux. The good news is that Zabbix 7 (the latest LTS version) runs incredibly smoothly on this platform. Capable of processing thousands of new values per second (NVPS), Zabbix 7 is not just a resource tracker—it’s a reliable “set of eyes” that lets you sleep easier.

Quick Start: Deploy in 5 Minutes

If you are comfortable with the command line and need the system running immediately, execute the following commands. Note: Please run as root or with sudo.

# 1. Add official Zabbix 7 repository
rpm -Uvh https://repo.zabbix.com/zabbix/7.0/release/centos/9/x86_64/zabbix-release-7.0-5.el9.noarch.rpm
dnf clean all

# 2. Install necessary component packages
dnf install zabbix-server-mysql zabbix-web-mysql zabbix-nginx-conf zabbix-sql-scripts zabbix-selinux-policy zabbix-agent2 -y

# 3. Install and enable MariaDB
dnf install mariadb-server -y
systemctl enable --now mariadb
mysql_secure_installation

Detailed System Configuration Steps

Step 1: Initialize a Dedicated Database

Zabbix requires a powerful database to store millions of metric records. I chose MariaDB for its high stability on the RHEL ecosystem. Important note: Zabbix requires the utf8mb4_bin collation to ensure case sensitivity for monitored items.

mysql -u root -p

create database zabbix character set utf8mb4 collate utf8mb4_bin;
create user zabbix@localhost identified by 'YourPassword';
grant all privileges on zabbix.* to zabbix@localhost;
set global log_bin_trust_function_creators = 1;
quit;

Next, import the schema and initial data. This process usually takes 30-60 seconds depending on your SSD’s I/O speed:

zcat /usr/share/zabbix-sql-scripts/mysql/server.sql.gz | mysql --default-character-set=utf8mb4 -uzabbix -p zabbix

Once complete, don’t forget to disable the function creation privilege to secure your system:

mysql -u root -p
set global log_bin_trust_function_creators = 0;
quit;

Step 3: Configure Zabbix Server

Now, we need to provide the database credentials to Zabbix Server. Open the configuration file:

vi /etc/zabbix/zabbix_server.conf

Locate the DBPassword= line and enter the password you created in the previous step. Other parameters like DBUser are set to zabbix by default, so no changes are needed.

Step 3: Install Nginx as the Web Server

Instead of a bulky Apache setup, I prefer Nginx to save RAM. Zabbix 7 provides a sample configuration file for Nginx; you just need to make a few adjustments:

vi /etc/nginx/conf.d/zabbix.conf

Uncomment the listen 80; line and change server_name to your IP address or domain. This tells Nginx exactly where to receive incoming requests.

Overcoming SELinux and Firewall Barriers

Many people choose to disable SELinux entirely. However, in a Production environment, this is a major security risk. Instead, grant specific permissions to Zabbix:

# Allow Nginx and Zabbix to connect to the internal network
setsebool -P httpd_can_network_connect 1
setsebool -P zabbix_can_network 1

# Open necessary service ports on the Firewall
firewall-cmd --permanent --add-service=http
firewall-cmd --permanent --add-port={10050,10051}/tcp
firewall-cmd --reload

Finally, restart all services to apply the changes:

# Open necessary <a href="https://itfromzero.com/en/centos-vi-en/mastering-nftables-on-centos-stream-9-replacing-iptables-for-optimized-firewall-performance.html">service ports on the Firewall</a>
systemctl restart zabbix-server zabbix-agent2 nginx php-fpm
systemctl enable zabbix-server zabbix-agent2 nginx php-fpm

Setting Up Automatic Email Alerts

To avoid staring at the dashboard all day, you need to configure SMTP. Access the web interface at http://your-ip (User: Admin / Pass: zabbix).

  1. Go to Alerts → Media types and select Email.
  2. Enter SMTP details (e.g., smtp.gmail.com, port 587).
  3. In the Users tab, add your personal email address to the Admin user to receive notifications when issues occur.

Why Use Zabbix Agent 2?

Zabbix Agent 2 is a significant leap forward, written entirely in Go. It supports parallel data collection (multi-threading), significantly reducing the load on the target server compared to the old version. If you are monitoring modern applications like Docker or Kubernetes, Agent 2 is a must.

Optimization Tips for Large Systems

  • DB User Management: Never use the root user for the Zabbix database.
  • PHP Tuning: For systems with over 100 nodes, increase memory_limit to 512M in the /etc/php-fpm.d/zabbix.conf file.
  • Use Templates: Zabbix 7 has a rich template library. Don’t waste time creating items manually when standard templates for Cisco, Windows, or Linux are already available.
  • Disk I/O Considerations: If the number of devices exceeds 500, consider using TimescaleDB to optimize historical data queries.

Mastering Zabbix 7 on CentOS Stream 9 gives you complete control over your infrastructure. From my experience, this system helps reduce passive troubleshooting time by up to 80%. If you encounter the “Zabbix server is not running” error, check the log file at /var/log/zabbix/zabbix_server.log immediately for a timely fix.

Share: