CentOSRHEL Based

How To Install Zabbix on CentOS Stream 10

Install Zabbix on CentOS Stream 10

In this tutorial, we will show you how to install Zabbix on CentOS Stream 10. Zabbix stands as one of the most powerful open-source monitoring solutions available for tracking the status of network services, servers, and infrastructure components. With its robust capabilities for monitoring, alerting, and visualization, Zabbix provides system administrators with comprehensive infrastructure oversight. This guide walks you through installing Zabbix 7.0 LTS on CentOS Stream 10, creating a solid foundation for enterprise-level monitoring.

Prerequisites

Before beginning the Zabbix installation process, ensure your system meets all necessary requirements. Proper preparation prevents complications and ensures optimal monitoring performance.

Hardware Requirements

The hardware needed for Zabbix varies based on your environment’s size and complexity. Consider these specifications:

  • CPU: Minimum 2 cores for small environments; 4+ cores recommended for medium to large deployments
  • RAM: 2GB minimum for small installations; 8GB or more recommended for environments monitoring 1000+ devices
  • Disk Space: 50GB minimum free space for the database (SSD storage highly recommended)
  • Network: Stable network connection with adequate bandwidth to communicate with all monitored hosts

For testing environments or minimal deployments (under 100 monitored items), you can run with more modest specifications, though performance may suffer.

Software Requirements

Your CentOS Stream 10 system should have:

  • CentOS Stream 10: A fresh, fully updated installation
  • Database: One of the following:
    • MySQL 8.0+
    • MariaDB 10.5+
    • PostgreSQL 13.0+ (optional alternative)
  • Web Server: Apache 2.4+
  • PHP: Version 8.1+ with these extensions:
    • php-mysql or php-pgsql
    • php-gd
    • php-bcmath
    • php-ctype
    • php-xmlreader
    • php-xmlwriter
    • php-session
    • php-mbstring
    • php-gettext
    • php-ldap (if using LDAP authentication)

Verify your CentOS Stream 10 version:

cat /etc/centos-release

Understanding Zabbix Architecture

A solid understanding of Zabbix’s architecture helps make informed decisions during installation and configuration.

Core Components

Zabbix consists of several integrated components:

  • Zabbix Server: The central processing unit that performs monitoring, triggering, and alerting, storing all configuration and operational data
  • Zabbix Database: Stores configuration information and collected monitoring data
  • Zabbix Web Interface: PHP-based frontend providing user-friendly configuration and data visualization
  • Zabbix Agent: Lightweight software deployed on monitored hosts to collect local resource and application data
  • Zabbix Proxy (optional): Distributes monitoring load and collects data on behalf of the Zabbix server

Communication Flow

Understanding component communication is crucial for proper firewall configuration:

  • Zabbix Server communicates with agents on port 10050 (default)
  • Agents connect to server port 10051 in active check mode
  • Web interface communicates with the server through the database
  • Server connects to database using standard ports (MySQL: 3306, PostgreSQL: 5432)
  • Users access web interface via HTTP (80) or HTTPS (443)

This explains why specific ports must be opened in your firewall configuration.

Pre-Installation Setup

Proper system preparation ensures smooth Zabbix installation on CentOS Stream 10.

System Updates

First, update your CentOS Stream 10 system:

sudo dnf update -y

This ensures all packages are current, enhancing compatibility and security.

SELinux Configuration

SELinux can interfere with Zabbix operation. Set it to permissive mode temporarily:

sudo setenforce 0

For persistence across reboots, edit the SELinux configuration:

sudo nano /etc/selinux/config

Change the SELINUX=enforcing line to:

SELINUX=permissive

We’ll address proper SELinux configuration for production environments later.

Firewall Configuration

Configure firewall rules to allow Zabbix communication:

sudo firewall-cmd --permanent --add-port=10050/tcp sudo firewall-cmd --permanent --add-port=10051/tcp sudo firewall-cmd --permanent --add-port=80/tcp sudo firewall-cmd --permanent --add-port=443/tcp sudo firewall-cmd --reload

Verify open ports:

sudo firewall-cmd --list-ports

These ports enable core Zabbix functionality across your network.

Database Installation and Configuration

Zabbix requires a database to store configuration and monitoring data. MariaDB works exceptionally well with CentOS Stream 10.

MySQL/MariaDB Installation

Install and start MariaDB:

