Zabbix监控系统部署与管理

本文详细介绍了Zabbix监控系统,包括其构成、安装步骤、数据库配置、环境准备,以及两节点部署的详细过程,如zabbix-server和zabbix-agent的部署、数据库访问权限问题的解决,以及基本的web管理操作,如创建主机群组、添加主机和模板等。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

目录

zabbix介绍

zabbix构成

zabbix进程

环境

zabbix-server节点部署

安装zabbix服务

安装与配置数据库

修改zabbix-PHP时区

登录网页安装

​编辑数据库Access denied故障

zabbix-agent节点部署

zabbix web管理

中文乱码问题

zabbix介绍

        zabbix是⼀个基于 Web 界面的提供分布式系统监视以及网络监视功能的企业级的免费开源解决⽅案。zabbix能监视各种⽹络参数,保证服务器系统的安全运营;并提供灵活的通知机制以让系统管理员快速定位/解决存在的各种问题。

zabbix构成

        zabbix由2部分构成,zabbix server与zabbix agent:

1、zabbix server 可以通过SNMP,zabbix agent,ping,端口监视等方法提供对远程服务器/网络状态的监视,数据收集等功能,它可以运行在Linux等平台上, zabbix server端基于C语言,web管理端Frontend基于PHP。

2、zabbix agent 需要安装在被监视的目标服务器上,它主要完成对硬件信息或与操作系统有关的内存,CPU 等信息的收集。

        当 zabbix 监控某个具体的项目, 该项目会设置⼀个触发器阈值,当被监控的指标超过该触发器设定的阈值,会进⾏⼀些必要的动作,动作包括:发送信息(邮件、微信、短信)、发送命令(shell 命令、reboot、restart、install 等),zabbix可以通过公有的通用协议snmp , icmp-ping等技术来实现支持无agent监视。

zabbix进程

1、zabbix server zabbix 服务端守护进程
2、zabbix agent 客户端守护进程,负责收集客户端数据
3、zabbix proxy zabbix 分布式代理守护进程
4、zabbix get 数据接收工具,单独使⽤的CLI命令
5、zabbix sender zabbix 数据发送⼯具

环境

VMware Workstation 17 Pro

CentOS Linux release 7.9.2009 (Core)

——4core,4G内存

——100G硬盘精简置备

——NAT网络

zabbix版本5.0.40

#

两节点部署

zabbix-server节点 192.168.8.165

zabbix-agent节点 192.168.8.148

zabbix-server节点部署

安装zabbix服务

#修改主机名
hostnamectl set-hostname zabbix-server && bash
hostnamectl set-hostname zabbix-agent && bash

#安全相关
systemctl disable firewalld.service --now
sed -i 's/^SELINUX=.*/SELINUX=disabled/' /etc/selinux/config
setenforce 0

#添加zabbix软件源,在epel源后添加zabbix相关字段
wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo

cat > /etc/yum.repos.d/zabbix.repo <<END 
[zabbix]
name=Zabbix Official Repository
baseurl=https://mirrors.aliyun.com/zabbix/zabbix/5.0/rhel/7/x86_64/
enabled=1
gpgcheck=0

[zabbix-frontend]
name=Zabbix Official Repository frontend
baseurl= https://mirrors.aliyun.com/zabbix/zabbix/5.0/rhel/7/x86_64/frontend/
enabled=1
gpgcheck=0
END

#安装zabbix-server、数据库、agent、
yum install -y zabbix-server-mysql zabbix-agent centos-release-scl \
zabbix-web-mysql-scl zabbix-apache-conf-scl
yum install -y zabbix-server-mysql zabbix-agent centos-release-scl \
zabbix-web-mysql-scl zabbix-apache-conf-scl --skip-broken
yum install -y zabbix-server-mysql zabbix-agent centos-release-scl \
zabbix-web-mysql-scl zabbix-apache-conf-scl

安装与配置数据库

#安装数据库
yum -y install mariadb mariadb-server
systemctl enable mariadb.service --now

mysql -uroot
create database zabbix character set utf8 collate utf8_bin; #创建数据库名称为zabbix
create user zabbix@localhost identified by 'ws'; #设置密码,我写的是ws
grant all privileges on zabbix.* to zabbix@localhost;
flush privileges;
quit;

#配置数据库
#在mariadb中导入zabbix的表
cd /usr/share/doc/zabbix-server-mysql-5.0.40/
zcat create.sql.gz | mysql -uzabbix -p'ws' zabbix

#关联zabbix与mariadb
修改/etc/zabbix/zabbix_server.conf
确保文件内有以下几个字段:
DBHost=loaclhost
DBUser=zabbix
DBPassword=ws
DBName=zabbix

修改zabbix-PHP时区

修改/etc/opt/rh/rh-php72/php-fpm.d/zabbix.conf
sed -i 's/^;.*/php_value[date.timezone] = Asia\/Shanghai/' /etc/opt/rh/rh-php72/php-fpm.d/zabbix.conf

systemctl enable zabbix-server zabbix-agent httpd rh-php72-php-fpm --now
systemctl restart zabbix-server zabbix-agent httpd rh-php72-php-fpm

登录网页安装

#登录网页进行安装
http://192.168.8.165/zabbix/setup.php #我的server地址为192.168.8.165
在网页中输入密码,填写服务器名称
#配置数据库链接
#配置服务器详细信息
#zabbix服务器和客户端分别有一个运行端口,默认服务器端10050,客户端10051

