【Zabbix】基于CentOS 7.9系统安装部署Zabbix 5.0LTS版本监控系统(详细教程)

18 篇文章 3 订阅
5 篇文章 1 订阅

〇、参考链接🔗

产品手册 (zabbix.com)

Zabbix 中文文档

Windows agent installation from MSI

一、Zabbix简介🔊

🏆 Zabbix 是一个基于 WEB 界面的提供分布式系统监视以及网络监视功能的企业级的开源解决方案。


🌈 它能监视各种网络参数,保证服务器系统的安全运营;并提供灵活的通知机制以让系统管理员快速定位/解决存在的各种问题。

image-20220213133347004

二、Zabbix功能特点及架构图🥇

概述🥇

Zabbix 是一个企业级分布式开源监控解决方案,一个的软件包中包含了多种功能。。


数据采集

  • 可用性和性能检查;
  • 支持 SNMP(包括主动轮询和被动捕获)、IPMI、JMX、VMware 监控
  • 自定义检查;
  • 按照自定义的时间间隔采集需要的数据;
  • 通过 Server/Proxy 和 Agents 来执行数据采集。

灵活的阈值定义

可以参考后端数据库定义非常灵活的告警阈值,即触发器


高度可配置化的告警

  • 可以根据递增计划、接收者、媒介类型自定义发送告警通知

  • 使用宏变量可以使告警通知变得更加高效有用;

  • 自动操作包含远程执行命令。


实时图形

使用内置图形功能可以将监控项实时绘制成图形


Web监控功能

Zabbix可以追踪模拟鼠标在 Web 网站上的点击操作,来检查 Web 网站的功能和响应时间


丰富的可视化选项

  • 可以组合多个监控项到单个视图中,创建自定义图表;
  • 网络拓扑图;
  • 以仪表盘样式展示自定义聚合图形和幻灯片演示
  • 报表;
  • 监控资源的更高层次展示视图(业务视图)。

历史数据存储

  • 存储在数据库中的数据;
  • 历史配置;
  • 内置数据管理机制(housekeeping)。

配置简单

  • 将被监控设备添加为主机;
  • 主机一旦添加到数据库中,就会采集数据用于监控;
  • 将模板用于监控设备

网络发现

  • 自动发现网络设备
  • Zabbix Agent 发现设备后自动注册;
  • 自动发现文件系统、网络接口和 SNMP OIDs 值。

image-20220213145236162

三、Zabbix节点规划🎨

主机名IP地址操作系统服务角色备注
💻zabbix-server192.168.200.60CentOS 7.9Zabbix-Server
💻zabbix-agent-centos192.168.200.70CentOS 7.9Zabbix-Agent
💻xyb192.168.200.80Windows 10Zabbix-Agent

四、Zabbix安装步骤📌

Ⅰ、Zabbix-Server服务端部署🔴

1、基础环境配置 📖

(1)配置主机名📚

[root@localhost ~]# hostnamectl set-hostname zabbix-server
[root@localhost ~]# bash
[root@zabbix-server ~]# hostname
zabbix-server

(2)关闭防火墙和SELINUX安全模式📴

#关闭防火墙并设置开机不启动
[root@zabbix-server ~]# systemctl disable firewalld
Removed symlink /etc/systemd/system/multi-user.target.wants/firewalld.service.
Removed symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.

关闭SElinux安全模式
[root@zabbix-server ~]# setenforce 0
[root@zabbix-server ~]# getenforce
Permissive
[root@zabbix-server ~]# vi /etc/selinux/config
修改以下内容:
SELINUX=disabled
按:wq保存退出即可。重启生效。
[root@zabbix-server ~]# reboot

(3)配置网络信息📝

