红帽 9 zabbix 安装流程

本文涉及的产品
RDS MySQL Serverless 基础系列,0.5-2RCU 50GB
RDS MySQL Serverless 高可用系列,价值2615元额度,1个月
简介: Zabbix是一个监控软件,用于确保企业服务架构的安全运行,具备灵活的告警机制和分布式监控能力。它由Server、Web页面、数据库、Proxy和Agent五个组件组成。工作流程中,Agent在目标设备上收集数据,Server存储和处理数据,Web页面提供监控信息。Zabbix支持主动和被动两种数据收集模式。在Redhat 9.2环境下,安装包括关闭防火墙、设置SELinux、安装MySQL、创建Zabbix数据库和用户、安装Zabbix RPM包及配置服务。完成安装后,通过Web界面使用Admin账号和预设密码zabbix登录。

?
一 、zabbix的基本概述
zabbix是一个监控软件,其可以监控各种网络参数,保证企业服务架构安全运营,同时支持灵活的告警机制,可以使得运维人员快速定位故障、解决问题。zabbix支持分布式功能,支持复杂架构下的监控解决方案,也支持web页面,为主机监控提供了良好直观的展现。

二、zabbix的构成
zabbix主要由以下5个组件构成:

1、Server

zabbix server是zabbix的核心组件,server内部存储了所有的配置信息、统计信息和操作信息。zabbix agent会向zabbix server报告可用性、完整性及其他统计信息。

2、web页面

web页面也是zabbix的一部分,通常和zabbix server位于一台物理设备上,但是在特殊情况下也可以分开配置。web页面主要提供了直观的监控信息,以方便运维人员监控管理。

3、数据库

zabbix数据库内存储了配置信息、统计信息等zabbix的相关内容。

4、proxy

zabbix proxy可以根据具体生产环境进行采用或者放弃。如果使用了zabbix proxy,则其会替代zabbix server采集数据信息,可以很好的分担zabbix server的负载。zabbix proxy通常运用与架构过大、zabbix server负载过重,或者是企业设备跨机房、跨网段、zabbix server无法与zabbix agent直接通信的场景。

5、Agent

zabbix agent通常部署在被监控目标上,用于主动监控本地资源和应用程序,并将监控的数据发送给zabbix server。

三 、zabbix的工作流程
Zabbix在进行监控时,zabbix客户端要安装在被监控设备上,负责定期收集数据,并将其发送给zabbix服务端;zabbix服务端要安装在监控设备上,其将zabbix客户端发送的数据存储的数据库中,zabbix web根据数据在前端进行展示和绘图。

zabbix的数据收集分为两种模式:

1、主动模式

zabbix客户端主动向zabbix server请求监控项列表,并主动将监控项内需要的数据提交给zabbix server。

2、被动模式

zabbix server向 agent 请求获取监控项的数据,zabbix agent返回数据。

由此可以看出zabbix的主动和被动模式是以zabbxi客户端为基准的

四、zabbix进程详解
在默认的情况下,zabbix有6个工作进程;分别是 zabbix_agentd,zabbix_get,zabbix_proxy,zabbix_sender,zabbix_server 和 zabbix_gateway。

其中,zabbix_java_gateway是可选进程。这6个进程的作用如下:

1、zabbix_agentd zabbix-agentd为zabbix客户端守护进程 ,主要负责收集客户端监控项数据。

2、zabbix_server zabbix_server为zabbix服务端守护进程,主要负责收集zabbix客户端数据。(端口为10051)

3、zabbix_proxy zabbix_proxy是zabbix的代理程序,其功能类似于server,作用上类似于一个中转站,最终会把收集的数据再次提交给zabbix_server。

4、zabbix_get zabbix_get作为zabbix工具,通常运行在zabbix_server或者zabbix_proxy上,用于远程获取客户端信息,通常用于排错。

5、zabbix_sender zabbix_sender也是zabbix的一个工具,通常运行在zabbix的客户端,用于耗时比较长的检查,其作用是主动发送数据。

6、zabbix_java_gateway zabbix_java_gateway是zabbix2.0以后引入的新功能,可以用于JAVA方面的设备;但是只能主动获取数据,而不能被动获取数据。

环境
Redhat 9.2

mysql 8.0.30

zabbix 6.4

