当前位置: 首页 > news >正文

Zabbix企业级分布式监控系统(上)

Zabbix企业级分布式监控系统

概念

Zabbix 是一款开源的企业级分布式监控系统,专注于对 IT 基础设施(服务器、网络设备、云资源、应用程序等)的全面监控、告警和可视化,广泛应用于企业运维、云平台管理等场景。其核心优势在于功能全面、可扩展性强、支持多平台,且完全开源免费。

Zabbix 核心功能

  1. 全方位监控能力
    • 硬件监控:CPU、内存、磁盘、网卡等服务器硬件指标。
    • 系统监控:Linux、Windows、AIX 等操作系统的进程、负载、文件系统、服务状态等。
    • 网络监控:通过 SNMP、ICMP、TCP/UDP 等协议监控交换机、路由器、防火墙的带宽、端口状态、丢包率等。
    • 应用监控:支持 MySQL、Nginx、Java(JMX)、Docker、Kubernetes 等主流应用 / 容器,可监控连接数、响应时间、错误率等业务指标。
    • 自定义监控:通过脚本(Shell、Python 等)、API 接口采集业务数据(如订单量、用户在线数),灵活适配个性化需求。
  2. 智能告警机制
    • 基于阈值触发告警(如 CPU 使用率 > 90%、服务宕机),支持多级别告警(信息、警告、严重、灾难)。
    • 丰富的告警媒介:邮件、短信、企业微信、钉钉、Slack、Webhook 等,可自定义告警内容和接收对象。
    • 告警升级与抑制:未及时处理的告警自动通知上级;避免短时间内重复告警(如波动导致的频繁触发)。
  3. 可视化与报表
    • 直观的 Web 控制台:实时展示监控数据、拓扑图、仪表盘(Dashboard),支持自定义视图。
    • 图表分析:趋势图、饼图、柱状图等,可查看历史数据(分钟级、小时级、天级),辅助容量规划和问题溯源。
    • 自动生成报表:监控数据统计、告警汇总等,支持导出 PDF/CSV。
  4. 分布式架构支持
    • 适合大规模监控场景(上万台设备),通过 Zabbix Proxy 实现区域级数据汇聚,减轻 Server 压力,优化跨机房网络传输。
    • 支持高可用部署(Server 集群),避免单点故障。

Zabbix 核心组件

  1. Zabbix Server

    系统核心,负责接收监控数据、存储(依赖数据库,如 MySQL、PostgreSQL)、分析数据、触发告警、管理配置等。

  2. Zabbix Agent

    安装在被监控设备上的轻量客户端,负责采集本地数据(如 CPU、内存),通过主动 / 被动模式与 Server/Proxy 通信(默认端口 10050)。

Zabbix 的基本监控流程:Agent采集数据 → 发送给Server/Proxy → Server存储到数据库 → 分析数据触发告警 → Web界面展示

环境部署

需要两台虚拟机
zabbix-server
zabbix-agent

安装nginx(zabbix-server下面安装)

#配置主机名
hostnamectl set-hostname zabbix-server#防火墙、selinux
systemctl disable firewalld.service
setenforce 0#创建nginx的yum源
vim /etc/yum.repos.d/nginx.repo
[nginx]
name=nginx repo
baseurl=http://nginx.org/packages/centos/7/$basearch/
gpgcheck=0
enabled=1#安装nginx
yum install -y nginx#开启服务
systemctl start nginx 
systemctl enable nginx

去浏览器测试nginx是否安装成功

在这里插入图片描述

安装数据库

#配置Mariadb10.5 yum源
vim /etc/yum.repos.d/mariadb.repo
[mariadb]
name = MariaDB
baseurl = https://archive.mariadb.org/mariadb-10.5.23/yum/centos7-amd64/
gpgkey=https://archive.mariadb.org/mariadb-10.5.23/yum/centos7-amd64/RPM-GPG-KEY-MariaDB
gpgcheck=0#安装mariadb
yum -y install mariadb-server mariadb#开启服务             
systemctl enable mariadb --now#自定义设置root密码
mysql_secure_installation
yy 设置密码 nnny