[root@zabbix-server ~]# vi /etc/sysconfig/network-scripts/ifcfg-ens32 
[root@zabbix-server ~]# cat /etc/sysconfig/network-scripts/ifcfg-ens32 
TYPE=Ethernet
PROXY_METHOD=none
BROWSER_ONLY=no
BOOTPROTO=static
DEFROUTE=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_FAILURE_FATAL=no
IPV6_ADDR_GEN_MODE=stable-privacy
NAME=ens32
DEVICE=ens32
ONBOOT=yes
IPADDR=192.168.200.60
PREFIX=24
GATEWAY=192.168.200.1
DNS1=8.8.8.8
DNS2=192.168.200.1
[root@zabbix-server ~]# systemctl restart network
[root@zabbix-server ~]# systemctl status network

(4)配置更新YUM源📝

  • 备份系统YUM源

    [root@zabbix-server ~]# cd /etc/yum.repos.d/
    [root@zabbix-server yum.repos.d]# mkdir bak
    [root@zabbix-server yum.repos.d]# cp -r CentOS-* bak/
    [root@zabbix-server yum.repos.d]# cd bak
    [root@zabbix-server bak]# ll
    total 40
    -rw-r--r-- 1 root root 1664 Feb  9 15:56 CentOS-Base.repo
    -rw-r--r-- 1 root root 1309 Feb  9 15:56 CentOS-CR.repo
    -rw-r--r-- 1 root root  649 Feb  9 15:56 CentOS-Debuginfo.repo
    -rw-r--r-- 1 root root  314 Feb  9 15:56 CentOS-fasttrack.repo
    -rw-r--r-- 1 root root  630 Feb  9 15:56 CentOS-Media.repo
    -rw-r--r-- 1 root root 1331 Feb  9 15:56 CentOS-Sources.repo
    -rw-r--r-- 1 root root 8515 Feb  9 15:56 CentOS-Vault.repo
    -rw-r--r-- 1 root root  616 Feb  9 15:56 CentOS-x86_64-kernel.repo
    
  • 配置阿里云YUM镜像源

    🔔 参考链接:【阿里云镜像】更改阿里巴巴开源镜像站镜像之——CentOS

    [root@zabbix-server yum.repos.d]# curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo
      % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                     Dload  Upload   Total   Spent    Left  Speed
    100  2523  100  2523    0     0  20183      0 --:--:-- --:--:-- --:--:-- 20184
    [root@zabbix-server yum.repos.d]# ll
    total 4
    drwxr-xr-x 2 root root  220 Feb  9 15:56 bak
    -rw-r--r-- 1 root root 2523 Feb  9 16:05 CentOS-Base.repo
    
  • 更新YUM源

    [root@zabbix-server ~]# yum clean all
    Loaded plugins: fastestmirror
    Cleaning repos: base extras updates
    Cleaning up list of fastest mirrors
    [root@zabbix-server ~]# yum makecache
    Loaded plugins: fastestmirror
    Determining fastest mirrors
     * base: mirrors.aliyuncs.com
     * extras: mirrors.aliyuncs.com
     * updates: mirrors.aliyuncs.com
    base                                      | 3.6 kB  00:00:00     
    extras                                    | 2.9 kB  00:00:00     
    updates                                   | 2.9 kB  00:00:00     
    (1/10): base/7/x86_64/group_gz            | 153 kB  00:00:00     
    (2/10): base/7/x86_64/primary_db          | 6.1 MB  00:00:00     
    (3/10): base/7/x86_64/other_db            | 2.6 MB  00:00:00     
    (4/10): extras/7/x86_64/filelists_db      | 259 kB  00:00:00   
    (5/10): extras/7/x86_64/primary_db        | 243 kB  00:00:00 
    (6/10): extras/7/x86_64/other_db          | 145 kB  00:00:00     
    (7/10): base/7/x86_64/filelists_db        | 7.2 MB  00:00:01     
    (8/10): updates/7/x86_64/filelists_db     | 7.4 MB  00:00:01     
    (9/10): updates/7/x86_64/other_db         | 960 kB  00:00:00     
    (10/10): updates/7/x86_64/primary_db      |  13 MB  00:00:01     
    Metadata Cache Created
    [root@zabbix-server ~]# yum repolist
    Loaded plugins: fastestmirror
    Loading mirror speeds from cached hostfile
     * base: mirrors.aliyuncs.com
     * extras: mirrors.aliyuncs.com
     * updates: mirrors.aliyuncs.com
    repo id                 repo name                  status
    base/7/x86_64    CentOS-7 - Base - mirrors.aliyun.com    10,072
    extras/7/x86_64  CentOS-7 - Extras - mirrors.aliyun.com   500
    updates/7/x86_64 CentOS-7 - Updates - mirrors.aliyun.com  3,411
    repolist: 13,983
    [root@zabbix-server ~]# yum update
    
