zabbix 6.0 部署 server agent

 

 

Zabbix 部署环境准备

Zabbix 版本选择

Zabbix 历史版本

https://en.wikipedia.org/wiki/Zabbix

Zabbix 产品周期

https://www.zabbix.com/cn/life_cycle_and_release_policy

 

Zabbix 分为两种版本: LTS和标准版本

 

 Zabbix 部署架构

image

 

Zabbix 安装要求
https://www.zabbix.com/documentation/6.0/zh/manual/installation/requirements
https://www.zabbix.com/documentation/5.0/zh/manual/installation/requirements
https://www.zabbix.com/documentation/4.0/zh/manual/installation/requirements

 

image

 

安装 Zabbix Server
Zabbix Server 安装方法介绍
Zabbix Server 提供了三种安装方法
二进制包安装: 官方提供了二进制包安装的方法,可以支持CentOS和Debian/Ubuntu的安装
源码编译安装: 部署繁琐,生产环境定制安装可以使用
基于容器安装: 测试环境使用,参考链接如下

 

二进制包安装 Zabbix Server
官方提供对多种OS版本的Zabbix 安装
可以从 ZABBIX 官方的软件仓库或镜像网站安装Zabbix SIA 提供了官方的 RPM 和 DEB 发行包
注意:Ubuntu22.04 不支持 Zabbix Server 5.0,只支持 Zabbix Server 6.0以上版本
二进制包安装Zabbix官方参考文档

 

官方和镜像仓库

#官方包仓库:
https://repo.zabbix.com/
#镜像源
https://mirrors.aliyun.com/zabbix/
https://mirrors.tuna.tsinghua.edu.cn/zabbix/

 

Zabbix 相关二进制包介绍

zabbix-server-mysql    #Zabbix Server服务器包
zabbix-frontend-php    #Zabbix 前端Web服务包,本质为LAP
abbix-apache-conf      #Zabbix 前端Web服务配置包,本质为LAP
zabbix-agent           #Zabbix 客户端包
zabbix-agent2          #Zabbix 客户端包
zabbix-get             #Zabbix 服务测试包

 

安装 Zabbix Server 包
访问链接: https://www.zabbix.com/download 找到仓库的源

 

 

范例: 在rocky linux 安装 Zabbix Server 5.0

 

https://www.zabbix.com/cn/download?zabbix=6.0&os_distribution=alma_linux&os_version=9&components=server_frontend_agent&db=mysql&ws=nginx

 

Install Zabbix repository

rpm -Uvh https://repo.zabbix.com/zabbix/6.0/rhel/9/x86_64/zabbix-release-latest-6.0.el9.noarch.rpm

dnf clean all

 

安装Zabbix server,Web前端,agent

dnf install zabbix-server-mysql zabbix-web-mysql zabbix-nginx-conf zabbix-sql-scripts zabbix-selinux-policy zabbix-agent

创建初始数据库

dnf install mysql mysql-server -y

systemctl start mysqld

mysql -uroot -p

create database zabbix character set utf8mb4 collate utf8mb4_bin;

create user zabbix@localhost identified by '123456';

grant all privileges on zabbix.* to zabbix@localhost;

set global log_bin_trust_function_creators = 1;

quit;

 

导入初始架构和数据,系统将提示您输入新创建的密码。

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

mysql -uroot -p

set global log_bin_trust_function_creators = 0;

quit;

 

为Zabbix server配置数据库

编辑配置文件 /etc/zabbix/zabbix_server.conf

vim /etc/zabbix/zabbix_server.conf

DBPassword=password

DBPassword=123456

 

为Zabbix前端配置PHP

编辑配置文件 /etc/nginx/conf.d/zabbix.conf uncomment and set 'listen' and 'server_name' directives.

vim  /etc/nginx/conf.d/zabbix.conf

# listen 8080;
# server_name example.com;

 

vim  /etc/nginx/conf.d/zabbix.conf 

# listen 80;
# server_name zabbix.ming.org;

 

启动Zabbix server和agent进程

启动Zabbix server和agent进程,并为它们设置开机自启:

systemctl restart zabbix-server zabbix-agent nginx php-fpm