步骤
搭建本地YUM仓库-CSDN博客

关闭防火墙seLinux

[root@admin ~]# systemctl stop firewalld
[root@admin ~]# setenforce 0
[root@admin ~]# systemctl disable firewalld
[root@admin ~]# vim /etc/selinux/config
[root@admin ~]#
17 #
18 # To revert back to SELinux enabled:
19 #
20 # grubby --update-kernel ALL --remove-args selinux
21 #
22 SELINUX=disabled //修改此行
23 # SELINUXTYPE= can take one of these three values:
机器更名

[root@admin ~]# hostnamectl set-hostname zabbix
[root@admin ~]# bash
[root@zabbix ~]#
安装mysql

[root@zabbix ~]# yum -y install mysql*
正在更新 Subscription Management 软件仓库。
无法读取客户身份

本系统尚未在权利服务器中注册。可使用 subscription-manager 进行注册。

AppStream 3.1 MB/s | 3.2 kB 00:00
BaseOS 2.7 MB/s | 2.7 kB 00:00

依赖关系解决。

软件包 架构 版本 仓库 大小

安装:
mysql x86_64 8.0.30-3.el9_0 AppStream 2.8 M
mysql-common x86_64 8.0.30-3.el9_0 AppStream 80 k
mysql-errmsg x86_64 8.0.30-3.el9_0 AppStream 488 k
mysql-selinux noarch 1.0.5-1.el9_0 AppStream 37 k
mysql-server x86_64 8.0.30-3.el9_0 AppStream 17 M
安装依赖关系:
mariadb-connector-c-config noarch 3.2.6-1.el9_0 AppStream 11 k
mecab x86_64 0.996-3.el9.3 AppStream 361 k
protobuf-lite x86_64 3.14.0-13.el9 AppStream 235 k

事务概要

安装 8 软件包

省略。。。。。。。

已安装:
mariadb-connector-c-config-3.2.6-1.el9_0.noarch mecab-0.996-3.el9.3.x86_64 mysql-8.0.30-3.el9_0.x86_64
mysql-common-8.0.30-3.el9_0.x86_64 mysql-errmsg-8.0.30-3.el9_0.x86_64 mysql-selinux-1.0.5-1.el9_0.noarch
mysql-server-8.0.30-3.el9_0.x86_64 protobuf-lite-3.14.0-13.el9.x86_64

完毕!
[root@zabbix ~]#

启动MySQL、设置开机自启、并初始化

[root@zabbix ~]# systemctl restart mysqld.service
[root@zabbix ~]# systemctl enable mysqld.service
Created symlink /etc/systemd/system/multi-user.target.wants/mysqld.service → /usr/lib/systemd/system/mysqld.service.
[root@zabbix ~]#
[root@zabbix ~]# mysql_secure_installation

Securing the MySQL server deployment.

Connecting to MySQL using a blank password.

VALIDATE PASSWORD COMPONENT can be used to test passwords
and improve security. It checks the strength of password
and allows the users to set only those passwords which are
secure enough. Would you like to setup VALIDATE PASSWORD component?

Press y|Y for Yes, any other key for No:
Please set the password for root here.

New password: //设置root密码

Re-enter new password:
By default, a MySQL installation has an anonymous user,
allowing anyone to log into MySQL 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? (Press y|Y for Yes, any other key for No) : 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? (Press y|Y for Yes, any other key for No) : y
//禁止root远程登录
Success.

By default, MySQL 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? (Press y|Y for Yes, any other key for No) : y

  • Dropping test database... //移除test数据库
    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? (Press y|Y for Yes, any other key for No) : y
//刷新权限表
Success.

All done!
[root@zabbix ~]#

进入mysql 创建zabbix数据库、用户并授予权限

[root@zabbix ~]# mysql -uroot -p1
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 15
Server version: 8.0.30 Source distribution

Copyright (c) 2000, 2022, Oracle and/or its affiliates.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> create database zabbix character set utf8mb4 collate utf8mb4_bin;
Query OK, 1 row affected (0.01 sec)

mysql> set global log_bin_trust_function_creators = 1;
Query OK, 0 rows affected (0.01 sec)

mysql> create user 'zabbix'@'%' identified by '1';
Query OK, 0 rows affected (0.00 sec)

