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
(10)检查配置
(11)配置数据库
(12)配置zabbix-server
(13)登录zabbix,用户名admin,密码zabbix
Zabbix使用
(1)创建主机
(2)配置Host
(3)查看新增Host。重复以上步骤添加103,104
(4)创建监控项
(5)配置监控项
(6)查看配置的监控项
(7)查看监控最新数据
(8)创建触发器
(9)创建动作
申请邮箱
(1)点击管理/报警媒介类型/Email
(2)编辑邮箱
(3)测试email
(4)email绑定邮件收件人
测试
(1)关闭集群中的HDFS,会有如下效果
[atguigu@hadoop102 hadoop-3.1.3]$ sbin/stop-dfs.sh
(2)查看邮件,接收故障信息
(3)查看仪表盘故障信息
上一篇: RDD、DataFrame和DataSet_大数据培训
下一篇: IDEA创建SparkSQL程序_大数据培训