安装php

#安装php
yum -y install epel-release
rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpmyum -y install php72w php72w-cli php72w-common php72w-devel php72w-embedded php72w-gd php72w-mbstring php72w-pdo php72w-xml php72w-fpm php72w-mysqlnd php72w-opcache php72w-ldap php72w-bcmath

配置nginx支持php

#修改php-fpm配置文件,把apache改为nginx
vim /etc/php-fpm.d/www.conf 
//8行 user = nginx
//10行 group = nginx#配置location,在index中添加index.php。以支持index.php的首页
vim /etc/nginx/conf.d/default.conf 
//9行  index  index.php index.html index.htm;
//配置php请求被传送到后端的php-fpm模块,默认情况下php配置块是被注释的,此时去掉注释并修改
//把fastcgi_param中的/scripts改为$document_root。root是配置php程序放置的根目录。
//29~35行     
location ~ \.php$ {root           /usr/share/nginx/html;fastcgi_pass   127.0.0.1:9000;fastcgi_index  index.php; fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;include        fastcgi_params;}#配置php
#修改PHP配置文件
vim /etc/php.ini//359 expose_php = Off    //隐藏php版本
//202 short_open_tag = On   //支持php短标签//以下为zabbix优化配置要求
//368 max_execution_time = 300  //执行时间
//378 max_input_time = 300    //接收数据等待时间
//389 memory_limit = 128M    //每个脚本占用内存
//656 post_max_size = 16M    //POST数据大小
//799 upload_max_filesize = 2M //上传文件大小
//800 always_populate_raw_post_data = -1  //需要添加可以用 $HTTP_RAW_POST_DATA 接收post raw data(原始未处理数据)
//877 date.timezone = Asia/Shanghai  //时区

启动php-fpm服务

systemctl enable php-fpm --now
# 重启nginx
systemctl restart nginx

首页文件

vim /usr/share/nginx/html/info.php
<?phpphpinfo();
?>

测试连接数据库

[root@zabbix-server ~]# cd /usr/share/nginx/html/
[root@zabbix-server html]# vim index.php 
[root@zabbix-server html]# cat index.php 
<?php$link=mysqli_connect('127.0.0.1','root','123');if ($link) echo "连接成功 !!!";else echo "连接失败 !!!";
?>

数据库内创建database和用户

[root@zabbix-server html]# mysql -u root -p123
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 17
Server version: 10.5.23-MariaDB MariaDB ServerCopyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.MariaDB [(none)]> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| test               |
+--------------------+
4 rows in set (0.003 sec)MariaDB [(none)]> create database zabbix character set utf8 collate utf8_bin;
Query OK, 1 row affected (0.001 sec)MariaDB [(none)]> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| test               |
| zabbix             |
+--------------------+
5 rows in set (0.000 sec)MariaDB [(none)]> grant all privileges on *.* to 'zabbix'@'%'identified by 'admin123';
Query OK, 0 rows affected (0.004 sec)MariaDB [(none)]> grant all privileges on *.* to 'zabbix'@'localhost'identified by 'admin123';
Query OK, 0 rows affected (0.001 sec)MariaDB [(none)]> flush privileges;
Query OK, 0 rows affected (0.001 sec)MariaDB [(none)]> exit
Bye

再次修改首页文件,看zabbix能否连接成功

[root@zabbix-server html]# vim index.php 
[root@zabbix-server html]# cat index.php 
<?php$link=mysqli_connect('127.0.0.1','zabbix','admin123');if ($link) echo "zabbix连接成功 !!!";else echo "zabbix连接失败 !!!";
?>

去浏览器访问网站:http://192.168.100.66/index.php

在这里插入图片描述

使用zabbix

导入数据库

