Fixing Slow Zabbix DB: Practical MySQL Partition Setup (Part 1)

Ready to streamline your complex Zabbix operations?

I’ve distilled the most valuable insights from this blog into one essential guide. Take full control of your environment with the Zabbix 7 Enterprise Optimization Handbook [Mastering Hybrid Infrastructure Monitoring with a Kubernetes First Approach].

👉 Get your PDF copy here: https://jikimy.gumroad.com/l/zabbixmaster


— Installing Zabbix 7.4 and Loading the Schema (History / Trends Partition Prep)


This guide explains how to install Zabbix 7.4 on Ubuntu 22.04 and prepare its MySQL schema for partitioning.
It’s a continuation of the practical performance-tuning series below:


1) Scope and Prerequisites

ComponentVersion / Note
OSUbuntu 22.04
Zabbix7.4 (Use 7.0 LTS if EOL support matters for compliance)
DBMySQL 8.x
WebApache + zabbix-frontend-php
GoalUp to schema import — partitioning starts in Part 2

⚠️ If your environment requires long-term security certification or audits, avoid short-lifecycle releases.
Stick to 7.0 LTS in EOL-sensitive organizations.


2) Add Zabbix Repository

- Repository setup
# wget https://repo.zabbix.com/zabbix/7.4/release/ubuntu/pool/main/z/zabbix-release/zabbix-release_latest_7.4+ubuntu22.04_all.deb
# dpkg -i zabbix-release_latest_7.4+ubuntu22.04_all.deb
# apt update

Checkpoint

  • /etc/apt/sources.list.d/zabbix.list should exist.
  • apt update must download indexes from repo.zabbix.com.

3) Install Zabbix Server, Frontend and Agent 2

- Zabbix server / frontend / agent2
# apt install -y zabbix-server-mysql zabbix-frontend-php zabbix-apache-conf zabbix-sql-scripts zabbix-agent2

- Optional Agent 2 plugins (install only what you need)
# apt install -y zabbix-agent2-plugin-mongodb zabbix-agent2-plugin-mssql zabbix-agent2-plugin-postgresql

Checkpoint

  • Config files appear under /etc/zabbix/ (notably zabbix_server.conf).
  • Apache module and zabbix.conf symlink under /etc/apache2/conf-enabled/.

4) Install MySQL

# apt install -y mysql-server

Checkpoint

  • systemctl status mysql → should be active (running)
  • Ubuntu 22.04 may enable auth_socket authentication:
    only the OS root user can log in as MySQL root.

5) Initialize the Database (User / Privileges / Function Trust)

mysql -uroot -p
# (enter password)  : The initial root password is not set.
Just press Enter without typing anything.

# Create DB, user, and privileges
mysql> create database zabbix character set utf8mb4 collate utf8mb4_bin;
mysql> create user zabbix@localhost identified by 'password';         # replace with real password
mysql> grant all privileges on zabbix.* to zabbix@localhost;
mysql> GRANT FILE ON *.* TO 'zabbix'@'localhost';
       => Grant privileges for partitioning

# Note: The partition automation script connects via TCP (127.0.0.1), so you must also create a 'zabbix'@'127.0.0.1' account with the same privileges.


# Temporarily allow stored functions
mysql>set global log_bin_trust_function_creators = 1;
quit;

🧩 Explanation

log_bin_trust_function_creators=1 must be enabled temporarily.

Zabbix’s schema contains several stored functions (e.g., get_host_agent()),
and when binary logging is active, a non-SUPER user cannot create functions by default.
Turning this flag on lets the import succeed.


6) Import Zabbix Schema

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

7) Restore Function Trust Setting

mysql -uroot -p
# (enter password)
mysql>set global log_bin_trust_function_creators = 0;
quit;

🔐 Security Note

The trust flag should only be enabled during schema creation.
Always revert it afterward.


8) Register DB Credentials in Zabbix Server

# vi /etc/zabbix/zabbix_server.conf

Uncomment and set:

DBName=zabbix
DBUser=zabbix
DBPassword=your_actual_password

9) Start Services

# systemctl restart zabbix-server zabbix-agent2 apache2
# systemctl enable zabbix-server zabbix-agent2 apache2

Checkpoint

  • systemctl status zabbix-server → active (running)
  • Access web UI: http://<server_ip>/zabbix

⏱ Time-zone handling:
Zabbix UI (PHP) uses your local zone (KST etc.) for display,
but database partitions use UTC epoch internally.
The time-zone difference affects display only, not data retention or partition boundaries.


10) Next Parts Preview

PartTopic
2Disk separation (AppArmor, permissions, innodb_directories) + General Tablespace setup
3file-per-table conversion + initial partitions (history = daily/epoch, trends = monthly)
4Automation scripts + cron scheduling + retention (DAYS_KEEP / MONTHS_KEEP)
5Disable Housekeeper + Zabbix cache / process tuning + MySQL InnoDB optimization

Troubleshooting Checklist

SymptomWhat to Check
Schema import failsConfirm log_bin_trust_function_creators = 1, then re-import
Login errorVerify DB user/password, and mysql_native_password vs auth_socket auth method
Service startup failsInspect /var/log/zabbix/zabbix_server.log and /var/log/apache2/error.log

End of Part 1 — Next:
Partition data directories, AppArmor rules, and tablespace configuration (Part 2).

🛠 마지막 수정일: 2025.12.12

ⓒ 2025 엉뚱한 녀석의 블로그 [quirky guy's Blog]. 본문 및 이미지를 무단 복제·배포할 수 없습니다. 공유 시 반드시 원문 링크를 명시해 주세요.
ⓒ 2025 엉뚱한 녀석의 블로그 [quirky guy's Blog]. All rights reserved. Unauthorized copying or redistribution of the text and images is prohibited. When sharing, please include the original source link.

💡 도움이 필요하신가요?
Zabbix, Kubernetes, 그리고 다양한 오픈소스 인프라 환경에 대한 구축, 운영, 최적화, 장애 분석, 광고 및 협업 제안이 필요하다면 언제든 편하게 연락 주세요.

📧 Contact: jikimy75@gmail.com
💼 Service: 구축 대행 | 성능 튜닝 | 장애 분석 컨설팅

📖 E-BooK [PDF] 전자책 (Gumroad): Zabbix 엔터프라이즈 최적화 핸드북
블로그에서 다룬 Zabbix 관련 글들을 기반으로 실무 중심의 지침서로 재구성했습니다. 운영 환경에서 바로 적용할 수 있는 최적화·트러블슈팅 노하우까지 모두 포함되어 있습니다.


💡 Need Professional Support?
If you need deployment, optimization, or troubleshooting support for Zabbix, Kubernetes, or any other open-source infrastructure in your production environment, or if you are interested in sponsorships, ads, or technical collaboration, feel free to contact me anytime.

📧 Email: jikimy75@gmail.com
💼 Services: Deployment Support | Performance Tuning | Incident Analysis Consulting

📖 PDF eBook (Gumroad): Zabbix Enterprise Optimization Handbook
A single, production-ready PDF that compiles my in-depth Zabbix and Kubernetes monitoring guides.