2、安装Zabbix镜像源📔
rpm -Uvh https://mirrors.aliyun.com/zabbix/zabbix/5.0/rhel/7/x86_64/zabbix-release-5.0-1.el7.noarch.rpm

sed -i 's#http://repo.zabbix.com#https://mirrors.aliyun.com/zabbix#' /etc/yum.repos.d/zabbix.repo 
[root@zabbix-server yum.repos.d]# rpm -Uvh https://mirrors.aliyun.com/zabbix/zabbix/5.0/rhel/7/x86_64/zabbix-release-5.0-1.el7.noarch.rpm
Retrieving https://mirrors.aliyun.com/zabbix/zabbix/5.0/rhel/7/x86_64/zabbix-release-5.0-1.el7.noarch.rpm
warning: /var/tmp/rpm-tmp.lQMN6g: Header V4 RSA/SHA512 Signature, key ID a14fe591: NOKEY
Preparing...                          ################################# [100%]
Updating / installing...
   1:zabbix-release-5.0-1.el7         ################################# [100%]
[root@zabbix-server yum.repos.d]# ll
total 8
drwxr-xr-x 2 root root  220 Feb  9 15:56 bak
-rw-r--r-- 1 root root 1759 Feb  9 16:35 CentOS-Base.repo
-rw-r--r-- 1 root root  853 May 11  2020 zabbix.repo
[root@zabbix-server yum.repos.d]# sed -i 's#http://repo.zabbix.com#https://mirrors.aliyun.com/zabbix#' /etc/yum.repos.d/zabbix.repo 
[root@zabbix-server yum.repos.d]# yum makecache
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
base                                       | 3.6 kB  00:00:00     
extras                                     | 2.9 kB  00:00:00     
updates                                    | 2.9 kB  00:00:00     
zabbix                                     | 2.9 kB  00:00:00     
zabbix-non-supported                       | 2.9 kB  00:00:00     
(1/6): zabbix/x86_64/primary_db            | 140 kB  00:00:00     
(2/6): zabbix/x86_64/other_db              | 215 kB  00:00:00     
(3/6): zabbix-non-supported/x86_64/filelists_db  | 1.7 kB  00:00:00   
(4/6): zabbix-non-supported/x86_64/other_db      | 3.3 kB  00:00:00 
(5/6): zabbix/x86_64/filelists_db                |  49 kB  00:00:01   
(6/6): zabbix-non-supported/x86_64/primary_db    | 3.7 kB  00:00:01 
Metadata Cache Created
[root@zabbix-server yum.repos.d]# yum repolist
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
repo id                repo name          status
base/7/x86_64     CentOS-7 - Base - mirrors.aliyun.com       10,072
extras/7/x86_64   CentOS-7 - Extras - mirrors.aliyun.com     500
updates/7/x86_64  CentOS-7 - Updates - mirrors.aliyun.com    3,411
zabbix/x86_64     Zabbix Official Repository - x86_64        233
zabbix-non-supported/x86_64 Zabbix Official Repository non-supported - x86_64           5
repolist: 14,221
[root@zabbix-server yum.repos.d]# 
3、安装 Zabbix 服务器📕
[root@zabbix-server ~]# yum install zabbix-server-mysql
[root@zabbix-server ~]# rpm -qa | grep zabbix
zabbix-release-5.0-1.el7.noarch
zabbix-server-mysql-5.0.20-1.el7.x86_64
4、安装 SCL 存储库📗

参考链接:RHEL/CentOS 7 前端安装