sudo dnf install -y mariadb-server
sudo systemctl start mariadb
sudo systemctl enable mariadb

Secure your MariaDB installation:

sudo mysql_secure_installation

Follow the prompts to set a root password, remove anonymous users, disallow remote root login, remove the test database, and reload privileges.

Create a database and user for Zabbix:

sudo mysql -u root -p

Enter your MariaDB root password, then execute:

CREATE DATABASE zabbix character set utf8mb4 collate utf8mb4_bin;
CREATE USER 'zabbix'@'localhost' IDENTIFIED BY 'secure_password';
GRANT ALL PRIVILEGES ON zabbix.* TO 'zabbix'@'localhost';
FLUSH PRIVILEGES; EXIT;

Replace secure_password with a strong password.

PostgreSQL Alternative

If you prefer PostgreSQL:

sudo dnf install -y postgresql-server postgresql-contrib
sudo postgresql-setup --initdb
sudo systemctl start postgresql
sudo systemctl enable postgresql

Configure PostgreSQL authentication:

sudo nano /var/lib/pgsql/data/pg_hba.conf

Find lines containing:

host all all 127.0.0.1/32 ident host all all ::1/128 ident

Change ident to md5, then create the database and user:

sudo -u postgres psql

Execute:

CREATE DATABASE zabbix;
CREATE USER zabbix WITH PASSWORD 'secure_password';
GRANT ALL PRIVILEGES ON DATABASE zabbix TO zabbix;
\q

TimescaleDB Option

For high-volume environments, TimescaleDB significantly improves performance when used with PostgreSQL:

sudo dnf install -y https://download.postgresql.org/pub/repos/yum/reporpms/EL-8-x86_64/pgdg-redhat-repo-latest.noarch.rpm
sudo dnf -qy module disable postgresql
sudo dnf install -y timescaledb-postgresql-13

Edit PostgreSQL configuration:

sudo nano /var/lib/pgsql/13/data/postgresql.conf

Add this line:

shared_preload_libraries = 'timescaledb'

Restart PostgreSQL:

sudo systemctl restart postgresql-13

TimescaleDB excels at managing historical monitoring data for long-term storage and analysis.

Installing Zabbix Repository

Adding the official Zabbix repository ensures you receive properly packaged components.

Adding Official Zabbix Repository

Add the Zabbix repository for CentOS Stream 10:

sudo rpm -Uvh https://repo.zabbix.com/zabbix/7.2/release/centos/10/noarch/zabbix-release-latest-7.2.el10.noarch.rpm
sudo dnf clean all

Verify the repository was added successfully:

sudo dnf repolist | grep zabbix

This command should display available Zabbix repositories.

Installing Zabbix Components

With the repository configured, install the Zabbix server, frontend, and agent components.

Installing Zabbix Server

Install the Zabbix server with MySQL/MariaDB support:

sudo dnf install -y zabbix-server-mysql

For PostgreSQL:

sudo dnf install -y zabbix-server-pgsql

Installing Zabbix Frontend

Install the web frontend and dependencies:

sudo dnf install -y zabbix-web-mysql zabbix-apache-conf

For PostgreSQL:

sudo dnf install -y zabbix-web-pgsql zabbix-apache-conf

These packages include necessary PHP modules and Apache configuration.

Installing Zabbix Agent

Install the Zabbix agent on your server:

sudo dnf install -y zabbix-agent

The agent allows the Zabbix server to monitor itself, following monitoring best practices.

Database Schema Configuration

After component installation, populate the database with Zabbix schema and initial data.

Initializing the Database

Import the initial schema into MariaDB:

sudo zcat /usr/share/zabbix-sql-scripts/mysql/server.sql.gz | sudo mysql -u zabbix -p zabbix

Enter the password you created for the zabbix user when prompted.

For PostgreSQL:

sudo zcat /usr/share/zabbix-sql-scripts/postgresql/server.sql.gz | sudo -u postgres psql zabbix

This process may take several minutes depending on system performance.

Database Optimization

For improved performance, adjust MariaDB parameters:

sudo nano /etc/my.cnf.d/mariadb-server.cnf

Add or modify these parameters in the [mysqld] section:

innodb_buffer_pool_size = 1G innodb_log_file_size = 256M innodb_flush_method = O_DIRECT max_connections = 1000

Adjust these values based on available memory and expected load. Restart MariaDB:

sudo systemctl restart mariadb

