首页 > 其他分享 >zabbix监控搭建(基础)

zabbix监控搭建(基础)

时间:2024-08-09 13:53:50浏览次数:10  
标签:... Zabbix etc zabbix 监控 MariaDB root 搭建

一、Zabbix介绍

Zabbix是一个监控系统,它可以帮助我们实时检查设备的状态,比如服务器、网络设备等。当设备出现问题时,它会及时通知我们,让我们可以采取措施来解决。同时,它还可以把收集到的数据转化成图表和报告,让我们更直观地了解设备的运行情况

1、监控的作用

任何你所想要监控的数据, 如cpu负载,cpu的idle时间,内存使用量,内存利用率,io,network等等。
现在很多开源监控方案已经把常见的监控做成了模板,我们可以直接套用
大型公司会有更多的监控需求, 那么就需要专业的开发人员来做监控开发(运维人员也可以开发)

2、zabbix特性

数据采集

Zabbix Agent方式会定期收集设备的各种指标数据,比如CPU使用率、内存占用、网络流量等。这些数据会被Zabbix Server主动获取。

触发检测告警

Zabbix会根据我们事先设定的阈值和触发条件,对采集到的数据进行检测。如果某个指标超过了阈值或满足了触发条件,Zabbix会触发一个告警。Zabbix会根据事先设置的通知方式,比如邮件、短信等,通知相关的人员或团队。这样我们可以及时知道设备出现了问题。

数据存储

Zabbix将采集到的数据存储在数据库中

数据展示

Zabbix提供了丰富的可视化功能,可以将采集到的数据转化成各种图表和报表。这样我们可以直观地了解设备的运行状态和趋势。

3、zabbix结构

在这里插入图片描述
Zabbix-server:收集监控数据,计算是否满足触发条件,向用户发送通知

Zabbix-database:所有配置信息和Zabbix收集到的数据都被存储在数据库中

Zabbix-Web:为了在任何地方和任何平台都能轻松地访问Zabbix,Zabbix提供了基于Web的界面。该界面是Zabbix Server的一部分,通常跟Zabbix Server运行在同一台物理机器上。

Zabbix-proxy:Zabbix Proxy可以替Zabbix Server收集性能和可用性数据。Proxy代理服务器是Zabbix 软件可选择部署的一部分。当然,Proxy代理服务器可以帮助单台Zabbix Server分担负载压力。

Zabbix-agent:Zabbix Agents监控代理部署在监控目标上,主动监控本地资源和应用(硬件驱动,内存等)

4、主流的开源监控平台介绍

mrtg (Multi Router Traffic Grapher)

通过snmp协议得到设备的流量信息,并以包含PNG格式的图形的HTML文档方式显示给用户。

cacti (仙人掌)

用php语言实现的一个软件,它的主要功能是用snmp服务获取数据,然后用rrdtool储存和更新数据。官网地址:https://www.cacti.net/

ntop

官网地址: https://www.ntop.org/

nagios

能够跨平台,插件多,报警功能强大。官网地址:https://www.nagios.org/

centreon

底层使用的就是nagios。是一个nagios整合版软件。官网地址:https://www.centreon.

ganglia

设计用于测量数以千计的节点,资源消耗非常小。官网地址:http://ganglia.info/

open-falcon

小米公司开源,高效率,高可用。用户基数相对小。官网地址:http://open-falcon.org/

zabbix

跨平台,画图,多条件告警,多种API接口。用户基数大。官网地址:https://www.zabbix.com/

prometheus

基于时间序列的数值数据的容器监控解决方案。官网地址:https://prometheus.io

二、安装zabbix

环境:rocky Linux 9虚拟机一台,selinux与firewalld均已关闭,使用Xshell连接

1、安装工具包

[root@zabbix ~]# yum -y install lrzsz tar net-tools chrony 
//时钟同步
[root@zabbix ~]# systemctl restart chronyd
[root@zabbix ~]# systemctl enable chronyd
[root@zabbix ~]# hwclock -w

2、配置zabbix源