从Zabbix 5.0版本开始,Zabbix前端需要PHP 7.2版或更高版本。 非常不幸的是, RHEL/CentOS 7 缺省只提供PHP 5.4版本. 本实验介绍在RHEL/CentOS 7上安装Zabbix前端的建议方法。


从官方提供的安装包repo.zabbix.com完成了Zabbix 5.0的干净的安装, 使用yum搜索Zabbix时,可能会缺少前端包。

使用yum搜索Zabbix
[root@zabbix-server ~]# yum search all zabbix
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
============================================== Matched: zabbix ==============================================
zabbix-agent.x86_64 : Old Zabbix Agent
zabbix-agent2.x86_64 : New Zabbix Agent
zabbix-get.x86_64 : Zabbix Get
zabbix-js.x86_64 : Zabbix JS
zabbix-proxy-mysql.x86_64 : Zabbix proxy for MySQL or MariaDB database
zabbix-proxy-pgsql.x86_64 : Zabbix proxy for PostgreSQL database
zabbix-proxy-sqlite3.x86_64 : Zabbix proxy for SQLite3 database
zabbix-release.noarch : Zabbix repository configuration
zabbix-sender.x86_64 : Zabbix Sender
zabbix-server-mysql.x86_64 : Zabbix server for MySQL or MariaDB database
zabbix-server-pgsql.x86_64 : Zabbix server for PostgresSQL database
pcp-export-pcp2zabbix.x86_64 : Performance Co-Pilot tools for exporting PCP metrics to Zabbix
pcp-export-zabbix-agent.x86_64 : Module for exporting PCP metrics to Zabbix agent
zabbix-java-gateway.x86_64 : Zabbix java gateway

因为前端包被移动到了一个专用的前端子目录frontend。
然而, Zabbix前端是可以被安装的,前提是PHP 7.2依赖条件已经提供。


为了方便起见,已经从主zabbix-web包中删除了对PHP的任何直接依赖。这为解决PHP7.2依赖关系的方法提供了更大的灵活性。

建议使用Red Hat软件集合中的PHP包。

在CentOS环境下:

[root@zabbix-server ~]# yum install centos-release-scl

image-20220209204956106

查看php 7.x版本

[root@zabbix-server ~]# yum list rh-php7\*

会返回显示新的rh-php7*列表。

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

[zabbix-frontend]
...
enabled=1
...

enabled=0替代成 enabled=1

在此阶段,通yum搜索Zabbix将返回zabbix-web包和四个新包。 这四个包是:

  • zabbix-nginx-conf-scl.noarch : Nginx的Zabbix前端配置 (scl 版本)
  • zabbix-web-deps-scl.noarch : 用于从redhat软件集合安装zabbix-web包所需PHP依赖项的便利包
  • zabbix-web-mysql-scl.noarch : 用于MySQL数据库的Zabbix web前端包 (scl 版本)
  • zabbix-web-pgsql-scl.noarch : 用于PostgreSQL数据库的Zabbix web前端包(scl 版本)

image-20220209212137017

5、安装zabbix 前端包📘
[root@zabbix-server ~]# yum install -y zabbix-web-mysql-scl zabbix-apache-conf-scl zabbix-nginx-conf-scl
[root@zabbix-server ~]# rpm -qa | grep zabbix
zabbix-web-mysql-scl-5.0.20-1.el7.noarch
zabbix-apache-conf-scl-5.0.20-1.el7.noarch
zabbix-nginx-conf-scl-5.0.20-1.el7.noarch
zabbix-web-5.0.20-1.el7.noarch
zabbix-release-5.0-1.el7.noarch
zabbix-web-deps-scl-5.0.20-1.el7.noarch
zabbix-server-mysql-5.0.20-1.el7.x86_64

image-20220209212437607

6、安装并配置数据库📙

安装mariadb数据库

[root@zabbix-server ~]# yum install mariadb-server

image-20220209215541566
启动数据库并设置开机自启动