mysql> grant all privileges on . to 'zabbix'@'%';
Query OK, 0 rows affected (0.00 sec)

mysql> flush privileges;
Query OK, 0 rows affected (0.01 sec)

mysql>
mysql> exit
Bye
安装zabbix rpm包和zabbix组件

zabbix官网 下载Zabbix

[root@zabbix ~]# rpm -Uvh https://repo.zabbix.com/zabbix/6.4/rhel/9/x86_64/zabbix-release-6.4-1.el9.noarch.rpm
获取https://repo.zabbix.com/zabbix/6.4/rhel/9/x86_64/zabbix-release-6.4-1.el9.noarch.rpm
警告:/var/tmp/rpm-tmp.Ce8fTt: 头V4 RSA/SHA512 Signature, 密钥 ID 08efa7dd: NOKEY
Verifying... ################################# [100%]
准备中... ################################# [100%]
正在升级/安装...
1:zabbix-release-6.4-1.el9 ################################# [100%]
[root@zabbix ~]# dnf clean all
正在更新 Subscription Management 软件仓库。
无法读取客户身份

本系统尚未在权利服务器中注册。可使用 subscription-manager 进行注册。

13 个文件已删除
[root@zabbix /]# dnf install zabbix-server-mysql zabbix-web-mysql zabbix-apache-conf zabbix-sql-scripts zabbix-selinux-policy zabbix-agent
正在更新 Subscription Management 软件仓库。
无法读取客户身份

本系统尚未在权利服务器中注册。可使用 subscription-manager 进行注册。

AppStream 254 MB/s | 6.3 MB 00:00
BaseOS 122 MB/s | 1.7 MB 00:00
Zabbix Official Repository - x86_64 7.3 kB/s | 222 kB 00:30
Zabbix Official Repository non-supported - x86_64 334 B/s | 1.1 kB 00:03

依赖关系解决。

软件包 架构 版本 仓库 大小

安装:
zabbix-agent x86_64 6.4.13-release1.el9 zabbix 559 k
zabbix-apache-conf noarch 6.4.13-release1.el9 zabbix 13 k
zabbix-selinux-policy x86_64 6.4.13-release1.el9 zabbix 273 k
zabbix-server-mysql x86_64 6.4.13-release1.el9 zabbix 2.0 M
zabbix-sql-scripts noarch 6.4.13-release1.el9 zabbix 7.8 M
zabbix-web-mysql noarch 6.4.13-release1.el9 zabbix 12 k
安装依赖关系:
OpenIPMI-libs x86_64 2.0.32-3.el9 AppStream 518 k
apr x86_64 1.7.0-11.el9 AppStream 127 k
apr-util x86_64 1.6.1-20.el9 AppStream 98 k
apr-util-bdb x86_64 1.6.1-20.el9 AppStream 15 k
fping x86_64 5.1-1.el9 zabbix-non-supported 35 k
httpd x86_64 2.4.53-11.el9_2.4 AppStream 54 k
httpd-core x86_64 2.4.53-11.el9_2.4 AppStream 1.5 M
httpd-filesystem noarch 2.4.53-11.el9_2.4 AppStream 17 k
httpd-tools x86_64 2.4.53-11.el9_2.4 AppStream 88 k
mariadb-connector-c x86_64 3.2.6-1.el9_0 AppStream 203 k
nginx-filesystem noarch 1:1.20.1-14.el9 AppStream 13 k
php-bcmath x86_64 8.0.27-1.el9_1 AppStream 38 k
php-common x86_64 8.0.27-1.el9_1 AppStream 686 k
php-fpm x86_64 8.0.27-1.el9_1 AppStream 1.6 M
php-gd x86_64 8.0.27-1.el9_1 AppStream 43 k
php-ldap x86_64 8.0.27-1.el9_1 AppStream 43 k
php-mbstring x86_64 8.0.27-1.el9_1 AppStream 473 k
php-mysqlnd x86_64 8.0.27-1.el9_1 AppStream 154 k
php-pdo x86_64 8.0.27-1.el9_1 AppStream 87 k
php-xml x86_64 8.0.27-1.el9_1 AppStream 138 k
redhat-logos-httpd noarch 90.4-1.el9 AppStream 18 k
unixODBC x86_64 2.3.9-4.el9 AppStream 495 k
zabbix-web noarch 6.4.13-release1.el9 zabbix 7.9 M
zabbix-web-deps noarch 6.4.13-release1.el9 zabbix 13 k
安装弱的依赖:
apr-util-openssl x86_64 1.6.1-20.el9 AppStream 17 k
mod_http2 x86_64 1.15.19-4.el9_2.4 AppStream 153 k
mod_lua x86_64 2.4.53-11.el9_2.4 AppStream 63 k