For PostgreSQL, edit /var/lib/pgsql/data/postgresql.conf and adjust shared_buffers, work_mem, and maintenance_work_mem according to server resources.

Configuring Zabbix Server

With the database prepared, configure the Zabbix server for operation.

Editing Server Configuration File

Edit the Zabbix server configuration:

sudo nano /etc/zabbix/zabbix_server.conf

Update these parameters:

DBHost=localhost DBName=zabbix DBUser=zabbix DBPassword=secure_password

Replace secure_password with your actual password.

Consider adjusting these performance parameters:

StartPollers=5 StartPingers=1 StartDiscoverers=1 CacheSize=64M HistoryCacheSize=16M TrendCacheSize=4M

These values are starting points and should be adjusted based on your environment size and available resources.

Setting up Logging

Configure logging settings in the same configuration file:

LogFile=/var/log/zabbix/zabbix_server.log LogFileSize=0 DebugLevel=3

The LogFileSize=0 setting disables automatic log rotation, assuming logrotate management. DebugLevel=3 provides warning messages, balancing information and log size.

Create a logrotate configuration:

sudo nano /etc/logrotate.d/zabbix-server

Add:

/var/log/zabbix/zabbix_server.log { weekly rotate 12 compress delaycompress missingok notifempty create 0640 zabbix zabbix }

This ensures proper log rotation and management for long-term operation.

Configuring Web Frontend

Next, configure Apache and PHP for the Zabbix web interface.

Apache Configuration

Review the Apache configuration file provided by the Zabbix package:

sudo nano /etc/httpd/conf.d/zabbix.conf

By default, this sets up the Zabbix frontend at http://your-server/zabbix. Modify if you want Zabbix at the root URL.

PHP Configuration

Configure PHP settings for optimal Zabbix performance:

sudo nano /etc/php.ini

Adjust these parameters:

max_execution_time = 300 memory_limit = 256M post_max_size = 32M upload_max_filesize = 16M max_input_time = 300 date.timezone = America/New_York

Replace America/New_York with your actual timezone. Restart Apache:

sudo systemctl restart httpd

Web Installation Wizard

Complete installation through the web interface. Navigate to:

http://your-server-ip/zabbix

Follow the installation wizard steps:

  1. Welcome: Click “Next step”
  2. Check pre-requisites: Verify all requirements are met
  3. Configure DB connection: Enter database details
  4. Zabbix server details: Enter server name and timezone
  5. Pre-installation summary: Review settings
  6. Install: Click “Finish”

Install Zabbix on CentOS Stream 10

After installation completes, you’ll reach the login page. Default credentials:

  • Username: Admin
  • Password: zabbix

Change the default password immediately upon first login for security.

Starting and Enabling Services

Start the Zabbix services and configure them to launch automatically at boot.

Starting Zabbix Services

Start Zabbix server, agent, and Apache:

sudo systemctl start zabbix-server
sudo systemctl start zabbix-agent
sudo systemctl start httpd

Verify services are running correctly:

sudo systemctl status zabbix-server
sudo systemctl status zabbix-agent
sudo systemctl status httpd

If any service fails to start, check the logs:

  • Zabbix server: /var/log/zabbix/zabbix_server.log
  • Zabbix agent: /var/log/zabbix/zabbix_agent.log
  • Apache: /var/log/httpd/error_log

Enabling Services for Boot

Configure services to start automatically at system boot:

sudo systemctl enable zabbix-server
sudo systemctl enable zabbix-agent
sudo systemctl enable httpd 
udo systemctl enable mariadb

For PostgreSQL users:

sudo systemctl enable postgresql

This ensures continuous monitoring without manual intervention after server reboots.

Post-Installation Verification

Verify all components are functioning correctly after installation.

Testing Server Connectivity

Confirm the Zabbix server is listening on its ports:

sudo ss -tulpn | grep zabbix

You should see the server listening on port 10051 and the agent on port 10050.

Test agent connectivity:

sudo zabbix_get -s 127.0.0.1 -p 10050 -k "system.hostname"

This should return your server’s hostname, confirming the agent responds to requests.

Accessing the Web Interface

Open your web browser and navigate to:

http://your-server-ip/zabbix

Log in with your credentials and explore the dashboard to verify functionality.

Verifying Database Connection

Check server-database connectivity by examining the server log:

sudo tail -f /var/log/zabbix/zabbix_server.log

Look for database connectivity errors. A properly functioning installation should show no critical errors.

