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

Zabbix 安装与配置

Zabbix 安装与配置

一、Zabbix 简介

Zabbix 是一款开源的企业级分布式监控系统,用于实时监控服务器、网络设备、应用程序等的状态。当设备出现异常(如 CPU 负载过高、磁盘空间不足、服务宕机等)时,Zabbix 能自动触发告警,并通过邮件、短信等方式通知管理员。同时,Zabbix 提供丰富的数据可视化功能,支持图表、仪表盘和报表,便于分析和趋势预测。

Zabbix 主要特性
  • 数据采集:支持 Agent、SNMP、IPMI、JMX 等多种方式采集数据。
  • 触发与告警:支持自定义触发条件和告警规则,支持多种通知方式。
  • 数据存储:使用数据库(如 MySQL、PostgreSQL)存储配置和监控数据。
  • 数据展示:提供 Web 界面、图表、地图、仪表盘等可视化功能。
Zabbix 架构组件
组件说明
Zabbix Server核心服务,负责数据处理、告警触发、通知发送
Zabbix Database存储配置信息与监控数据
Zabbix Web基于 Web 的管理界面
Zabbix Proxy可选的代理节点,用于分布式监控和负载分担
Zabbix Agent部署在被监控主机上,采集本地数据

二、安装环境准备

1、系统环境
  • 操作系统:Rocky Linux 9(或其他 RHEL 系)
  • 主机名:zabbix-server
  • IP 地址:192.168.100.100(示例)
2、前置操作

关闭防火墙和 SELinux

安装常用工具和时钟同步服务

yum -y install lrzsz tar net-tools chrony

三、安装 Zabbix

1、安装 Zabbix 源
[root@zabbix-server ~]# rpm -Uvh zabbix-release-7.0-2.el9.noarch.rpm
2、替换为阿里镜像源

编辑 /etc/yum.repos.d/zabbix.repo

[zabbix]
name=Zabbix Official Repository - $basearch
baseurl=https://mirrors.aliyun.com/zabbix/zabbix/7.0/rocky/9/$basearch/
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX-B5333005[zabbix-non-supported]
name=Zabbix Official Repository non-supported - $basearch
baseurl=https://mirrors.aliyun.com/zabbix/non-supported/rhel/9/$basearch/
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX-08EFA7DD
gpgcheck=1[zabbix-sources]
name=Zabbix Official Repository source code - $basearch
baseurl=https://repo.zabbix.com/zabbix/7.0/rocky/9/SRPMS
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX-B5333005
gpgcheck=1

3、安装 Zabbix 组件

[root@zabbix-server ~]# yum -y install zabbix-server-mysql zabbix-web-mysql zabbix-nginx-conf zabbix-sql-scripts zabbix-selinux-policy zabbix-agent

四、安装与配置数据库

1、安装 MariaDB
[root@zabbix-server ~]# yum -y install mariadb-server mariadb
[root@zabbix-server ~]# systemctl restart mariadb
[root@zabbix-server ~]# systemctl enable mariadb
2、初始化数据库安全设置
[root@zabbix-server ~]# mysql_secure_installation Switch to unix_socket authentication [Y/n] yYou already have your root account protected, so you can safely answer 'n'.Change the root password? [Y/n] y
New password: 
Re-enter new password: 
Password updated successfully!Remove anonymous users? [Y/n] yDisallow root login remotely? [Y/n] nRemove test database and access to it? [Y/n] yReload privilege tables now? [Y/n] yThanks for using MariaDB!
3、创建 Zabbix 数据库与用户
[root@zabbix-server ~]# mysql -uroot -p
Enter password: 
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 12
Server version: 10.5.16-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)]> create database zabbix character set utf8mb4 collate utf8mb4_bin;
Query OK, 1 row affected (0.000 sec)MariaDB [(none)]> create user zabbix@localhost identified by 'wiltjer';
Query OK, 0 rows affected (0.001 sec)MariaDB [(none)]> grant all privileges on zabbix.* to zabbix@localhost;
Query OK, 0 rows affected (0.001 sec)MariaDB [(none)]> set global log_bin_trust_function_creators = 1;
Query OK, 0 rows affected (0.000 sec)MariaDB [(none)]> flush privileges;
Query OK, 0 rows affected (0.000 sec)MariaDB [(none)]> exit;
Bye
4、导入 Zabbix 数据库结构
[root@zabbix-server ~]# zcat /usr/share/zabbix-sql-scripts/mysql/server.sql.gz | mysql --default-character-set=utf8mb4 -uzabbix -p zabbix
Enter password:
5、关闭函数创建权限
[root@zabbix-server ~]# mysql -uroot -p
Enter password: 
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 14
Server version: 10.5.16-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)]> set global log_bin_trust_function_creators = 0;
Query OK, 0 rows affected (0.000 sec)MariaDB [(none)]> flush privileges;
Query OK, 0 rows affected (0.000 sec)MariaDB [(none)]> exit;
Bye