//将包文件直接拖进来
[root@zabbix ~]# rz -E
rz waiting to receive.
[root@zabbix ~]# ls
anaconda-ks.cfg  zabbix-release-7.0-2.el9.noarch.rpm
[root@zabbix ~]# rpm -Uvh zabbix-release-7.0-2.el9.noarch.rpm 
warning: zabbix-release-7.0-2.el9.noarch.rpm: Header V4 RSA/SHA512 Signature, key ID b5333005: NOKEY
Verifying...                          ################################# [100%]
Preparing...                          ################################# [100%]
Updating / installing...
   1:zabbix-release-7.0-2.el9         ################################# [100%]

将zabbix的源换成阿里源
[root@zabbix ~]# vim /etc/yum.repos.d/zabbix.repo
//将该文件内容替换为以下内容
[zabbix]
name=Zabbix Official Repository - $basearch
baseurl=https://mirrors.aliyun.com/zabbix/zabbix/7.0/rocky/9/$basearch/
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX-B5333005

[zabbix-non-supported]
name=Zabbix Official Repository non-supported - $basearch
baseurl=https://mirrors.aliyun.com/zabbix/non-supported/rhel/9/$basearch/
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX-08EFA7DD
gpgcheck=1

[zabbix-sources]
name=Zabbix Official Repository source code - $basearch
baseurl=https://repo.zabbix.com/zabbix/7.0/rocky/9/SRPMS
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX-B5333005
gpgcheck=1

在epel源后面添加一行
[root@zabbix ~]# vim /etc/yum.repos.d/epel.repo 
//在[epel]这个标签的末尾加上一行信息,否则安装会报错
[epel]
......
excludepkgs=zabbix*

3、安装zabbix、web前端、agent、数据库包文件

[root@zabbix ~]# yum install zabbix-server-mysql zabbix-web-mysql zabbix-nginx-conf zabbix-sql-scripts zabbix-selinux-policy zabbix-agent mariadb-server mariadb -y

4、启动并初始化数据库

//启动数据库
[root@zabbix ~]# systemctl restart mariadb
[root@zabbix ~]# systemctl enable mariadb
//初始化数据库
[root@zabbix ~]# 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
haven't set the root password yet, you should just press enter here.

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

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

You already have your root account protected, so you can safely answer 'n'.

Switch to unix_socket authentication [Y/n] y
Enabled successfully!
Reloading privilege tables..
 ... Success!


You already have your root account protected, so you can safely answer 'n'.

Change the 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!

5、配置数据库并导入zabbix表数据

[root@zabbix ~]# mysql -uroot -predhat
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 12
Server version: 10.5.22-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 utf8mb4 collate utf8mb4_bin;
Query OK, 1 row affected (0.000 sec)

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

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

MariaDB [(none)]> set global log_bin_trust_function_creators = 1;
Query OK, 0 rows affected (0.000 sec)

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

MariaDB [(none)]> exit
Bye

[root@zabbix ~]# zcat /usr/share/zabbix-sql-scripts/mysql/server.sql.gz | mysql --default-character-set=utf8mb4 -uzabbix -p zabbix
Enter password: //这里输入数据库密码

6、导入数据库架构后禁用log_bin_trust_function_creators选项

[root@zabbix ~]# myaql -uroot -predhat
bash: myaql: command not found
[root@zabbix ~]# mysql -uroot -predhat
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 14
Server version: 10.5.22-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)]> set global log_bin_trust_function_creators = 0;
Query OK, 0 rows affected (0.000 sec)

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

MariaDB [(none)]> exit
Bye

7、配置zabbix并启动服务

[root@zabbix ~]# vim /etc/zabbix/zabbix_server.conf
//找到并修改以下内容,内容一样的去掉#
//内容不一样就修改并去掉#
ListenPort=10051        
DBHost=localhost 
DBName=zabbix 
DBUser=zabbix 
DBPassword=redhat              
DBSocket=/var/lib/mysql/mysql.sock 
ListenIP=0.0.0.0 

8、zabbix配置启动服务—浏览器访问

