集群监控利器之Zabbix

发布时间:2021年08月13日作者:atguigu浏览次数:234

Zabbix概述

Zabbix是一款能够监控各种网络参数以及服务器健康性和完整性的软件。Zabbix使用灵活的通知机制,允许用户为几乎任何事件配置基于邮件的告警。这样可以快速反馈服务器的问题。基于已存储的数据,Zabbix提供了出色的报告和数据可视化功能。

集群监控利器之Zabbix

 

Zabbix部署

进程

hadoop102节点

 

hadoop103节点

hadoop104节点

zabbix-agent

 

zabbix-server

     

MySQL

     

zabbix-web

     

(1)准备工作,关闭集群

如果集群开启,先关闭集群。因为安装完毕Zabbix后,需要重启虚拟机。

[atguigu@hadoop102 ~]$ cluster.sh stop

关闭防火墙(3台节点,已关闭)

[atguigu@hadoop102 ~]$ sudo service iptables stop
[atguigu@hadoop102 ~]$ sudo chkconfig iptables off


[atguigu@hadoop103 ~]$ sudo service iptables stop
[atguigu@hadoop103 ~]$ sudo chkconfig iptables off


[atguigu@hadoop104 ~]$ sudo service iptables stop
[atguigu@hadoop104 ~]$ sudo chkconfig iptables off

(2)关闭防火墙

[atguigu@hadoop102 ~]$ sudo service iptables stop
[atguigu@hadoop102 ~]$ sudo chkconfig iptables off


[atguigu@hadoop103 ~]$ sudo service iptables stop
[atguigu@hadoop103 ~]$ sudo chkconfig iptables off


[atguigu@hadoop104 ~]$ sudo service iptables stop
[atguigu@hadoop104 ~]$ sudo chkconfig iptables of

(3)关闭SELinux

[atguigu@hadoop102 ~]$ sudo vim /etc/selinux/config
# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
#     enforcing - SELinux security policy is enforced.
#     permissive - SELinux prints warnings instead of enforcing.
#     disabled - No SELinux policy is loaded.
SELINUX=disabled
# SELINUXTYPE= can take one of these two values:
#     targeted - Targeted processes are protected,
#     mls - Multi Level Security protection.
SELINUXTYPE=targeted

(4)重启服务器

[atguigu@hadoop102 ~]$  sudo reboot

配置yum源

(1)从阿里云镜像中下载zabbix安装包,并执行安装命令。

[atguigu@hadoop102 ~]$ sudo rpm -ivh https://mirrors.aliyun.com/zabbix/zabbix/4.4/rhel/7/x86_64/zabbix-release-4.4-1.el7.noarch.rpm


[atguigu@hadoop103 ~]$ sudo rpm -ivh https://mirrors.aliyun.com/zabbix/zabbix/4.4/rhel/7/x86_64/zabbix-release-4.4-1.el7.noarch.rpm


[atguigu@hadoop104 ~]$ sudo rpm -ivh https://mirrors.aliyun.com/zabbix/zabbix/4.4/rhel/7/x86_64/zabbix-release-4.4-1.el7.noarch.rpm

(2)修改阿里云镜像101,102,103三台节点,依次执行以下步骤

[atguigu@hadoop102 ~]$ sudo cat /etc/yum.repos.d/zabbix.repo

查看内容如下

[zabbix]
name=Zabbix Official Repository - $basearch
baseurl=http://repo.zabbix.com/zabbix/4.4/rhel/7/$basearch/
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX-A14FE591


[zabbix-debuginfo]
name=Zabbix Official Repository debuginfo - $basearch
baseurl=http://repo.zabbix.com/zabbix/4.4/rhel/7/$basearch/debuginfo/
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX-A14FE591
gpgcheck=1


[zabbix-non-supported]
name=Zabbix Official Repository non-supported - $basearch
baseurl=http://repo.zabbix.com/non-supported/rhel/7/$basearch/
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX
gpgcheck=1

(3)执行以下命令完成全局替换

[atguigu@hadoop102 ~]$ sudo sed -i 's/http:\/\/repo.zabbix.com/https:\/\/mirrors.aliyun.com\/zabbix/g' /etc/yum.repos.d/zabbix.repo

(4)查看修改后的zabbix.repo文件

[atguigu@hadoop102 ~]$ sudo cat /etc/yum.repos.d/zabbix.repo


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


[zabbix-debuginfo]
name=Zabbix Official Repository debuginfo - $basearch
baseurl=https://mirrors.aliyun.com/zabbix/zabbix/4.4/rhel/7/$basearch/debuginfo/
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX-A14FE591
gpgcheck=1


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

安装Zabbix

(1)在hadoop102、hadoop103、hadoop104三台节点分别执行以下安装命令

[atguigu@hadoop102 ~]$ sudo yum install zabbix-server-mysql zabbix-web-mysql zabbix-agent
[atguigu@hadoop103 ~]$ sudo yum install zabbix-agent
[atguigu@hadoop104 ~]$ sudo yum install zabbix-agent

(2)创建Zabbix

[atguigu@hadoop102 ~]$ mysql -uroot -p000000 -e"create database zabbix character set utf8 collate utf8_bin"

(3)导入Zabbix建表语句

[atguigu@hadoop102 ~]$ zcat /usr/share/doc/zabbix-server-mysql-4.4.10/create.sql.gz | mysql -uroot -p000000 zabbix

(4)配置Zabbix_Server(hadoop102)

