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

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

〇、参考链接🔗


产品手册 (zabbix.com)


Zabbix 中文文档


Windows agent installation from MSI


一、Zabbix简介🔊


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


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



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


概述🥇


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


数据采集


  • 可用性和性能检查;


  • 支持 SNMP(包括主动轮询和被动捕获)、IPMI、JMX、VMware 监控


  • 自定义检查;


  • 按照自定义的时间间隔采集需要的数据;


  • 通过 Server/Proxy 和 Agents 来执行数据采集。



灵活的阈值定义


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


高度可配置化的告警


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


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


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


实时图形


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


Web监控功能


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


丰富的可视化选项


  • 可以组合多个监控项到单个视图中,创建自定义图表;


  • 网络拓扑图;


  • 以仪表盘样式展示自定义聚合图形和幻灯片演示;


  • 报表;


  • 监控资源的更高层次展示视图(业务视图)。


历史数据存储


  • 存储在数据库中的数据;


  • 历史配置;


  • 内置数据管理机制(housekeeping)。


配置简单


  • 将被监控设备添加为主机;


  • 主机一旦添加到数据库中,就会采集数据用于监控;


  • 将模板用于监控设备


网络发现


  • 自动发现网络设备


  • Zabbix Agent 发现设备后自动注册;


  • 自动发现文件系统、网络接口和 SNMP OIDs 值。



三、Zabbix节点规划🎨


主机名 IP地址 操作系统 服务角色 备注
💻zabbix-server 192.168.200.60 CentOS 7.9 Zabbix-Server
💻zabbix-agent-centos 192.168.200.70 CentOS 7.9 Zabbix-Agent
💻xyb 192.168.200.80 Windows 10 Zabbix-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



查看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 版本)



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



6、安装并配置数据库📙


安装mariadb数据库


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



启动数据库并设置开机自启动


[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 ~]# 
相关实践学习
每个IT人都想学的“Web应用上云经典架构”实战
本实验从Web应用上云这个最基本的、最普遍的需求出发,帮助IT从业者们通过“阿里云Web应用上云解决方案”,了解一个企业级Web应用上云的常见架构,了解如何构建一个高可用、可扩展的企业级应用架构。
MySQL数据库入门学习
本课程通过最流行的开源数据库MySQL带你了解数据库的世界。   相关的阿里云产品:云数据库RDS MySQL 版 阿里云关系型数据库RDS(Relational Database Service)是一种稳定可靠、可弹性伸缩的在线数据库服务,提供容灾、备份、恢复、迁移等方面的全套解决方案,彻底解决数据库运维的烦恼。 了解产品详情: https://www.aliyun.com/product/rds/mysql 
相关文章
|
Linux 应用服务中间件 nginx
在CentOS上部署Minikube教程
至此,您已成功在CentOS上部署并使用Minikube。您可以自由探索Kubernetes的世界,熟练配置和管理Kubernetes集群。
1153 20
|
监控 关系型数据库 MySQL
zabbix7.0.9安装-以宝塔安装形式-非docker容器安装方法-系统采用AlmaLinux9系统-最佳匹配操作系统提供稳定运行环境-安装教程完整版本-优雅草卓伊凡
zabbix7.0.9安装-以宝塔安装形式-非docker容器安装方法-系统采用AlmaLinux9系统-最佳匹配操作系统提供稳定运行环境-安装教程完整版本-优雅草卓伊凡
1189 30
|
运维 监控 BI
zabbix强大的报警系统
zabbix强大的报警系统
677 8
|
监控 关系型数据库 MySQL
【01】客户端服务端C语言-go语言-web端PHP语言整合内容发布-优雅草网络设备监控系统-硬件设备实时监控系统运营版发布-本产品基于企业级开源项目Zabbix深度二开-分步骤实现预计10篇合集-自营版
【01】客户端服务端C语言-go语言-web端PHP语言整合内容发布-优雅草网络设备监控系统-硬件设备实时监控系统运营版发布-本产品基于企业级开源项目Zabbix深度二开-分步骤实现预计10篇合集-自营版
693 0
|
Oracle 关系型数据库 MySQL
Centos7下图形化部署单点KFS同步工具并将Oracle增量同步到KES
Centos7下图形化部署单点KFS同步工具并将Oracle增量同步到KES
Centos7下图形化部署单点KFS同步工具并将Oracle增量同步到KES
|
存储 Linux 开发者
虚拟机centos7.9一键部署docker
本文介绍了如何在 CentOS 7.9 虚拟机上安装 Docker 社区版 (Docker-ce-20.10.20)。通过使用阿里云镜像源,利用 `wget` 下载并配置 Docker-ce 的 YUM 仓库文件,然后通过 `yum` 命令完成安装。安装后,通过 `systemctl` 设置 Docker 开机自启并启动 Docker 服务。最后,使用 `docker version` 验证安装成功,并展示了客户端与服务器的版本信息。文中还提供了列出所有可用 Docker-ce 版本的命令。
3508 0
虚拟机centos7.9一键部署docker
|
监控 应用服务中间件 nginx
详细解释容器以及虚拟机centos7.9容器化部署基础服务(容器化部署nginx)
容器是一种轻量级、可移植的软件打包和隔离技术,将应用程序及其依赖项打包,确保在任何环境中一致运行。容器共享主机操作系统内核,相比虚拟机更高效、轻量,具有快速启动和高资源利用率的特点。容器的关键技术包括命名空间(如 PID、NET 等)、控制组(cgroups)和联合文件系统(UnionFS)。使用容器可以提高开发和部署效率,简化管理,确保环境一致性。例如,在 CentOS 7.9 上部署 Nginx 时,可以通过 Docker 下载和运行 `nginx:1.20` 镜像,并通过端口映射使外部请求访问 Nginx 服务。此外,还可以将测试页面复制到容器中,进一步验证容器的功能。
589 0
|
Linux 网络安全 开发工具
centos7部署l2tp ipsec
1、查询操作系统版本 #cat /etc/redhat-release CentOS Linux release 7.5.1804 (Core) 2、查询系统是否支持ppp,返回yes代表通过。 #modprobe ppp-compress-18 && echo yes 3、查询系统是否开启了tun,返回File descriptor in bad state代表通过。
9059 0
|
存储 Ubuntu Linux
VMware-安装CentOS系统教程及安装包
虚拟机相当于是一个独立于你电脑的环境,在这个环境上面,你可以安装Linux、Windows、Ubuntu等各个类型各个版本的系统,在这个系统里面你不用担心有病读等,不用担心文件误删导致系统崩溃。 虚拟机也和正常的电脑系统是一样的,也可以开关机,不用的时候,你关机就可以了,也不会占用你的系统资源,使用起来还是比较方便 这里也有已经做好的CentOS 7系统,下载下来解压后直接用VMware打开就可以使用
1706 69
|
11月前
|
存储 分布式计算 Linux
安装篇--CentOS 7 虚拟机安装
VMware 装 CentOS 7 不知道从哪下手?这篇超详细图文教程手把手教你在 VMware Workstation 中完成 CentOS 7 桌面系统的完整安装流程。从 ISO 镜像下载、虚拟机配置,到安装图形界面、设置用户密码,每一步都有截图讲解,适合零基础新手快速上手。装好之后无论你是要搭 Hadoop 集群,还是练 Linux ,这个环境都够你折腾一整天!
4545 3