Rocky Linux 手把手部署 Zabbix 7.4 监控系统完整教程

Rocky Linux10.2 对应 RHEL10,Zabbix7.4 官方提供 Rocky10 的 rpm 包,推荐使用 Agent2,数据库 MariaDB,PHP8.2,Web 选用 Nginx。

环境说明:单服务器部署,所有组件同机;root 用户执行;系统为 Rocky Linux 10.2 x86_64。

一、系统初始化

1. 更新系统

dnf update -y

image

关闭 SELinux(生产可配置策略,测试直接关闭)

setenforce 0
sed -i 's/^SELINUX=enforcing/SELINUX=permissive/' /etc/selinux/config

image

防火墙放行端口(80/TCP、10051/TCP、10050/TCP)

# 放行http网页端口
firewall-cmd --add-service=http --permanent
# zabbix-server端口
firewall-cmd --add-port=10051/tcp --permanent
# zabbix-agent端口
firewall-cmd --add-port=10050/tcp --permanent
firewall-cmd --reload

image

安装 MariaDB 数据库

dnf install mariadb-server mariadb -y
# 启动开机自启
systemctl enable --now mariadb
# 数据库安全初始化(设置root密码,删除匿名用户,禁止root远程)
mysql_secure_installation

imageimage

创建 Zabbix 数据库与账号

mysql -uroot -p

image

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

先清理缓存,安装全套 Zabbix7.4 组件

dnf clean all
dnf install zabbix-server-mysql zabbix-web-mysql zabbix-nginx-conf zabbix-sql-scripts zabbix-selinux-policy zabbix-agent2 -y

image

安装完成后验证包

rpm -qa | grep zabbix

image正常会列出一堆包:zabbix-server-mysql、zabbix-sql-scripts、zabbix-agent2……

✅ 所有 Zabbix 7.4 包全部安装成功! 现在可以去找 SQL 脚本文件了:

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

image✅ 导入成功! 没有报错,直接返回 root 提示符,代表 Zabbix 初始化表已经全部写入 zabbix 数据库。

关闭数据库参数 log_bin_trust_function_creators

mysql -uroot -p

image

SET GLOBAL log_bin_trust_function_creators = 0;
quit;

image

配置 zabbix_server.conf 数据库密码

vi /etc/zabbix/zabbix_server.conf

image

  • ### Option: DBPassword = 【说明文字,删掉】
  • # DBPassword= = 被注释的配置行,只删掉行首的 #,保留 DBPassword=

操作步骤:

  1. 删掉 Option: 这几个字符
  2. 只保留:DBPassword=Zabbix@Passw0rd
  3. DBUser=zabbix
    DBPassword=Zabbix@Passw0rd

保存(ESC 然后 :wq)

重启 zabbix-server 查看状态

systemctl restart zabbix-server
systemctl status zabbix-server

imagezabbix-server 成功启动,active (running)

把其他服务一并启动并设置开机自启

systemctl enable --now zabbix-agent2 nginx php-fpm

image

服务开机自启链接创建完成

现在查看这三个服务运行状态:

systemctl status zabbix-agent2 nginx php-fpm

image目标:三个服务全部显示 active (running)

测试 nginx 页面能不能本地访问

curl http://127.0.0.1

imageimageimageimage

安装完成登录信息

  • 用户名:Admin(A 大写)
  • 密码:zabbix(全小写)

登录进去第一件事,去用户设置里修改 Admin 默认密码,提升安全性!

posted @ 2026-10-15 22:53  九幽提刑官  阅读(9)  评论(0)    收藏  举报