Kafka-Eagle 监控
Kafka-Eagle 框架可以监控 Kafka 集群的整体运行情况,在生产环境中经常使用。
6.1 MySQL 环境准备
Kafka-Eagle 的安装依赖于 MySQL,MySQL 主要用来存储可视化展示的数据。如果集 群中之前安装过 MySQL 可以跨过该步。
6.2 Kafka 环境准备
1)关闭 Kafka 集群
[atguigu@hadoop102 scripts]$ sh kf.sh stop
--------停止 hadoop102 Kafka-------
--------停止 hadoop103 Kafka-------
--------停止 hadoop104 Kafka-------
2)修改/opt/module/kafka/bin/kafka-server-start.sh 命令中
修改如下参数值:
if [ "x$KAFKA_HEAP_OPTS" = "x" ]; then
export KAFKA_HEAP_OPTS="-Xmx1G -Xms1G"
fi
为
if [ "x$KAFKA_HEAP_OPTS" = "x" ]; then
export KAFKA_HEAP_OPTS="-server -Xms2G -Xmx2G -XX:PermSize=128m -XX:+UseG1GC -XX:MaxGCPauseMillis=200 -XX:ParallelGCThreads=8 -XX:ConcGCThreads=5 -XX:InitiatingHeapOccupancyPercent=70"
export JMX_PORT="9999"
# export KAFKA_HEAP_OPTS="-Xmx1G -Xms1G"
fi
注意:修改之后在启动 Kafka 之前要分发之其他节点
[atguigu@hadoop102 scripts]$ sh xsync.sh /opt/module/kafka/bin/kafka-server-start.sh
==================== hadoop102 ====================
sending incremental file list
sent 78 bytes received 12 bytes 180.00 bytes/sec
total size is 1,587 speedup is 17.63
==================== hadoop103 ====================
sending incremental file list
kafka-server-start.sh
sent 1,016 bytes received 47 bytes 708.67 bytes/sec
total size is 1,587 speedup is 1.49
==================== hadoop104 ====================
sending incremental file list
kafka-server-start.sh
sent 1,016 bytes received 47 bytes 2,126.00 bytes/sec
total size is 1,587 speedup is 1.49
6.3 Kafka-Eagle 安装
0)官网:https://www.kafka-eagle.org/
1)上传压缩包 kafka-eagle-bin-2.1.0.tar.gz 到集群/opt/software 目录
2)解压到本地
[atguigu@hadoop102 software]$ tar -zxvf kafka-eagle-bin-2.1.0.tar.gz
3)进入刚才解压的目录
[atguigu@hadoop102 kafka-eagle-bin-2.1.0]$ ll
总用量 81544
-rw-rw-r--. 1 atguigu atguigu 83499440 4月 3 13:28 efak-web-2.1.0-bin.tar.gz
4)将 efak-web-2.0.8-bin.tar.gz 解压至/opt/module
[atguigu@hadoop102 kafka-eagle-bin-2.1.0]$ tar -zxvf efak-web-2.1.0-bin.tar.gz -C /opt/module/
5)修改名称
[atguigu@hadoop102 module]$ mv efak-web-2.1.0/ efak
6)修改配置文件 /opt/module/efak/conf/system-config.properties
[atguigu@hadoop102 conf]$ vim system-config.properties
efak.zk.cluster.alias=cluster1
cluster1.zk.list=hadoop102:2181,hadoop103:2181,hadoop104:2181/kafka
# offset 保存在 kafka
cluster1.efak.offset.storage=kafka
# 配置 mysql 连接
efak.driver=com.mysql.jdbc.Driver
efak.url=jdbc:mysql://hadoop102:3306/ke?useUnicode=true&characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNull
efak.username=root
efak.password=000000
7)添加环境变量
[atguigu@hadoop102 conf]$ sudo vim /etc/profile.d/my_env.sh
# kafkaEFAK
export KE_HOME=/opt/module/efak
export PATH=$PATH:$KE_HOME/bin
注意:source /etc/profile
[atguigu@hadoop102 conf]$ source /etc/profile
8)启动
注意:启动之前需要先启动 ZK 以及 KAFKA。
(1)启动 efak
[atguigu@hadoop102 bin]$ sh ke.sh start
Welcome to
______ ______ ___ __ __
/ ____/ / ____/ / | / //_/
/ __/ / /_ / /| | / ,<
/ /___ / __/ / ___ | / /| |
/_____/ /_/ /_/ |_|/_/ |_|
( Eagle For Apache Kafka® )
Version 2.1.0 -- Copyright 2016-2022
*******************************************************************
* EFAK Service has started success.
* Welcome, Now you can visit 'http://192.168.10.102:8048'
* Account:admin ,Password:123456
*******************************************************************
* <Usage> ke.sh [start|status|stop|restart|stats] </Usage>
* <Usage> https://www.kafka-eagle.org/ </Usage>
*******************************************************************
6.4 Kafka-Eagle 页面操作
1)登录页面查看监控数据