简介
kafka eagle(kafka鹰) 是一款由国内公司开源的Kafka集群监控系统,可以用来监视kafka集群的broker状态、Topic信息、IO、内存、consumer线程、偏移量等信息,并进行可视化图表展示。独特的KQL还可以通过SQL在线查询kafka中的数据。
官网地址 https://www.kafka-eagle.org/
github地址:https://github.com/smartloli/kafka-eagle
下载
下载地址http://download.kafka-eagle.org/
本文安装的是2.0.5版本,支持Kafka版本0.8,0.9.x,0.10.x,0.11.x,1.x,2.x
wget https://github.com/smartloli/kafka-eagle-bin/archive/v2.0.5.tar.gz
安装
tar -zvxf v2.0.5.tar.gz
cd kafka-eagle-bin-2.0.5/
tar -zxvf kafka-eagle-web-2.0.5-bin.tar.gz -C /opt/bd/
cd ../
mv kafka-eagle-web-2.0.5 kafka-eagle
创建mysql数据库ke 用来储存元数据
MySQL > create database ke;
设置环境变量
vim /etc/profile
export KE_HOME=/opt/bd/kafka-eagle
export PATH=$PATH:$KE_HOME/bin
source /etc/profile
基本设置
修改配置文件
cd ${KE_HOME}/conf
vim system-config.properties
配置zookeeper地址
kafka.eagle.zk.cluster.alias=cluster1
cluster1.zk.list=tdn1:2181,tdn2:2181,tdn3:2181/kafka
重要提示
此处示例的kafka是2.4版本 所以zookeeper地址后加上 /kafka, 如果不清楚版本,建议复制kafka配置文件的zookeeper配置(CDH6.3.x及以下不需要加)
mysql 8.0 在当前版本使用中会有问题
配置Mysql
注释掉sqlite jdbc driver address 修改mysql jdbc driver address 改成自己的MySQL密码
kafka.eagle.driver=com.mysql.cj.jdbc.Driver
kafka.eagle.url=jdbc:mysql://127.0.0.1:3306/ke?useUnicode=true&characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNull
#Mysql密码
kafka.eagle.username=root
kafka.eagle.password=123456
开启JMX监控
eagle通过jmx收集一些指标,在使用jmx之前需要确保kafka开启了jmx监控
Apache版本:
开启方法1:kafka启动时要添加JMX_PORT=9999
开启方法2:vim bin/kafka-server-start.sh
...
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"
fi
CDH
修改每个broker节点的broker_java_opts:
-server -XX:+UseG1GC -XX:MaxGCPauseMillis=20 -XX:InitiatingHeapOccupancyPercent=35 -XX:G1HeapRegionSize=16M -XX:MinMetaspaceFreeRatio=50 -XX:MaxMetaspaceFreeRatio=80 -XX:+DisableExplicitGC -Djava.awt.headless=true -Djava.net.preferIPv4Stack=true -Dcom.sun.management.jmxremote=true
其他可选设置 (普通用户忽略,保持默认即可)
如果Kafka开启了安全认证如则需要修改sasl设置
cluster1.kafka.eagle.sasl.enable=true
cluster1.kafka.eagle.sasl.protocol=SASL_PLAINTEXT
cluster1.kafka.eagle.sasl.mechanism=GSSAPI
cluster1.kafka.eagle.sasl.jaas.config=com.sun.security.auth.module.Krb5LoginModule required useKeyTab=true storeKey=true keyTab="/etc/security/keytabs/kafka_client.keytab" principal="[email protected]";
# make sure there is a local ticket cache "klist -l" to view
# cluster1.kafka.eagle.sasl.jaas.config=com.sun.security.auth.module.Krb5LoginModule required useTicketCache=true renewTicket=true serviceName="kafka-eagle.org";
# if your kafka cluster doesn't require it, you don't need to set it up
# cluster1.kafka.eagle.sasl.client.id=
如果开启了zookeeper acl认证 需要修改以下配置
# Add zookeeper acl
cluster1.zk.acl.enable=true
cluster1.zk.acl.schema=digest
cluster1.zk.acl.username=test
cluster1.zk.acl.password=test123
kafka 如果开启了acl ssl 需要修改配置
######################################
# kafka jmx acl and ssl authenticate
######################################
cluster1.kafka.eagle.jmx.acl=true
cluster1.kafka.eagle.jmx.user=keadmin
cluster1.kafka.eagle.jmx.password=keadmin123
cluster1.kafka.eagle.jmx.ssl=false
cluster1.kafka.eagle.jmx.truststore.location=/Users/dengjie/workspace/ssl/certificates/kafka.truststore
cluster1.kafka.eagle.jmx.truststore.password=ke123456
######################################
kafka jmx uri(建议保持默认)
cluster1.kafka.eagle.jmx.uri=service:jmx:rmi:///jndi/rmi://%s/jmxrmi
启动
$KE_HOME/bin/ke.sh start
进度条100%后会出现启动成功界面,端口默认8048
输入密码 admin/123456 登录即可
其他命令
$KE_HOME/bin/ke.sh [start|status|stop|restart|stats]
TIP
可以设置域名让浏览器缓存js文件,大大提高加载速度。