[root@zabbix-server ~]# systemctl start mariadb
[root@zabbix-server ~]# systemctl enable mariadb
[root@zabbix-server ~]# systemctl status mariadb

初始化数据库并设置数据库登录密码🔐

[root@zabbix-server ~]# mysql_secure_installation 

NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB
      SERVERS IN PRODUCTION USE!  PLEASE READ EACH STEP CAREFULLY!

In order to log into MariaDB to secure it, we'll need the current
password for the root user.  If you've just installed MariaDB, and
you haven't set the root password yet, the password will be blank,
so you should just press enter here.

Enter current password for root (enter for none): 
OK, successfully used password, moving on...

Setting the root password ensures that nobody can log into the MariaDB
root user without the proper authorisation.

Set root password? [Y/n] y
New password: 
Re-enter new password: 
Password updated successfully!
Reloading privilege tables..
 ... Success!


By default, a MariaDB installation has an anonymous user, allowing anyone
to log into MariaDB without having to have a user account created for
them.  This is intended only for testing, and to make the installation
go a bit smoother.  You should remove them before moving into a
production environment.

Remove anonymous users? [Y/n] y
 ... Success!

Normally, root should only be allowed to connect from 'localhost'.  This
ensures that someone cannot guess at the root password from the network.

Disallow root login remotely? [Y/n] n
 ... skipping.

By default, MariaDB comes with a database named 'test' that anyone can
access.  This is also intended only for testing, and should be removed
before moving into a production environment.

Remove test database and access to it? [Y/n] y
 - Dropping test database...
 ... Success!
 - Removing privileges on test database...
 ... Success!

Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.

Reload privilege tables now? [Y/n] y
 ... Success!

Cleaning up...

All done!  If you've completed all of the above steps, your MariaDB
installation should now be secure.

Thanks for using MariaDB!

进入数据库,创建zabbix数据库,注意:设置编码格式为utf-8。

mysql -uroot -ppassword

mysql> create database zabbix character set utf8 collate utf8_bin;

mysql> create user zabbix@localhost identified by ‘password’;

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

mysql> flush privileges;

mysql> quit;

[root@zabbix-server ~]# mysql -uroot -p
Enter password: 
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 11
Server version: 5.5.68-MariaDB MariaDB Server