把文件拖进来解压然后进入文件夹中把数据导入进数据库zabbix中

[root@zabbix-server ~]# rz -E
rz waiting to receive.
[root@zabbix-server ~]# ls
anaconda-ks.cfg  Downloads             nginx-release-centos-7-0.el7.ngx.noarch.rpm  Templates
Desktop          initial-setup-ks.cfg  Pictures                                     Videos
Documents        Music                 Public                                       zabbix-6.0.6.tar.gz[root@zabbix-server ~]# tar zxvf zabbix-6.0.6.tar.gz
[root@zabbix-server ~]# cd /root/zabbix-6.0.6/
[root@zabbix-server zabbix-6.0.6]# cd database/
[root@zabbix-server database]# ls
elasticsearch  Makefile.am  Makefile.in  mysql  oracle  postgresql  sqlite3[root@zabbix-server database]# cd mysql/
[root@zabbix-server mysql]# 
[root@zabbix-server mysql]# 
[root@zabbix-server mysql]# ls
data.sql  double.sql  history_pk_prepare.sql  images.sql  Makefile.am  Makefile.in  schema.sql
[root@zabbix-server mysql]# mysql -u root -p123 zabbix < schema.sql
[root@zabbix-server mysql]# mysql -u root -p123 zabbix < images.sql
[root@zabbix-server mysql]# mysql -u root -p123 zabbix < data.sql
[root@zabbix-server mysql]# mysql -u root -p123 zabbix < double.sql
[root@zabbix-server mysql]# mysql -u root -p123 zabbix < history_pk_prepare.sql

检查有没有导入成功