事务概要

安装 33 软件包

总计:25 M
总下载:19 M
安装大小:88 M
确定吗?[y/N]: y
下载软件包:
(1/9): zabbix-apache-conf-6.4.13-release1.el9.noarch.rpm 10 kB/s | 13 kB 00:01
(2/9): zabbix-selinux-policy-6.4.13-release1.el9.x86_64.rpm 66 kB/s | 273 kB 00:04
(3/9): zabbix-agent-6.4.13-release1.el9.x86_64.rpm 9.3 kB/s | 559 kB 01:00
(4/9): zabbix-server-mysql-6.4.13-release1.el9.x86_64.rpm 8.7 kB/s | 2.0 MB 03:52
(5/9): zabbix-web-deps-6.4.13-release1.el9.noarch.rpm 746 B/s | 13 kB 00:17
(6/9): zabbix-web-mysql-6.4.13-release1.el9.noarch.rpm 2.0 kB/s | 12 kB 00:05
(7/9): fping-5.1-1.el9.x86_64.rpm 1.8 kB/s | 35 kB 00:19
(8/9): zabbix-web-6.4.13-release1.el9.noarch.rpm 26 kB/s | 7.9 MB 05:06

(9/9): zabbix-sql-scripts-6.4.13-release1.el9.noarch.rpm 22 kB/s | 7.8 MB 06:06

总计 51 kB/s | 19 MB 06:11
Zabbix Official Repository - x86_64 3.0 MB/s | 3.1 kB 00:00
导入 GPG 公钥 0x08EFA7DD:
Userid: "Zabbix LLC (Jul 2022) packager@zabbix.com"
指纹: D9AA 84C2 B617 479C 6E4F CF4D 19F2 4753 08EF A7DD
来自: /etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX-08EFA7DD
确定吗?[y/N]: y
导入公钥成功
运行事务检查
事务检查成功。
运行事务测试
事务测试成功。
运行事务
准备中 :
省 略 。。。。。 。 。 。
已更新安装的产品。

已安装:
OpenIPMI-libs-2.0.32-3.el9.x86_64 apr-1.7.0-11.el9.x86_64 apr-util-1.6.1-20.el9.x86_64
apr-util-bdb-1.6.1-20.el9.x86_64 apr-util-openssl-1.6.1-20.el9.x86_64 fping-5.1-1.el9.x86_64
httpd-2.4.53-11.el9_2.4.x86_64 httpd-core-2.4.53-11.el9_2.4.x86_64 httpd-filesystem-2.4.53-11.el9_2.4.noarch
httpd-tools-2.4.53-11.el9_2.4.x86_64 mariadb-connector-c-3.2.6-1.el9_0.x86_64 mod_http2-1.15.19-4.el9_2.4.x86_64
mod_lua-2.4.53-11.el9_2.4.x86_64 nginx-filesystem-1:1.20.1-14.el9.noarch php-bcmath-8.0.27-1.el9_1.x86_64
php-common-8.0.27-1.el9_1.x86_64 php-fpm-8.0.27-1.el9_1.x86_64 php-gd-8.0.27-1.el9_1.x86_64
php-ldap-8.0.27-1.el9_1.x86_64 php-mbstring-8.0.27-1.el9_1.x86_64 php-mysqlnd-8.0.27-1.el9_1.x86_64
php-pdo-8.0.27-1.el9_1.x86_64 php-xml-8.0.27-1.el9_1.x86_64 redhat-logos-httpd-90.4-1.el9.noarch
unixODBC-2.3.9-4.el9.x86_64 zabbix-agent-6.4.13-release1.el9.x86_64 zabbix-apache-conf-6.4.13-release1.el9.noarch
zabbix-selinux-policy-6.4.13-release1.el9.x86_64 zabbix-server-mysql-6.4.13-release1.el9.x86_64 zabbix-sql-scripts-6.4.13-release1.el9.noarch
zabbix-web-6.4.13-release1.el9.noarch zabbix-web-deps-6.4.13-release1.el9.noarch zabbix-web-mysql-6.4.13-release1.el9.noarch