systemctl enable zabbix-server zabbix-agent nginx php-fpm

 

 

访问 Zabbix 的 Web 管理页面完成配置向导
访问下面链接

#基于Nginx
http://server_ip_or_name/

 

78abadf44f75722b9f89ffb8a097bf33

 

 

检查环境

5d519c0439f49631855bfc6492e99a57

 

输入数据库信息

8a6962555b8caae3f6cd4b89d5fe7322

 

30a379d9ae54bc2e425074d0562b77dd

 

 

上面所填写的内容保存在下面文件中

#如果是CentOS下面文件
/etc/zabbix/web/zabbix.conf.php
#如果是Ubuntu则下面文件
/usr/share/zabbix/conf/zabbix.conf.php 实质也是/etc/zabbix/web/zabbix.conf.php软链接

完成安装

Zabbix 前端已经就绪!第一次登录, 默认的用户名是 Admin,密码是zabbix

9e5c0df0c32e48c6d07beb5032983547

 中文及乱码

e0288e8de32afc771b9d2a160c7fdc27

 

 

 

默认为英文,可修改为中文

CentOS安装中文包,再修改语言,否则无法选择

yum -y install langpacks-zh_CN

因为字体兼容性的原因,在显示中文时可能会有乱码出现
注意:乱码和语言环境无关,英语环境也支持中文显示,但会有乱码

 

C:\Windows\Fonts

 

将中文字体上传到 Zabbix Server 的目录 /usr/share/zabbix/assets/fonts 下

image

 

7481de8418c2840861f8d82669bf23aa

 

 

pwd
/usr/share/zabbix/assets/fonts

#支持ttf和ttc后缀的字体文件

mv graphfont.ttf graphfont.ttf.bak

mv msyhbd.ttc graphfont.ttf

 

ls

graphfont.ttf graphfont.ttf.bak

[root@master1 fonts]# ll
total 16488
-rw-r--r-- 1 root root 16883552 Mar  2  2025 graphfont.ttf
lrwxrwxrwx 1 root root       33 Oct 22 14:14 graphfont.ttf.bak -> /etc/alternatives/zabbix-web-font
[root@master1 fonts]# 

 



 

再次刷新页面,乱码问题解决

 

2359051290c03f8cab0c243ac1a8f93a

 

 

 

安装 Zabbix Agent
Zabbix Agent 需要安装到被监控的主机上,它负责定期收集各项数据,并发送到zabbix server端,
zabbix server将数据存储到数据库中,zabbix web 访问数据库在前端进行展现和绘图。

image

 

Zabbix Agent 有两个版本:Zabbix Agent 和 Zabbix Agent2 
Zabbix Agent 2 是新一代的 Zabbix agent,在Zabbix 4.4的版本时已经推出. 未来可能会代替 Zabbix agent

官方说明

https://www.zabbix.com/documentation/5.0/manual/concepts/agent2

 

Zabbix Agent2 特点
减少 TCP 连接的数量
基于 go 开发,支持更大的并发性检查
插件易于扩展。插件应该能够:

  • 提供琐碎的检查,包括只有几个简单的代码行
  • 提供复杂的检查,包括长期运行的脚本和独立的数据收集,并定期发回数据

是 Zabbix agent 的替代版版本(因为它支持所有以前的功能)
agent2是多线程模式,agent是多进程模式


对比 Agent和Agent2 官方链接

https://www.zabbix.com/documentation/5.0/zh/manual/appendix/agent_comparison

 