[root@zabbix-server mysql]# mysql -u root -p123
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 25
Server version: 10.5.23-MariaDB MariaDB ServerCopyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.MariaDB [(none)]> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| test               |
| zabbix             |
+--------------------+
5 rows in set (0.000 sec)MariaDB [(none)]> use zabbix;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -AMariaDB [zabbix]> show tables;
+----------------------------+
| Tables_in_zabbix           |
+----------------------------+
| acknowledges               |
| actions                    |
| alerts                     |
| auditlog                   |
| autoreg_host               |
| conditions                 |
| config                     |
| config_autoreg_tls         |
| corr_condition             |
| corr_condition_group       |
| corr_condition_tag         |
| corr_condition_tagpair     |
| corr_condition_tagvalue    |
| corr_operation             |
| correlation                |
| dashboard                  |
| dashboard_page             |
| dashboard_user             |
| dashboard_usrgrp           |
| dbversion                  |
| dchecks                    |
| dhosts                     |
| drules                     |
| dservices                  |
| escalations                |
| event_recovery             |
| event_suppress             |
| event_tag                  |
| events                     |
| expressions                |
| functions                  |
| globalmacro                |
| globalvars                 |
| graph_discovery            |
| graph_theme                |
| graphs                     |
| graphs_items               |
| group_discovery            |
| group_prototype            |
| ha_node                    |
| history                    |
| history_log                |
| history_log_old            |
| history_old                |
| history_str                |
| history_str_old            |
| history_text               |
| history_text_old           |
| history_uint               |
| history_uint_old           |
| host_discovery             |
| host_inventory             |
| host_tag                   |
| hostmacro                  |
| hosts                      |
| hosts_groups               |
| hosts_templates            |
| housekeeper                |
| hstgrp                     |
| httpstep                   |
| httpstep_field             |
| httpstepitem               |
| httptest                   |
| httptest_field             |
| httptest_tag               |
| httptestitem               |
| icon_map                   |
| icon_mapping               |
| ids                        |
| images                     |
| interface                  |
| interface_discovery        |
| interface_snmp             |
| item_condition             |
| item_discovery             |
| item_parameter             |
| item_preproc               |
| item_rtdata                |
| item_tag                   |
| items                      |
| lld_macro_path             |
| lld_override               |
| lld_override_condition     |
| lld_override_opdiscover    |
| lld_override_operation     |
| lld_override_ophistory     |
| lld_override_opinventory   |
| lld_override_opperiod      |
| lld_override_opseverity    |
| lld_override_opstatus      |
| lld_override_optag         |
| lld_override_optemplate    |
| lld_override_optrends      |
| maintenance_tag            |
| maintenances               |
| maintenances_groups        |
| maintenances_hosts         |
| maintenances_windows       |
| media                      |
| media_type                 |
| media_type_message         |
| media_type_param           |
| module                     |
| opcommand                  |
| opcommand_grp              |
| opcommand_hst              |
| opconditions               |
| operations                 |
| opgroup                    |
| opinventory                |
| opmessage                  |
| opmessage_grp              |
| opmessage_usr              |
| optemplate                 |
| problem                    |
| problem_tag                |
| profiles                   |
| proxy_autoreg_host         |
| proxy_dhistory             |
| proxy_history              |
| regexps                    |
| report                     |
| report_param               |
| report_user                |
| report_usrgrp              |
| rights                     |
| role                       |
| role_rule                  |
| script_param               |
| scripts                    |
| service_alarms             |
| service_problem            |
| service_problem_tag        |
| service_status_rule        |
| service_tag                |
| services                   |
| services_links             |
| sessions                   |
| sla                        |
| sla_excluded_downtime      |
| sla_schedule               |
| sla_service_tag            |
| sysmap_element_trigger     |
| sysmap_element_url         |
| sysmap_shape               |
| sysmap_url                 |
| sysmap_user                |
| sysmap_usrgrp              |
| sysmaps                    |
| sysmaps_element_tag        |
| sysmaps_elements           |
| sysmaps_link_triggers      |
| sysmaps_links              |
| tag_filter                 |
| task                       |
| task_acknowledge           |
| task_check_now             |
| task_close_problem         |
| task_data                  |
| task_remote_command        |
| task_remote_command_result |
| task_result                |
| timeperiods                |
| token                      |
| trends                     |
| trends_uint                |
| trigger_depends            |
| trigger_discovery          |
| trigger_queue              |
| trigger_tag                |
| triggers                   |
| users                      |
| users_groups               |
| usrgrp                     |
| valuemap                   |
| valuemap_mapping           |
| widget                     |
| widget_field               |
+----------------------------+
178 rows in set (0.003 sec)

安装环境包

[root@zabbix-server mysql]# yum install -y mysql-devel pcre-devel openssl-devel zlib-devel libxml2-devel net-snmp-devel net-snmp libssh2-devel OpenIPMI-devel libevent-devel openldap-devel libcurl-devel fping gcc gcc-c++ make

创建程序用户

[root@zabbix-server mysql]# useradd -s /sbin/nglogin -M zabbix
[root@zabbix-server mysql]# id zabbix
uid=1001(zabbix) gid=1001(zabbix) groups=1001(zabbix)[root@zabbix-server mysql]# cd
[root@zabbix-server ~]# 
[root@zabbix-server ~]# 
[root@zabbix-server ~]# cd zabbix-6.0.6/[root@zabbix-server zabbix-6.0.6]# export CFLAGS="-std=gnu99"#编译安装
[root@zabbix-server zabbix-6.0.6]# ./configure --sysconfdir=/etc/zabbix/ --enable-server --with-mysql --with-net-snmp --with-libxml2 --with-ssh2 --with-openipmi --with-zlib --with-libpthread --with-libevent --with-openssl --with-ldap --with-libcurl --with-libpcre

在这里插入图片描述