[atguigu@hadoop102 ~]$ sudo vim /etc/zabbix/zabbix_server.conf
DBHost=hadoop102
DBName=zabbix
DBUser=root
DBPassword=000000

(5)配置Zabbix_Agent(三台节点)

[atguigu@hadoop102 ~]$ sudo vim /etc/zabbix/zabbix_agentd.conf
Server=hadoop102
#ServerActive=127.0.0.1
#Hostname=Zabbix server

(6)配置Zabbix_Web时区

[atguigu@hadoop102 ~]$ sudo vim /etc/httpd/conf.d/zabbix.conf
#
# Zabbix monitoring system php web frontend
#
Alias /zabbix /usr/share/zabbix
<Directory "/usr/share/zabbix">
    Options FollowSymLinks
    AllowOverride None
    Require all granted


    <IfModule mod_php5.c>
        php_value max_execution_time 300
        php_value memory_limit 128M
        php_value post_max_size 16M
        php_value upload_max_filesize 2M
        php_value max_input_time 300
        php_value max_input_vars 10000
        php_value always_populate_raw_post_data -1
        php_value date.timezone Asia/Shanghai
    </IfModule>
</Directory>

(7)启动zabbix

[atguigu@hadoop102 ~]$ sudo systemctl start zabbix-server zabbix-agent httpd
[atguigu@hadoop102 ~]$ sudo systemctl enable zabbix-server zabbix-agent httpd


[atguigu@hadoop103 ~]$ sudo systemctl start zabbix-agent
[atguigu@hadoop103 ~]$ sudo systemctl enable zabbix-agent


[atguigu@hadoop104 ~]$ sudo systemctl start zabbix-agent
[atguigu@hadoop104 ~]$ sudo systemctl enable zabbix-agent

(8)停止zabbix

[atguigu@hadoop102 ~]$ sudo systemctl stop zabbix-server zabbix-agent httpd
[atguigu@hadoop102 ~]$ sudo systemctl disable zabbix-server zabbix-agent httpd


[atguigu@hadoop103 ~]$ sudo systemctl stop zabbix-agent
[atguigu@hadoop103 ~]$ sudo systemctl disable zabbix-agent


[atguigu@hadoop104 ~]$ sudo systemctl stop zabbix-agent
[atguigu@hadoop104 ~]$ sudo systemctl disable zabbix-agent

(9)连接zabbix_web数据库。访问http://hadoop102/zabbix

集群监控利器之Zabbix

 

(10)检查配置

集群监控利器之Zabbix

 

(11)配置数据库

集群监控利器之Zabbix

 

(12)配置zabbix-server

集群监控利器之Zabbix

 

集群监控利器之Zabbix

 

(13)登录zabbix,用户名admin,密码zabbix

集群监控利器之Zabbix

 

集群监控利器之Zabbix

 

集群监控利器之Zabbix

 

集群监控利器之Zabbix

 

Zabbix使用

(1)创建主机

集群监控利器之Zabbix

 

(2)配置Host

集群监控利器之Zabbix

 

(3)查看新增Host。重复以上步骤添加103,104

集群监控利器之Zabbix

 

集群监控利器之Zabbix

 

(4)创建监控项

集群监控利器之Zabbix

 

集群监控利器之Zabbix

 

(5)配置监控项

集群监控利器之Zabbix

 

集群监控利器之Zabbix

 

(6)查看配置的监控项

集群监控利器之Zabbix

 

(7)查看监控最新数据

集群监控利器之Zabbix

 

(8)创建触发器

集群监控利器之Zabbix

 

集群监控利器之Zabbix

 

集群监控利器之Zabbix

 

集群监控利器之Zabbix

 

集群监控利器之Zabbix

 

(9)创建动作

集群监控利器之Zabbix

 

集群监控利器之Zabbix

 

集群监控利器之Zabbix

 

集群监控利器之Zabbix

 

集群监控利器之Zabbix

 

集群监控利器之Zabbix

 

集群监控利器之Zabbix

 

集群监控利器之Zabbix

 

申请邮箱

(1)点击管理/报警媒介类型/Email

集群监控利器之Zabbix

 

(2)编辑邮箱

集群监控利器之Zabbix

 

(3)测试email

集群监控利器之Zabbix

 

(4)email绑定邮件收件人

集群监控利器之Zabbix

 

集群监控利器之Zabbix

 

测试

(1)关闭集群中的HDFS,会有如下效果

[atguigu@hadoop102 hadoop-3.1.3]$ sbin/stop-dfs.sh

(2)查看邮件,接收故障信息

集群监控利器之Zabbix

 

(3)查看仪表盘故障信息

集群监控利器之Zabbix
想要了解跟多关于大数据培训课程内容欢迎关注尚硅谷大数据培训,尚硅谷除了这些技术文章外还有免费的高质量大数据培训课程视频供广大学员下载学习。

上一篇:
下一篇:
相关课程

java培训 大数据培训 前端培训 UI/UE设计培训

关于尚硅谷
教育理念
名师团队
学员心声
资源下载
视频下载
资料下载
工具下载
加入我们
招聘岗位
岗位介绍
招贤纳师
联系我们
全国统一咨询电话:010-56253825
地址:北京市昌平区宏福科技园2号楼3层(北京校区)

深圳市宝安区西部硅谷大厦B座C区一层(深圳校区)

上海市松江区谷阳北路166号大江商厦6层(上海校区)

武汉市东湖高新开发区东湖网谷(武汉校区)

西安市雁塔区和发智能大厦B座3层(西安校区)