完毕!
[root@zabbix /]#

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

[root@zabbix ~]# zcat /usr/share/zabbix-sql-scripts/mysql/server.sql.gz | mysql --default-character-set=utf8mb4 -uzabbix -p zabbix
Enter password:
随后进入MySQL关闭log_bin_trust_function_creators 参数

[root@zabbix ~]# mysql -uroot -p1
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 12
Server version: 8.0.30 Source distribution

Copyright (c) 2000, 2022, Oracle and/or its affiliates.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> set global log_bin_trust_function_creators = 0;
Query OK, 0 rows affected (0.00 sec)

mysql>
mysql> quit
Bye
[root@zabbix ~]#

配置zabbix数据库

[root@zabbix ~]# vim /etc/zabbix/zabbix_server.conf
[root@zabbix ~]#
121 DBUser=zabbix
122
123 ### Option: DBPassword
124 # Database password.
125 # Comment this line if no password is used.
126 #
127 # Mandatory: no
128 # Default:
129 DBPassword=1
130

启动server和agent进程,并设置开机自启

[root@zabbix ~]# systemctl restart zabbix-server.service zabbix-agent.service httpd php-fpm.service
[root@zabbix ~]# systemctl enable zabbix-server.service zabbix-agent.service httpd php-fpm.service
Created symlink /etc/systemd/system/multi-user.target.wants/httpd.service → /usr/lib/systemd/system/httpd.service.
Created symlink /etc/systemd/system/multi-user.target.wants/php-fpm.service → /usr/lib/systemd/system/php-fpm.service.
[root@zabbix ~]#

浏览器访问 ip/zabbix 输入密码登录(mysql 创建的zabbix用户密码)
image.png

此处密码为创建zabbix用户的密码(我设置的“1”)

image.png

image.png

用户名为Admin 密码为zabbix
image.png

进入后页面如下
image.png

?

相关实践学习
基于CentOS快速搭建LAMP环境
本教程介绍如何搭建LAMP环境,其中LAMP分别代表Linux、Apache、MySQL和PHP。
全面了解阿里云能为你做什么
阿里云在全球各地部署高效节能的绿色数据中心,利用清洁计算为万物互联的新世界提供源源不断的能源动力,目前开服的区域包括中国(华北、华东、华南、香港)、新加坡、美国(美东、美西)、欧洲、中东、澳大利亚、日本。目前阿里云的产品涵盖弹性计算、数据库、存储与CDN、分析与搜索、云通信、网络、管理与监控、应用服务、互联网中间件、移动服务、视频服务等。通过本课程,来了解阿里云能够为你的业务带来哪些帮助     相关的阿里云产品:云服务器ECS 云服务器 ECS(Elastic Compute Service)是一种弹性可伸缩的计算服务,助您降低 IT 成本,提升运维效率,使您更专注于核心业务创新。产品详情: https://www.aliyun.com/product/ecs
目录
相关文章
|
监控 前端开发 NoSQL
Zabbix6.0下部署开源的Zabbix报表系统ZbxTable
Zabbix6.0下部署开源的Zabbix报表系统ZbxTable
1300 0
Zabbix6.0下部署开源的Zabbix报表系统ZbxTable
|
监控 关系型数据库 MySQL
CentOS7下部署开源监控平台Cacti(下)
CentOS7下部署开源监控平台Cacti(下)
576 0
CentOS7下部署开源监控平台Cacti(下)
|
监控 关系型数据库 MySQL
CentOS7下部署开源监控平台Cacti(上)
CentOS7下部署开源监控平台Cacti
487 0
CentOS7下部署开源监控平台Cacti(上)
|
存储 监控 前端开发
Zabbix4.2安装和4.0升级4.2笔记
Zabbix4.2安装和4.0升级4.2笔记
Zabbix4.2安装和4.0升级4.2笔记
|
Web App开发 关系型数据库 测试技术

推荐镜像

更多
http://www.vxiaotou.com