#安装
[root@zabbix-server zabbix-6.0.6]# make install#查看版本
[root@zabbix-server zabbix-6.0.6]# zabbix_server --version
zabbix_server (Zabbix) 6.0.6
Revision 3f7597e3ea3 27 June 2022, compilation time: Nov  5 2025 15:17:48Copyright (C) 2022 Zabbix SIA
License GPLv2+: GNU GPL version 2 or later <http://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it according to
the license. There is NO WARRANTY, to the extent permitted by law.This product includes software developed by the OpenSSL Project
for use in the OpenSSL Toolkit (http://www.openssl.org/).Compiled with OpenSSL 1.0.2k-fips  26 Jan 2017
Running with OpenSSL 1.0.2k-fips  26 Jan 2017

修改配置文件

[root@zabbix-server zabbix-6.0.6]# vim /etc/zabbix/zabbix_server.conf

创建日志文件并修改属组和属主

[root@zabbix-server zabbix-6.0.6]# touch /var/log/zabbix_server.log
[root@zabbix-server zabbix-6.0.6]# chown zabbix.zabbix /var/log/zabbix_server.log
[root@zabbix-server zabbix-6.0.6]# ll /var/log/zabbix_server.log 
-rw-r--r-- 1 zabbix zabbix 0 Nov  5 15:20 /var/log/zabbix_server.log

启动zabbix-server

[root@zabbix-server zabbix-6.0.6]# vim /usr/lib/systemd/system/zabbix-server.service
[root@zabbix-server zabbix-6.0.6]# cat /usr/lib/systemd/system/zabbix-server.service
[Unit]
Description=Zabbix Server with MySQL DB
After=syslog.target network.target mysqld.service[Service]
Type=simple
ExecStart=/usr/local/sbin/zabbix_server -f
User=zabbix[Install]
WantedBy=multi-user.target[root@zabbix-server zabbix-6.0.6]# systemctl start zabbix-server.service
[root@zabbix-server zabbix-6.0.6]# netstat -ntap | grep 10051
tcp        0      0 0.0.0.0:10051           0.0.0.0:*               LISTEN      14524/zabbix_server 

前端页面复制到站点

[root@zabbix-server zabbix-6.0.6]# cp -r /root/zabbix-6.0.6/ui/* /usr/share/nginx/html/
cp: overwrite ‘/usr/share/nginx/html/index.php’? y
[root@zabbix-server zabbix-6.0.6]# chown -R nginx:nginx /usr/share/nginx/html/

浏览器访问网站:192.168.100.66

在这里插入图片描述

访问zabbix前端

[外链图片转存中…(img-QLN4NZCp-1762338898646)]

在这里插入图片描述
在这里插入图片描述

在这里插入图片描述
在这里插入图片描述

账号:Admin
密码:zabbix

在这里插入图片描述
在这里插入图片描述

被监控端部署agent

#更新CA
[root@localhost ~]# yum update -y ca-certificates#安装软件包
[root@localhost ~]# rpm -ivh https://repo.zabbix.com/zabbix/6.0/rhel/7/x86_64/zabbix-release-6.0-4.el7.noarch.rpm[root@localhost ~]# yum install -y zabbix-agent2#启动服务
[root@localhost ~]# systemctl enable zabbix-agent2.service --now
Created symlink from /etc/systemd/system/multi-user.target.wants/zabbix-agent2.service to /usr/lib/systemd/system/zabbix-agent2.service.#修改配置文件
[root@localhost ~]# vim /etc/zabbix/zabbix_agent2.conf 
13PidFile=/var/run/zabbix/zabbix_agent2.pid
32LogFile=/var/log/zabbix/zabbix_agent2.log
43LogFileSize=0
82Server=192.168.100.66           //指向监控服务器
135ServerActive=192.168.100.66   //指向监控服务器
146Hostname=test     //名称
283Include=/etc/zabbix/zabbix_agent2.d/*.conf#查看状态
[root@localhost ~]# systemctl status zabbix-agent2.service 
● zabbix-agent2.service - Zabbix Agent 2Loaded: loaded (/usr/lib/systemd/system/zabbix-agent2.service; enabled; vendor preset: disabled)Active: active (running) since Wed 2025-11-05 16:11:39 CST; 2min 57s agoMain PID: 2158 (zabbix_agent2)CGroup: /system.slice/zabbix-agent2.service└─2158 /usr/sbin/zabbix_agent2 -c /etc/zabbix/zabbix_agent2.confNov 05 16:11:39 localhost.localdomain systemd[1]: Started Zabbix Agent 2.
Nov 05 16:11:39 localhost.localdomain systemd[1]: Starting Zabbix Agent 2...
Nov 05 16:11:39 localhost.localdomain zabbix_agent2[2158]: Starting Zabbix Agent 2 (6.0.42)
Nov 05 16:11:39 localhost.localdomain zabbix_agent2[2158]: Zabbix Agent2 hostname: [Zabbix server]
Nov 05 16:11:39 localhost.localdomain zabbix_agent2[2158]: Press Ctrl+C to exit.

ive: active (running) since Wed 2025-11-05 16:11:39 CST; 2min 57s ago
Main PID: 2158 (zabbix_agent2)
CGroup: /system.slice/zabbix-agent2.service
└─2158 /usr/sbin/zabbix_agent2 -c /etc/zabbix/zabbix_agent2.conf

Nov 05 16:11:39 localhost.localdomain systemd[1]: Started Zabbix Agent 2.
Nov 05 16:11:39 localhost.localdomain systemd[1]: Starting Zabbix Agent 2…
Nov 05 16:11:39 localhost.localdomain zabbix_agent2[2158]: Starting Zabbix Agent 2 (6.0.42)
Nov 05 16:11:39 localhost.localdomain zabbix_agent2[2158]: Zabbix Agent2 hostname: [Zabbix server]
Nov 05 16:11:39 localhost.localdomain zabbix_agent2[2158]: Press Ctrl+C to exit.

http://www.dtcms.com/a/573888.html

相关文章:

  • 深度解析:接口性能优化实战指南
  • 站点创建成功html代码hr表示
  • 一、Netty-高并发IO底层原理(5种主要的IO模型)
  • 网站开发外包 验收c2c有哪些网站
  • Jenkins是什么
  • 建网站公司浩森宇特大连网络营销师招聘网
  • LeetCode - 杨辉三角 / 二叉树的最大深度
  • RV1126 NO.39:OPENCV查找图形轮廓并画框
  • 【第1章>第3节】基于FPGA的图像腐蚀处理算法的Verilog实现
  • 西安电子科技大学信息化建设处网站模板建站排版跟没缓存好似的
  • 神经网络—— 学习与感知器(细节补充)
  • tensorflow 图像分类 之一
  • 自己网站上做淘宝搜索引擎网站开发属于什么行业
  • 查询网站备案号网站如何做免费的推广
  • 编写一个DXE driver 提供遍历pcie设备配置空间的protocol
  • 随笔之工作方法的“术”
  • 淘宝上做进出口网站有哪些我男同同性做视频网站
  • LLM中的选择性注意:从人类聚焦到模型聚焦
  • 从成本到战略:金仓 KingbaseES 的多维度优势与企业数据库选型的核心考量
  • 做pc网站排wordpress载入慢
  • Java注解在Spring Boot中的详细原理与使用情况解析
  • Python + WebSocket 实现实时体育比分系统(含数据库设计与前端演示)
  • 揭阳智能模板建站网站转应用
  • 多个网站 备案吗工作室网站建设要多大内存
  • 借助 TX Text Control:在 .NET C# 中验证 PDF/UA 文档
  • 高光谱成像系统赋能烟叶分选(烟叶除杂、烟叶霉变、烟叶烟梗区分、烟叶等级分选)
  • Java NIO 深度解析:从 BIO 到 NIO 的演进与实战​
  • 聊聊AIoT开发效率与安全:从ARMINO IDK框架说起
  • 0.5、提示词中 System、User、Assistant 的基本概念
  • 响应式网站设计建设制作温岭app开发公司