finish后进入web
默认用户名Admin
默认密码zabbix

数据库Access denied故障

显示网页10051端口未监听

netstat -tunlp | grep -i zabbix 也只监听了10050端口

#

#

查看tail -f /var/log/zabbix/zabbix_server.log

提示database isdown

connection to database 'zabbix' failed: [2005] Unknown MySQL server host 'loaclhost'

#

#

重新确认/etc/zabbix/zabbix_server.conf文件 发现DBuser字段没有添加 重新添加后重启服务,恢复正常

#

zabbix-agent节点部署

#调整软件源
wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo

cat > /etc/yum.repos.d/zabbix.repo <<END 
[zabbix]
name=Zabbix Official Repository
baseurl=https://mirrors.aliyun.com/zabbix/zabbix/5.0/rhel/7/x86_64/
enabled=1
gpgcheck=0

[zabbix-frontend]
name=Zabbix Official Repository frontend
baseurl= https://mirrors.aliyun.com/zabbix/zabbix/5.0/rhel/7/x86_64/frontend/
enabled=1
gpgcheck=0
END

#安全相关
systemctl disable firewalld.service --now
sed -i 's/^SELINUX=.*/SELINUX=disabled/' /etc/selinux/config
setenforce 0

#安装agent软件
yum install -y zabbix-agent

#修改agent配置文件
vim /etc/zabbix/zabbix_agentd.conf
找到与修改为
Server=192.168.8.165 #被动方式
ServerActive=192.168.8.165 #主动方式
Hostname=agent01

systemctl enable zabbix-agent --now

netstat -tunlp | grep -i zabbix #agent已经打开10050端口
tcp        0      0 0.0.0.0:10050           0.0.0.0:*               LISTEN      5790/zabbix_agentd 
tcp6       0      0 :::10050                :::*                    LISTEN      5790/zabbix_agentd

zabbix web管理

1、创建主机群组
2、添加主机

#

#

3、对该主机添加模板(zabbix根据模板进行监控

例如添加templates-Template App HTTP Service

此时会提示存在问题Apache: Service is down

#

#

4、图形管理

在主机里找到图形-创建图形-添加监控项-确定添加

#

#

中文乱码问题

在C:\Windows\Fonts中找到简中字体文件

我复制的是简体仿宋simfang.ttf

从windows中拷贝字体文件到zabbix-server中

cp /usr/share/zabbix/assets/fonts/graphfont.ttf \

/usr/share/zabbix/assets/fonts/graphfont.ttf.bak

把simfang.ttf字体文件替换掉graphfont.ttf,并重新命名成graphfont.ttf

systemctl restart zabbix-server

#乱码问题恢复

#

### 部署 Zabbix 监控系统于 CentOS 8 #### 添加必要的仓库 由于 Zabbix 并未包含在 CentOS 的默认软件源内[^2],因此需先加入 EPEL 和官方的 Zabbix 软件库以便顺利安装。 ```bash dnf install https://repo.zabbix.com/zabbix/5.0/rhel/8/x86_64/zabbix-release-5.0-1.el8.noarch.rpm dnf clean all ``` #### 安装 MySQL 数据库服务器 (MariaDB) 为了存储配置数据和其他持久化信息,建议设置一个数据库服务。这里选用 MariaDB 来作为后端支持: ```bash dnf module enable mariadb dnf install @mariadb systemctl start mariadb.service systemctl enable mariadb.service mysql_secure_installation ``` 创建用于保存 Zabbix 数据的新数据库实例并赋予相应权限给特定用户访问此数据库: ```sql CREATE DATABASE zabbix CHARACTER SET utf8mb4 COLLATE utf8mb4_bin; GRANT ALL PRIVILEGES ON zabbix.* TO 'zabbix'@'localhost' IDENTIFIED BY '<password>'; FLUSH PRIVILEGES; EXIT; ``` 初始化该新建立起来的数据表结构以及填充初始所需记录项: ```bash zcat /usr/share/doc/zabbix-server-mysql*/create.sql.gz | mysql -uzabbix -p zabbix ``` #### 安装 Zabbix Server 及 Agent 组件 通过命令行工具来完成实际的服务组件下载本地环境构建工作: ```bash dnf install zabbix-server-mysql zabbix-web-mysql zabbix-agent ``` 编辑 `/etc/httpd/conf.d/zabbix.conf` 文件中的 PHP 设置部分以匹配所使用的时区设定. 修改 `/etc/zabbix/zabbix_server.conf` 中有关连接到之前已准备好的数据库的相关参数: ```properties DBName=zabbix DBUser=zabbix DBPassword=<your_password> ``` 启动 HTTPD Web 服务进程及其关联的日志轮转机制,并将其设为开机自启项目之一;同样处理 Zabbix 主程序本身: ```bash systemctl restart httpd php-fpm zabbix-server zabbix-agent systemctl enable httpd php-fpm zabbix-server zabbix-agent ``` 最后一步则是打开浏览器窗口输入目标主机 IP 地址加上路径 `/zabbix` 进入图形界面引导流程直至结束即可正常使用完整的功能特性集了。 对于插件数据源配置方面,则按照具体需求调整对应的 URL、用户名密码等细节选项[^3].
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

心葉493

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值