参数 Zabbix agent Zabbix agent 2
程序设计
语言 C 一部分使用C,其他用go
守护进程 yes no (Windows 5.0.4之后版本支持)
扩展支持 自定义C的可加载模
块。
自定义GO的插件。
请求    
支持平台
Linux, IBM AIX,
FreeBSD, NetBSD,
OpenBSD, HP-UX,
Mac OS X, Solaris: 9,
10, 11, Windows: 从
xp开始所有的桌面和
服务端版本。
Linux, Windows: 从xp开始所有的桌面和服务端版本。
支持的加
密库
GnuTLS 3.1.18 and
newer OpenSSL
1.0.1, 1.0.2, 1.1.0,
1.1.1 SSL库 - tested
with versions 2.7.4,
2.8.2 (某些限制的使
用, 查看 加密详情页).
Linux: OpenSSL 1.0.1和最新版本在Zabbix 4.4.8之后支
持。 MS Windows: OpenSSL 1.1.1或者最新版.
OpenSSL库必须开启PSK,否则LibreSSL不支持.
监控进程    
进程 每个server/proxy都
有独立的进程。
单个进程多线程。 这最大的线程数由GOMAXPROCS环
境变量决定。
指标
UNIX: 查看支持的
items. Windows: 查
看指定Windows版本
的监控项.
UNIX: Zabbix agent支持所有指标。 其他的, agent2 提
供Docker, Memcached, MySQL, PostgreSQL, Redis,
systemd (查看agent2的监控项)的Zabbix-native监控方
案 Windows: Zabbix agent支持所有指标和HTTPS检查
net.tcp.service* , LDAP. 其他的, agent2 提供关于
PostgreSQL, Redis的Zabbix-native监控方案。
并发 单进程按监控项顺序
进行检查
来自不同插件的检查或一个插件内的多个检查可以同时
执行。
计划/灵活
间隔 仅支持被动检查。 支持主动检查。
第三方
traps
no yes
Additional
features    
永久存储 no yes
超时设置 只能定义agent级别。 超时插件可以覆盖在agent上的级别超时设置。
参数 Zabbix agent Zabbix agent 2
删除用户
权限
yes (Unix-like
systems only) no
用户可配
置密码套
件
yes no


安装Zabbix Agent 有三种方式
包安装
二进制安装
编译安装

 

包安装 Zabbix Agent
Linux 安装 Zabbix Agent
可以从官方或国内镜像站点下载

https://www.zabbix.com/cn/download
https://repo.zabbix.com/zabbix/
https://mirrors.aliyun.com/zabbix/zabbix/
https://mirror.tuna.tsinghua.edu.cn/zabbix/zabbix/

安装说明

https://www.zabbix.com/cn/download

 

rpm -Uvh https://repo.zabbix.com/zabbix/6.0/rhel/9/x86_64/zabbix-release-latest-6.0.el9.noarch.rpm

dnf clean all

dnf install zabbix-agent

systemctl restart zabbix-agent
systemctl enable zabbix-agent

 

vim /etc/zabbix/zabbix_agentd.conf

Server=192.168.3.60

ServerActive=192.168.3.60

 

Zabbix 核心功能
使用现有模板和监控项监控主机和应用
内置模板参考链接:

https://git.zabbix.com/projects/ZBX/repos/zabbix/browse/templates

 

使用现有模板和监控项监控主机流程
在被监控的主机上安装Zabbix Agent ,建议和 Zabbix Server 同一个版本
配置 Zabbix agent的配置文件关键两项,并重启服务生效

Server = <Zabbix_Server_IP>
Hostname=<本机IP>


在Zabbix Server 上使用 zabbix_get 工具测试是否正常连接被监控主机
在Zabbix Server 添加被监控主机
在Zabbix WEB 添加已有的模板至被监控的主机
在Zabbix WEB 观察是否有新数据生成

 

监控 Linux 主机
监控前先确保被监控主机已经安装好 Zabbix agent 并启动
LInux 主机模板参考链接:

 https://git.zabbix.com/projects/ZBX/repos/zabbix/browse/templates/os/linux

 

添加主机

 

 

cae0cea099a84d96226896bc75c8fdb2

 

关联内置模板
模板是一些事先定义好的相关监控项的集合,直接关联模板,比一个一个加入监控项要方便很多
模板分为内置模板和自定义模板
内置模板参看:

https://git.zabbix.com/projects/ZBX/repos/zabbix/browse/templates

https://www.zabbix.com/documentation/5.0/zh/manual/config/items/itemtypes/zabbix_agent

 

3b32bad1d728b7fb50b56f8153e090a3

 

 

确认成功
等一会儿可以看到下面 ZBX 变绿色,表示成功

 

2853f9ee54955dbbb700baa18c6afd88

 

 

posted @ 2026-10-28 19:01  minger_lcm  阅读(16)  评论(0)    收藏  举报