五、配置 Zabbix Server

编辑 /etc/zabbix/zabbix_server.conf

ListenPort=10051
DBHost=localhost
DBName=zabbix
DBUser=zabbix
DBPassword=wiltjer
DBSocket=/var/lib/mysql/mysql.sock
ListenIP=0.0.0.0

六、配置 Web 前端

1、配置 Nginx

编辑 /etc/nginx/conf.d/zabbix.conf

listen          8080;
server_name     192.168.100.100;
2、启动服务
[root@zabbix-server ~]# systemctl restart zabbix-server.service zabbix-agent.service nginx php-fpm
[root@zabbix-server ~]# systemctl enable zabbix-server.service zabbix-agent.service nginx php-fpm

七、访问 Zabbix Web 安装向导

在浏览器中打开

默认账号为 Admin,密码为 zabbix

http://192.168.100.100:8080/setup.php

在这里插入图片描述

八、中文支持

从 Windows 系统复制 simkai.ttf(楷体)

上传至服务器 /usr/share/zabbix/assets/fonts/

替换默认字体:

[root@zabbix-server ~]# cd /usr/share/zabbix/assets/fonts/
[root@zabbix-server fonts]# mv simkai.ttf graphfont.ttf 
mv: overwrite 'graphfont.ttf'? y[root@zabbix-server ~]# systemctl restart zabbix-agent.service 
[root@zabbix-server ~]# systemctl enable zabbix-agent.service

九、配置 Zabbix Agent(监控远程主机)

在被监控主机上执行

[root@zabbix-agent yum.repos.d]# curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo
[root@zabbix-agent ~]# yum -y install zabbix-agent

编辑 /etc/zabbix/zabbix_agentd.conf

Server=192.168.100.100			# Zabbix Server IP
ServerActive=192.168.100.100
Hostname=zabbix-agent			# 在 Zabbix Web 中配置的主机名

重启并启用 Agent

[root@zabbix-agent ~]# systemctl restart zabbix-agent
[root@zabbix-agent ~]# systemctl enable zabbix-agent

十、在 Zabbix Web 中添加主机

1、登录 Zabbix Web

监测 主机 创建主机

在这里插入图片描述

2、填写主机名、IP、端口(10050)

在这里插入图片描述

3、查看仪表盘

在这里插入图片描述

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

相关文章:

  • Java Socket编程深度解析:从网络基础到高性能通信架构的全景实践
  • 网站建设湖南岚鸿建设免费推广自己的网站
  • 网页设计元素湖南关键词优化推荐
  • 共形场拓扑序
  • Java线程知识(二)
  • 全国射箭协作区锦标赛
  • IFC 2x3 和IFC4_ADD2 和IFC 4.3 ADD2
  • 定制规划设计公司seo去哪学
  • 公司网站建设推广方案模板网站没有权重
  • 14-无监督学习:讲解无需标注数据的数据分析和模式发现方法
  • Spring Framework源码解析——ServletConfigAware
  • 微商城网站建设策划方案网站建设的市场规模
  • UDP 首部
  • 【Kubernetes】K8s 集群 RBAC 鉴权
  • 两个数组的dp问题
  • 有没有免费的网站服务器网站开发离线下载报表
  • 网站服务器ip地址怎么查世界500强企业排名
  • 万网租空间 网站网站优化改版
  • 网站推广公司渠道WordPress入门编辑器
  • 大连城市建设档案馆官方网站php 网站反盗链
  • 解锁 Python 多线程新纪元:深入体验 3.14 的 Free-Threading 功能
  • 【框架演进】Vue与React的跨越性变革:从Vue2到Vue3,从Class到Hooks
  • ASP.NET Core Blazor简介和快速入门(基础篇)
  • 找印度人做网站网站建设经费预算
  • 孝感网站建设公司学院 网站 两学一做
  • 网站建设费用5万入账企业注册号查询系统
  • Redis概述
  • 南京网站优化步骤制作企业网站页面html
  • 南阳微网站推广wordpress 怎么添加网站备案信息
  • 将导出的数据导入新创建的海量数据库