环境信息
- Rockylinux 9.6
- Mysql 8.4.7 LTS
- Zabbix 7.0 LTS
系统环境初始化
设置主机名称
hostnamectl hostname Zabbix-Server
关闭 selinux
[root@Zabbix-Server ~]# sed -ri 's#(SELINUX=).*#\1disabled#' /etc/selinux/config && setenforce 0
[root@Zabbix-Server ~]# getenforce
Permissive
添加官方 Zabbix 仓库
rpm -Uvh https://repo.zabbix.com/zabbix/7.0/rocky/9/x86_64/zabbix-release-latest-7.0.el9.noarch.rpm
[root@Zabbix-Server Zabbix]# rpm -Uvh zabbix-release-latest-7.0.el9.noarch.rpm
warning: zabbix-release-latest-7.0.el9.noarch.rpm: Header V4 RSA/SHA512 Signature, key ID b5333005: NOKEY
Verifying... ################################# [100%]
Preparing... ################################# [100%]
Updating / installing...
1:zabbix-release-7.0-5.el9 ################################# [100%]
安装 Zabbix Server 及相关组件
[root@Zabbix-Server Zabbix]# dnf install zabbix-server-mysql zabbix-web-mysql zabbix-nginx-conf zabbix-sql-scripts zabbix-selinux-policy zabbix-agent2
Zabbix Official Repository - x86_64 29 kB/s | 425 kB 00:14
Zabbix Official Repository (non-supported) - x86_64 616 B/s | 1.1 kB 00:01
Zabbix Official Repository (tools) - x86_64 1.1 kB/s | 2.2 kB 00:02
Dependencies resolved.
=====================================================================================================================================================
Package Architecture Version Repository Size
=====================================================================================================================================================
Installing:
zabbix-agent2 x86_64 7.0.21-release2.el9 zabbix 6.3 M
zabbix-nginx-conf noarch 7.0.21-release2.el9 zabbix 13 k
zabbix-selinux-policy x86_64 7.0.21-release2.el9 zabbix 307 k
zabbix-server-mysql x86_64 7.0.21-release2.el9 zabbix 2.3 M
zabbix-sql-scripts noarch 7.0.21-release2.el9 zabbix 7.9 M
zabbix-web-mysql
安装 Zabbix Agent 2 plugins
[root@Zabbix-Server ~]# dnf install zabbix-agent2-plugin-mongodb zabbix-agent2-plugin-mssql zabbix-agent2-plugin-postgresql
Last metadata expiration check: 0:01:53 ago on Tue Nov 10 17:37:15 2025.
Dependencies resolved.
===============================================================================================================================================================================
Package Architecture Version Repository Size
===============================================================================================================================================================================
Installing:
zabbix-agent2-plugin-mongodb x86_64 7.0.21-release1.el9 zabbix 3.7 M
zabbix-agent2-plugin-mssql x86_64 7.0.21-release1.el9 zabbix 2.6 M
zabbix-agent2-plugin-postgresql x86_64 7.0.21-release1.el9 zabbix 3.0 M
Transaction Summary
===============================================================================================================================================================================
Install 3 Packages
安装 MySQL 8.4.7-LTS
[root@Zabbix-Server ~]# tar xvf mysql-8.4.7-1.el9.x86_64.rpm-bundle.tar
[root@Zabbix-Server ~]# dnf install *.rpm
Last metadata expiration check: 1:59:58 ago on Mon 10 Nov 2025 08:23:59 PM CST.
Dependencies resolved.
=====================================================================================================================================================
Package Architecture Version Repository Size
=====================================================================================================================================================
Installing:
mysql-community-client x86_64 8.4.7-1.el9 @commandline 3.1 M
mysql-community-client-debuginfo x86_64 8.4.7-1.el9 @commandline 26 M
mysql-community-client-plugins x86_64 8.4.7-1.el9 @commandline 1.5 M
mysql-community-client-plugins-debuginfo x86_64 8.4.7-1.el9 @commandline 3.1 M
mysql-community-common x86_64 8.4.7-1.el9 @commandline 578 k
mysql-community-debuginfo x86_64 8.4.7-1.el9 @commandline 5.4 M
mysql-community-debugsource x86_64 8.4.7-1.el9 @commandline 17 M
mysql-community-devel x86_64 8.4.7-1.el9 @commandline 7.5 M
mysql-community-icu-data-files x86_64 8.4.7-1.el9 @commandline 2.3 M
mysql-community-libs x86_64 8.4.7-1.el9 @commandline 1.5 M
mysql-community-libs-compat x86_64 8.4.7-1.el9 @commandline 1.4 M
mysql-community-libs-compat-debuginfo x86_64 8.4.7-1.el9 @commandline 2.5 M
mysql-community-libs-debuginfo x86_64 8.4.7-1.el9 @commandline 2.7 M
mysql-community-server x86_64 8.4.7-1.el9 @commandline 50 M
启动 MySQL
[root@Zabbix-Server ~]# systemctl enable --now mysqld
[root@Zabbix-Server ~]# systemctl status mysqld.service
● mysqld.service - MySQL Server
Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; preset: disabled)
Active: active (running) since Mon 2025-11-10 22:52:03 CST; 4s ago
Docs: man:mysqld(8)
http://dev.mysql.com/doc/refman/en/using-systemd.html
Process: 60977 ExecStartPre=/usr/bin/mysqld_pre_systemd (code=exited, status=0/SUCCESS)
Main PID: 61079 (mysqld)
Status: "Server is operational"
Tasks: 46 (limit: 203760)
Memory: 444.5M
CPU: 4.895s
CGroup: /system.slice/mysqld.service
└─61079 /usr/sbin/mysqld
Nov 10 22:51:56 Zabbix-Server systemd[1]: Starting MySQL Server...
Nov 10 22:52:03 Zabbix-Server systemd[1]: Started MySQL Server.
修改 MySQL 初始密码
# 在MySQL日志中找到系统默认设置的密码
[root@Zabbix-Server ~]# cat /var/log/mysqld.log | grep password
2025-11-10T14:52:00.359511Z 6 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: 6douWKoqX4!<
# 使用默认的密码登录,修改MySQL root 用户密码
[root@Zabbix-Server ~]# mysql -uroot -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 8
Server version: 8.4.7
Copyright (c) 2000, 2025, Oracle and/or its affiliates.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql>
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'As%&a12BC,';
Query OK, 0 rows affected (0.02 sec)
mysql> exit
# 二次登录,验证新密码
[root@Zabbix-Server ~]# mysql -uroot -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 11
Server version: 8.4.7 MySQL Community Server - GPL
Copyright (c) 2000, 2025, Oracle and/or its affiliates.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql>
创建 Zabbix 初始数据库
[root@Zabbix-Server ~]# mysql -uroot -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 12
Server version: 8.4.7 MySQL Community Server - GPL
Copyright (c) 2000, 2025, Oracle and/or its affiliates.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql>
mysql> create database zabbix character set utf8mb4 collate utf8mb4_bin;
Query OK, 1 row affected (0.00 sec)
mysql> create user zabbix@localhost identified by 'As%&a12BC,';
Query OK, 0 rows affected (0.01 sec)
mysql> grant all privileges on zabbix.* to zabbix@localhost;
Query OK, 0 rows affected (0.00 sec)
mysql> set global log_bin_trust_function_creators = 1;
Query OK, 0 rows affected, 1 warning (0.00 sec)
mysql> quit
在前面 Zabbix 安装步骤中,会生成 Zabbix 数据库基础数据,我们直接导入 MySQL 数据即可
[root@Zabbix-Server ~]# ll /usr/share/zabbix-sql-scripts/mysql/server.sql.gz
-rw-r--r--. 1 root root 4154743 Nov 4 03:04 /usr/share/zabbix-sql-scripts/mysql/server.sql.gz
[root@Zabbix-Server ~]# zcat /usr/share/zabbix-sql-scripts/mysql/server.sql.gz | mysql --default-character-set=utf8mb4 -uzabbix -p zabbix
Enter password:
# 通过 zcat 输出 sql 文件内容,通过管道符传递给 MySQL 作为 sql 语句执行数据导入
# 执行完成后,我们查验下数据是否生成
[root@Zabbix-Server ~]# mysql -uroot -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 15
Server version: 8.4.7 MySQL Community Server - GPL
Copyright (c) 2000, 2025, Oracle and/or its affiliates.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| sys |
| zabbix |
+--------------------+
5 rows in set (0.03 sec)
mysql> use zabbix;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
mysql> show tables;
+----------------------------+
| Tables_in_zabbix |
+----------------------------+
| acknowledges |
| actions |
| alerts |
| auditlog |
| autoreg_host |
| changelog |
| conditions |
| config |
| config_autoreg_tls |
| connector |
数据库初始化完成后,恢复严格模式
mysql> set global log_bin_trust_function_creators = 0;
Query OK, 0 rows affected, 1 warning (0.00 sec)
解释一下这里为什么要调整 log_bin_trust_function_creators 这个全局系统变量的值,其值为布尔型(0或1),作用解释如下:
当值为 0(默认值)时:
- 严格模式 : MySQL会对存储函数和触发器的创建进行严格检查
- 要求函数确定性 : 创建的存储函数必须声明为
DETERMINISTIC、NO SQL或READS SQL DATA - 安全限制 : 防止可能影响主从复制一致性的非确定性函数
当值为 1 时:
- 宽松模式 : 允许创建任何类型的存储函数,不进行严格检查
- 信任开发者 : 假设函数创建者会确保函数的确定性
修改的主要原因:Zabbix使用存储过程和函数
Zabbix数据库包含大量的 存储过程、函数和触发器 ,且某些函数可能没有明确被声明为:DETERMINISTIC ,包含 MODIFIES SQL DATA 的操作,这些数据库对象:
- 用于数据处理和聚合
- 实现复杂的监控逻辑
- 进行性能优化
【MySQL官方文档】:Stored Program Binary Logging
配置 Zabbix Server 数据库
编辑 /etc/zabbix/zabbix_server.conf ,设置数据库密码
123 DBUser=zabbix
124
125 ### Option: DBPassword
126 # Database password.
127 # Comment this line if no password is used.
128 #
129 # Mandatory: no
130 # Default:
131 DBPassword=As%&a12BC,
启动 Zabbix Server 和 agent 进程
[root@Zabbix-Server ~]# systemctl enable --now zabbix-server zabbix-agent2 nginx php-fpm
Created symlink /etc/systemd/system/multi-user.target.wants/zabbix-server.service → /usr/lib/systemd/system/zabbix-server.service.
Created symlink /etc/systemd/system/multi-user.target.wants/zabbix-agent2.service → /usr/lib/systemd/system/zabbix-agent2.service.
Created symlink /etc/systemd/system/multi-user.target.wants/nginx.service → /usr/lib/systemd/system/nginx.service.
Created symlink /etc/systemd/system/multi-user.target.wants/php-fpm.service → /usr/lib/systemd/system/php-fpm.service.
[root@Zabbix-Server ~]#
[root@Zabbix-Server ~]# systemctl status zabbix-server.service
● zabbix-server.service - Zabbix Server
Loaded: loaded (/usr/lib/systemd/system/zabbix-server.service; enabled; preset: disabled)
Active: active (running) since Tue 2025-11-11 11:20:06 CST; 1min 7s ago
Process: 94291 ExecStart=/usr/sbin/zabbix_server -c $CONFFILE (code=exited, status=0/SUCCESS)
Main PID: 94331 (zabbix_server)
Tasks: 77 (limit: 203760)
Memory: 86.9M
CPU: 698ms
CGroup: /system.slice/zabbix-server.service
├─94331 /usr/sbin/zabbix_server -c /etc/zabbix/zabbix_server.conf
├─94332 "/usr/sbin/zabbix_server: ha manager"
├─94333 "/usr/sbin/zabbix_server: service manager #1 [processed 0 events, updated 0 event tags, deleted 0 problems, synced 0 service updates, >
├─94334 "/usr/sbin/zabbix_server: configuration syncer [synced configuration in 0.032490 sec, idle 10 sec]"
├─94346 "/usr/sbin/zabbix_server: alert manager #1 [sent 0, failed 0 alerts, idle 5.007155 sec during 5.007375 sec]"
├─94347 "/usr/sbin/zabbix_server: alerter #1 started"
├─94348 "/usr/sbin/zabbix_server: alerter #2 started"
初始化 Zabbix Server 配置
添加防火墙规则
[root@Zabbix-Server ~]# firewall-cmd --add-service=https --add-service=http --permanent
success
[root@Zabbix-Server ~]# firewall-cmd --add-port={10050,10051}/tcp --permanent
success
[root@Zabbix-Server ~]# firewall-cmd --permanent --add-port={161,162}/udp
success
[root@Zabbix-Server ~]# firewall-cmd --reload
success
添加中文支持语言包
# 安装中文语言包
[root@Zabbix-Server ~]# dnf install langpacks-zh_CN.noarch
Last metadata expiration check: 0:20:12 ago on Tue Nov 11 15:23:33 2025.
Dependencies resolved.
===================================================================================================================================================
Package Architecture Version Repository Size
===================================================================================================================================================
Installing:
langpacks-zh_CN noarch 3.0-16.el9 appstream 9.6 k
Installing dependencies:
google-noto-cjk-fonts-common noarch 20230817-2.el9 appstream 11 k
google-noto-sans-cjk-ttc-fonts noarch 20230817-2.el9 appstream 81 M
langpacks-core-font-zh_CN noarch 3.0-16.el9 appstream 9.7 k
langpacks-core-zh_CN noarch 3.0-16.el9 appstream 9.6 k
Installing weak dependencies:
google-noto-serif-cjk-ttc-fonts noarch 20230817-2.el9 appstream 116 M
# 安装 glibc-common
[root@Zabbix-Server ~]# dnf install glibc-common
Last metadata expiration check: 0:22:36 ago on Tue Nov 11 15:23:33 2025.
Package glibc-common-2.34-168.el9_6.14.x86_64 is already installed.
Dependencies resolved.
===================================================================================================================================================
Package Architecture Version Repository Size
===================================================================================================================================================
Upgrading:
glibc x86_64 2.34-168.el9_6.24 baseos 1.9 M
glibc-common x86_64 2.34-168.el9_6.24 baseos 293 k
glibc-gconv-extra x86_64 2.34-168.el9_6.24 baseos 1.5 M
glibc-langpack-en x86_64 2.34-168.el9_6.24 baseos 550 k
Installing weak dependencies:
glibc-langpack-zh x86_64 2.34-168.el9_6.24 baseos 2.1 M
# 验证中文支持
[root@Zabbix-Server ~]# locale -a | grep zh_CN
zh_CN
zh_CN.gb18030
zh_CN.gbk
zh_CN.utf8
# 处理主机仪表盘显示异常问题
# 1. Windows 机器上复制一个你喜欢的字体(C:\Windows\Fonts)上传到服务器:/usr/share/zabbix/assets/fonts
# 2. 编辑 vim /usr/share/zabbix/include/defines.inc.php 文件,将字体名称修改为你上传的字体名字,然后刷新页面即可
define('ZBX_GRAPH_FONT_NAME', 'simkai'); // font file name
登录 Zabbix 界面
在用户配置处修改语言为:简体中文(zh_CN),接下来就慢慢享用吧
参考文献

要想成为扫地僧,需要不断的学习进步,这个世界,在悄悄惩罚那些不改变的人