//编辑配置文件 /etc/nginx/conf.d/zabbix.conf 取消注释并设置“listen”和“server_name”指令
[root@zabbix ~]# vim /etc/nginx/conf.d/zabbix.conf 
        listen          8080;
        server_name     example.com;


//启动以下服务并enable
[root@zabbix ~]# systemctl restart zabbix-server zabbix-agent nginx php-fpm
[root@zabbix ~]# systemctl enable zabbix-server zabbix-agent nginx php-fpm

//浏览器访问http://192.168.100.115:8080/setup.php
注:ip换成自己的
在这里插入图片描述

9、解决支持中文

[root@zabbix ~]# yum -y install langpacks-zh_CN.noarch glibc-common
[root@zabbix ~]#  locale -a | grep zh_CN
zh_CN
zh_CN.gb18030
zh_CN.gbk
zh_CN.utf8

然后刷新浏览器

10、设置浏览器界面

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

下一步再接完成就配置好了,就可以进入登陆界面了

默认账号为Admin,密码为zabbix
在这里插入图片描述

11、解决中午乱码问题

找到windows下的简体 楷体 常规字体
C:\Windows\Fonts
将简体 楷体 常规字体文件复制出来上传到Linux系统中的/usr/share/zabbix/assets/fonts
替换原先的字体文件即可

[root@zabbix ~]# cd /usr/share/zabbix/assets/fonts/
[root@zabbix fonts]# rz -E
rz waiting to receive.
[root@zabbix fonts]# ls
graphfont.ttf  SIMKAI.TTF  zabbix-icons.svg  zabbix-icons.ttf  zabbix-icons.woff  zabbix-icons.woff2
[root@zabbix fonts]# mv SIMKAI.TTF graphfont.ttf
mv: overwrite 'graphfont.ttf'? y

12、监控远程主机

//新开一台虚拟机

[root@node6 ~]# rz -E
rz waiting to receive.  //将包文件拖进来
[root@node6 ~]#  rpm -Uvh zabbix-release-7.0-2.el9.noarch.rpm
warning: zabbix-release-7.0-2.el9.noarch.rpm: Header V4 RSA/SHA512 Signature, key ID b5333005: NOKEY
Verifying...                          ################################# [100%]
Preparing...                          ################################# [100%]
Updating / installing...
   1:zabbix-release-7.0-2.el9         ################################# [100%]
[root@node6 ~]# vim /etc/yum.repos.d/zabbix.repo 

[zabbix]
name=Zabbix Official Repository - $basearch
baseurl=https://mirrors.aliyun.com/zabbix/zabbix/7.0/rocky/9/$basearch/
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX-B5333005

[zabbix-non-supported]
name=Zabbix Official Repository non-supported - $basearch
baseurl=https://mirrors.aliyun.com/zabbix/non-supported/rhel/9/$basearch/
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX-08EFA7DD
gpgcheck=1

[zabbix-sources]
name=Zabbix Official Repository source code - $basearch
baseurl=https://repo.zabbix.com/zabbix/7.0/rocky/9/SRPMS
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX-B5333005
gpgcheck=1

[root@node6 ~]# vim /etc/yum.repos.d/epel.repo 
[epel]
......//在epel源后面添加一行
excludepkgs=zabbix*

[root@node6 ~]# yum -y install zabbix-agent chrony lazsz net-tools
[root@node6 ~]# systemctl restart chronyd
[root@node6 ~]# systemctl enable chronyd
[root@node6 ~]# hwclock -w

[root@node6 ~]# vim /etc/zabbix/zabbix_agentd.conf 
Server=192.168.100.40 				zabbix服务器的IP,agent被动监控(默认模式) 
ServerActive=192.168.100.40 			zabbix服务器的IP,agent主动监控 
Hostname=zabbix-agent 				zabbix服务器的主机名

[root@node6 ~]# systemctl restart zabbix-agent
[root@node6 ~]# systemctl enable zabbix-agent

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
完成

标签:...,Zabbix,etc,zabbix,监控,MariaDB,root,搭建
From: https://blog.csdn.net/q911326/article/details/141033775