Performance Optimization

For optimal performance, especially in larger environments, consider these recommendations.

Zabbix Server Tuning

Fine-tune the Zabbix server by editing:

sudo nano /etc/zabbix/zabbix_server.conf

Adjust these parameters based on server resources:

StartPollers=10 StartPreprocessors=3 StartPollersUnreachable=5 StartPingers=5 StartDiscoverers=3 StartHTTPPollers=2 CacheSize=128M HistoryCacheSize=32M TrendCacheSize=8M ValueCacheSize=64M

These values suit medium environments monitoring 500-1000 hosts. For larger deployments, increase values proportionally and ensure adequate RAM.

Database Optimization

Implement database maintenance for long-term performance:

Create a maintenance script for MySQL/MariaDB:

sudo nano /usr/local/bin/zabbix_db_maintenance.sh

Add:

#!/bin/bash MYSQL_PWD="your_password" mysql -u zabbix -D zabbix -e " DELETE FROM history WHERE clock < UNIX_TIMESTAMP(NOW() - INTERVAL 30 DAY); DELETE FROM history_uint WHERE clock < UNIX_TIMESTAMP(NOW() - INTERVAL 30 DAY); DELETE FROM history_str WHERE clock < UNIX_TIMESTAMP(NOW() - INTERVAL 30 DAY); DELETE FROM history_text WHERE clock < UNIX_TIMESTAMP(NOW() - INTERVAL 30 DAY); DELETE FROM history_log WHERE clock < UNIX_TIMESTAMP(NOW() - INTERVAL 30 DAY); OPTIMIZE TABLE history, history_uint, history_str, history_text, history_log; "

Make executable:

sudo chmod +x /usr/local/bin/zabbix_db_maintenance.sh

Schedule weekly execution:

sudo crontab -e

Add:

0 1 * * 0 /usr/local/bin/zabbix_db_maintenance.sh > /dev/null 2>&1

This script manages database growth by removing old data and optimizing tables, critical for long-term performance.

Troubleshooting Common Issues

Even with careful installation, issues may arise. Here are solutions to common problems.

Service Startup Problems

If Zabbix server fails to start, check logs:

sudo tail -f /var/log/zabbix/zabbix_server.log

Common issues include:

  1. Database connection problems: Verify database credentials in zabbix_server.conf and confirm database server operation.
  2. Insufficient permissions: Check zabbix user database permissions:
    sudo mysql -u root -p -e "SHOW GRANTS FOR 'zabbix'@'localhost';"
  3. SELinux blocking: If you’ve re-enabled SELinux, check audit logs:
    sudo ausearch -m avc -ts recent

    SELinux issues may require custom policies or temporarily switching to permissive mode for troubleshooting.

Database Connection Issues

If server can’t connect to database, verify:

  1. Database server is running:
    sudo systemctl status mariadb
  2. Zabbix user can authenticate:
    mysql -u zabbix -p -e "SELECT 1;"
  3. Database exists with proper schema:
    mysql -u zabbix -p -e "SHOW TABLES FROM zabbix;"

Revisit database creation and schema import if issues arise.

Web Interface Access Problems

If the web interface is inaccessible, check:

  1. Apache service status:
    sudo systemctl status httpd
  2. Apache error logs:
    sudo tail -f /var/log/httpd/error_log
  3. PHP configuration:
    php -i | grep -E '(date.timezone|memory_limit|max_execution_time)'
  4. Firewall allowing connections:
    sudo firewall-cmd --list-ports

Addressing these common issues should resolve most installation problems.

Congratulations! You have successfully installed Zabbix. Thanks for using this tutorial for installing the Zabbix open-source monitoring software on your CentOS Stream 10 system. For additional or useful information, we recommend you check the official Zabbix website.

VPS Manage Service Offer
If you don’t have time to do all of this stuff, or if this is not your area of expertise, we offer a service to do “VPS Manage Service Offer”, starting from $10 (Paypal payment). Please contact us to get the best deal!

r00t

r00t is an experienced Linux enthusiast and technical writer with a passion for open-source software. With years of hands-on experience in various Linux distributions, r00t has developed a deep understanding of the Linux ecosystem and its powerful tools. He holds certifications in SCE and has contributed to several open-source projects. r00t is dedicated to sharing her knowledge and expertise through well-researched and informative articles, helping others navigate the world of Linux with confidence.
Back to top button