Copyright (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 utf8 collate utf8_bin;
Query OK, 1 row affected (0.00 sec)

MariaDB [(none)]> create user zabbix@localhost identified by '000000';
Query OK, 0 rows affected (0.00 sec)

MariaDB [(none)]> grant all privileges on zabbix.* to zabbix@localhost;
Query OK, 0 rows affected (0.00 sec)

MariaDB [(none)]> flush privileges;
Query OK, 0 rows affected (0.00 sec)

MariaDB [(none)]> quit
Bye

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

[root@zabbix-server ~]# zcat /usr/share/doc/zabbix-server-mysql*/create.sql.gz | mysql -uzabbix -p zabbix
Enter password: 
[root@zabbix-server ~]# 
7、修改zabbix_server.conf配置文件📚

为Zabbix server配置数据库

修改配置文件 /etc/zabbix/zabbix_server.conf,修改数据库密码。

[root@zabbix-server ~]# vim /etc/zabbix/zabbix_server.conf 
修改内容
DBPassword=password
保存退出
8、修改 zabbix 的 php 配置文件📓
[root@zabbix-server ~]# vim /etc/opt/rh/rh-php72/php-fpm.d/zabbix.conf
修改内容
#将注释;去掉,并修改为
php_value[date.timezone] = Asia/Shanghai
按:wq保存退出

image-20220209222028509

9、启动Zabbix server和agent进程📒

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

[root@zabbix-server ~]# systemctl start zabbix-server zabbix-agent httpd rh-php72-php-fpm
[root@zabbix-server ~]# systemctl enable zabbix-server zabbix-agent httpd rh-php72-php-fpm
[root@zabbix-server ~]# systemctl status zabbix-server zabbix-agent httpd rh-php72-php-fpm
[root@zabbix-server ~]# netstat -ntpl

image-20220209224650148

10、配置Zabbix前端-WEB界面安装📃

连接到新安装的Zabbix前端: http://server_ip_or_name/zabbix

开始Web界面安装设置

image-20220209223323986

检查先决条件

image-20220209224303830

配置数据库连接信息

image-20220209224918016

服务器详细信息

image-20220209225103526

安装前确认信息

image-20220209225149305

安装完成

image-20220209225257672

11、登录Zabbix集群控制面板📜

输入系统默认的用户名和密码Admin/zabbix。
image-20220209225708018
image-20220209225650739

12、设置成中文界面📄

image-20220209230407222

Ⅱ、Zabbix-agent客户端部署——添加一台centos监控主机🟡

🎨参考链接新建主机 (zabbix.com)
注意事项:被监视的主机需要和服务器在同一网络下;修改的的主机名需要一致。

1、完成基础环境配置🆗
  • 修改主机名;

  • 关闭防火墙和SElinux安全模式;

  • 配置网卡信息,测试网络连通性;

  • 配置并更新YUM源(包括CentOS源、Zabbix源)

2、安装配置Agent✅
  • 安装zabbix-agent
rpm -Uvh https://mirrors.aliyun.com/zabbix/zabbix/5.0/rhel/7/x86_64/zabbix-release-5.0-1.el7.nsoarch.rpm

sed -i 's#http://repo.zabbix.com#https://mirrors.aliyun.com/zabbix#' /etc/yum.repos.d/zabbix.repo 
  • 配置zabbix-agent
[root@zabbix-agent-centos ~]# vim /etc/zabbix/zabbix_agentd.conf 
修改内容如下
# zabbix 服务端地址
Server=192.168.200.60
# zabbix活动服务器地址
ServerActive=192.168.200.60
# 主机名,在web页面添加主机时需设置相同
Hostname=zabbix-agent-centos
按:wq保存退出。
  • 启动zabbix-agent
[root@zabbix-agent-centos ~]# systemctl start zabbix-agent
[root@zabbix-agent-centos ~]# systemctl enable zabbix-agent
[root@zabbix-agent-centos ~]# systemctl status zabbix-agent
3、Web页面创建主机⏩

创建主机

image-20220210143059310

填写主机相关信息,如图所示。

image-20220210144529679

添加监控主机模板

image-20220210144615749

查看被监控主机是否连接上,已启用状态🔗

image-20220210144836003
image-20220210162803606
至此,CentOS系统监控主机添加完成。

Ⅲ、Zabbix-agent客户端部署——添加一台Windows监控主机🟢

📣 参考链接:4 Windows agent installation from MSI (zabbix.com)

1、安装Zabbix Agent包💖

在被监视的主机Windows主机上,安装zabbix安装包。

image-20220210165028532

接收许可协议

image-20220210165051454

填写Zabbix Agent客户端配置信息。包括主机名,Zabbix 服务端的IP地址或DNS。

image-20220210165324900

选择程序在Windows客户端安装的安装路径位置

image-20220210165356909

单击“Install”,进行安装

image-20220210165428251

安装完成,点击“Finish”。

image-20220210165625430

启动任务管理器,查看Zabbix Agent服务进程是否启动。

image-20220210165714460
至此,在Windows 10 系统上,安装部署Zabbix Agent客户端完毕。

2、添加配置防火墙规则💛

配置防火墙,允许放行zabbix端口

image-20220210170115302

选择“端口”

image-20220210170143878

选择"TCP",输入特定本地端口"10050"

image-20220210170236263

选择"允许连接"

image-20220210170254860

默认,单击"下一步"

image-20220210170313372

命令此规则的名称,例如"Zabbix 10050"

image-20220210170348025

查看此入站规则是否已添加

image-20220210170404156

3、Web页面创建主机💙

创建主机,如图所示。

image-20220210170843695

选择对应的模板

image-20220210170916758

查看是否连接。

image-20220210170940767

查看主机是否正确连接上,可用性"ZBX"选项是否变成 绿色

image-20220210171409102
至此,Windows系统监控主机添加完成。

Ⅳ、添加监控项

1、创建应用集
  • 点击“应用集”
    image-20220212125807494
  • 点击“创建应用集”
    image-20220212130127007
  • 填写“名称”
    image-20220212130408679
  • 添加完成
    image-20220212130458444
2、创建监控项
  • 点击“创建监控项”
    image-20220212130624789

  • 监控服务器CPU中断数,设备的中断数。返回整数。填写相关参数
    image-20220212130742134

  • 测试是否能过获取监控数据
    image-20220212130947151

  • 监控项已添加完成
    image-20220212131025120

关于key值,可以直接在网页上设置(服务器自动执行),也可以使用命令行命令(手动执行)来获取:

❌❗出现以下报错信息

[root@zabbix-agent-centos ~]# zabbix_get -s 192.168.200.60 -p 10050 -k 'system.cpu.intr'
-bash: zabbix_get: command not found
没有安装zabbix_get工具,执行yum命令安装即可。
[root@zabbix-agent-centos ~]# yum install -y zabbix-get-5.0.20-1.el7.x86_64

image-20220212131720938

[root@zabbix-server ~]# zabbix_get -s 192.168.200.60 -p 10050 -k 'system.cpu.intr'
377422
  • 在zabbix-agent客户端,使用命令查看intr的速率变化:
[root@zabbix-agent-centos ~]# vmstat 1
procs -----------memory---------- ---swap-- -----io---- -system-- ------cpu-----
 r  b   swpd   free   buff  cache   si   so    bi    bo   in   cs us sy id wa st
 2  0      0 1636652   2108 260304    0    0    85     5   54  119  0  0 99  0  0
 0  0      0 1636652   2108 260336    0    0     0     0   81  122  0  0 100  0  0
 0  0      0 1636652   2108 260336    0    0     0     0   67  102  0  0 100  0  0
 0  0      0 1636652   2108 260336    0    0     0     0   74  114  0  1 99  0  0
 0  0      0 1636652   2108 260336    0    0     0     0   64  101  0  0 100  0  0

image-20220212133914666

五、常见问题❓❌

1、ssh远程登录报错问题💥

C:\Users\xybdiy>ssh root@192.168.200.60
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@    WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED!     @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
IT IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY!
Someone could be eavesdropping on you right now (man-in-the-middle attack)!
It is also possible that a host key has just been changed.
The fingerprint for the ECDSA key sent by the remote host is
SHA256:dLKCGuPVvBAqv4F6zitccxVsxbZHwMoeqcH6/HFZ05c.
Please contact your system administrator.
Add correct host key in C:\\Users\\xybdiy/.ssh/known_hosts to get rid of this message.
Offending ECDSA key in C:\\Users\\xybdiy/.ssh/known_hosts:15
ECDSA host key for 192.168.200.60 has changed and you have requested strict checking.
Host key verification failed.

# 解决办法
清除本地缓存密钥后,重新SSH远程连接
C:\Users\xybdiy>ssh-keygen -R 192.168.200.60
# Host 192.168.200.60 found: line 15
C:\Users\xybdiy/.ssh/known_hosts updated.
Original contents retained as C:\Users\xybdiy/.ssh/known_hosts.old

2、PHP option “date.timezone” unknown fail 报错信息💢

image-20220209223541945

解决办法:
[root@zabbix-server ~]# vim /etc/opt/rh/rh-php72/php-fpm.d/zabbix.conf
修改内容
#将注释;去掉,并修改为
php_value[date.timezone] = Asia/Shanghai
按:wq保存退出
重启相关服务即可。

image-20220209224114499

3、中文乱码问题💥

image-20220212134021950
上传微软雅黑的字体 📌
image-20220212135517512

解决办法:
1️⃣#查询zabbix目录的所在的位置
[root@zabbix-server ~]# whereis zabbix
zabbix: /usr/lib/zabbix /etc/zabbix /usr/share/zabbix

2️⃣#通过find命令搜索fonts目录存放的位置
[root@zabbix-server ~]# find / -name fonts
/boot/grub2/fonts
/etc/fonts
/usr/share/fonts
/usr/share/zabbix/assets/fonts
/usr/share/httpd/noindex/css/fonts

3️⃣#查看fonts目录下的字体
[root@zabbix-server ~]# ls /usr/share/zabbix/assets/fonts
graphfont.ttf

4️⃣#进入fonts目录,查看该字体的软链接
[root@zabbix-server ~]# cd /usr/share/zabbix/assets/fonts/
[root@zabbix-server fonts]# ll
total 0
lrwxrwxrwx 1 root root 33 Feb  9 21:23 graphfont.ttf -> /etc/alternatives/zabbix-web-font

5️⃣#查看字体是否上传
[root@zabbix-server fonts]# ls
graphfont.ttf  msyh.ttc

6️⃣# 删除旧软链接
[root@zabbix-server fonts]# rm -f /etc/alternatives/zabbix-web-font

7️⃣# 新建新软链接
[root@zabbix-server fonts]# ln -s /usr/share/zabbix/assets/fonts/msyh.ttc /etc/alternatives/zabbix-web-font

8️⃣#重启zabbix-server服务
[root@zabbix-server fonts]# systemctl restart zabbix-server
[root@zabbix-server fonts]# systemctl status zabbix-server

成功解决
image-20220212135343347

  • 7
    点赞
  • 34
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 1
    评论
好的,以下是 CentOS 7.9 安装 Zabbix 的步骤: 1. 安装 EPEL 和 Zabbix 仓库 ```shell yum install -y epel-release rpm -ivh https://repo.zabbix.com/zabbix/5.2/rhel/7/x86_64/zabbix-release-5.2-1.el7.noarch.rpm ``` 2. 安装 Zabbix Server、Zabbix Agent 和 Zabbix Web ```shell yum install -y zabbix-server-mysql zabbix-web-mysql zabbix-agent ``` 3. 安装 MySQL 数据库 ```shell yum install -y mariadb mariadb-server ``` 4. 配置 MySQL 数据库 ```shell systemctl start mariadb systemctl enable mariadb mysql_secure_installation ``` 5. 创建 Zabbix 数据库 ```shell mysql -uroot -p create database zabbix character set utf8 collate utf8_bin; grant all privileges on zabbix.* to zabbix@localhost identified by 'zabbix'; quit; ``` 6. 导入 Zabbix 数据库 ```shell zcat /usr/share/doc/zabbix-server-mysql*/create.sql.gz | mysql -uzabbix -p zabbix ``` 7. 配置 Zabbix Server 编辑 `/etc/zabbix/zabbix_server.conf` 文件,修改以下参数: ```conf DBHost=localhost DBName=zabbix DBUser=zabbix DBPassword=zabbix ``` 8. 配置 Zabbix Web 编辑 `/etc/zabbix/web/zabbix.conf.php` 文件,修改以下参数: ```php $DB['TYPE'] = 'MYSQL'; $DB['SERVER'] = 'localhost'; $DB['PORT'] = '0'; $DB['DATABASE'] = 'zabbix'; $DB['USER'] = 'zabbix'; $DB['PASSWORD'] = 'zabbix'; ``` 9. 启动 Zabbix Server 和 Zabbix Agent ```shell systemctl start zabbix-server systemctl start zabbix-agent systemctl enable zabbix-server systemctl enable zabbix-agent ``` 10. 配置防火墙 ```shell firewall-cmd --add-port=10050/tcp --permanent firewall-cmd --add-port=10051/tcp --permanent firewall-cmd --reload ``` 11. 访问 Zabbix Web 在浏览器中访问 `http://your_ip_address/zabbix`,输入默认用户名 `Admin` 和默认密码 `zabbix` 登录 Zabbix Web。 以上就是 CentOS 7.9 安装 Zabbix 的全部步骤。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

打赏作者

云矩阵

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

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

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

打赏作者

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

抵扣说明:

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

余额充值