相关文章

  • 公交车辆4G无线视频监控系统统一接入应用解决方案
    目录一、背景二、应用对象三、应用目的四、系统组成五、安装位置5.1、摄像机位置5.2、摄像机选型5.3、录像机选型六、监控中心设计6.1 中心服务器6.2媒体服务器6.3数据通道七、车载系统设计7.1网络示意图7.2车载录像监控八、数据备份九、视频效果一......
  • docker搭建本地仓库
    环境准备:服务器:9.134.130.35私有仓库服务器,运行registry容器客户端:9.208.244.175测试客户端,用于上传、下载镜像文件测试搭建本地仓库mkdir/docker/registry-p--创建主机目录dockerrun-itd-v/docker/registry/:/docker/registry-p5000:5000--restart=always--......
  • 医院定位导航系统:基于iBeacon技术实现医疗环境的智能化监控与人员安全预警
    在追求高效、安全、人性化的医疗服务背景下,医院定位导航系统成为医院智慧化建设的重要基石。该系统不仅集成了高精度的定位技术,还融合了人员定位、安全预警等多元化功能,为医院管理、患者就医及医护人员工作提供了全方位的支持。基于蓝牙iBeacon技术的院内定位蓝牙iBeacon技术......
  • 五,搭建环境:辅助功能
    五,搭建环境:辅助功能@目录五,搭建环境:辅助功能编写登录失败异常编写常量类MD5工具(加密工具类)日志配置文件编写登录失败异常我们在demo-module04-util模块下,创建一个名为:com.rainbowsea.imperial.court.exception的包下,创建一个名为:LoginFailedException的异常类——>作......
  • 玩转usbserver(五)之usbserver加入zabbix集中监控
     一、把usbserver加入到zabbix监控平台问:可以监控那些东西答:主要是端口监控,连接断开了可以及时报警、网络断开了也可以报警....二、如何配置(你把那两个模版导入,照图配置一下主机资源即可)zbx_export_hosts.yamlzabbix_export:version:'6.2'date:'2024-05-30T......
  • 快速基于 ClickHouse + Grafana 搭建可观测性解决方案 - 分布式链路追踪篇(ClickHouse
    引言在ClickHouse,我们认为可观测性仅仅是另一个实时分析问题。作为一款高性能的实时分析数据库,ClickHouse被用于多种场景,包括时间序列数据的实时分析。其应用场景的多样性推动了大量分析函数的发展,这些函数有助于查询大多数数据类型。这些查询特性和高压缩率使得越来越多的用户......
  • Thinkphp框架盲盒app源码搭建+付费进群源码交友合体设计开发
    本文将详细介绍盲盒App的源码设计与搭建过程,涵盖从需求分析、技术选型、环境准备到开发、测试、上线的全流程。源码:m.ymzan.top一、需求分析在搭建盲盒App之前,首先需要明确应用的核心需求。盲盒App的核心功能通常包括用户管理、商品管理、订单处理、支付系......
  • typeScript学习之环境搭建
    ^_^--今天来介绍一下运行typeScript代码需要的环境------->    下面是需要安装的软件和环境以及安装过程中遇到的问题,win10、win11系统下载最新或者稳定版的软件就可以,因为我使用的是win7系统,很多软件不支持或对win7系统的版本不再维护,尝试了很多次找到合适的对应版本一......
  • 搭建时空基底,建设“数字之城”
    在这个日新月异的时代,数字技术正以前所未有的速度重塑我们的世界。今天,让我们一同深入探讨如何通过搭建时空基底,为“数字之城”的建设奠定坚实基础。一、时空基底:数字之城的骨骼与脉络所谓“时空基底”,是指结合时间维度与空间维度的综合性信息框架,它是构建数字城......
  • Flink 实时数仓(十)【DWS 层搭建(四)交易域汇总表创建】
    前言    今天完成DWS层交易域剩下的两个指标,估计一早上就完了,这两个需求用到的知识点和昨天的需求差不多;1、交易域省份粒度下单各窗口汇总表1.1、思路分析        这个需求是比较简单的,province_id字段是订单表中的字段,在DWD层的下单事务事实表中我们......