一、背景

上一节中,我们搭建了一个kafka集群,但是kafka集群在运行的过程中会产生各种数据,比如broker信息、集群信息、主题信息、消费者信息等等,而kafka自身没有提供一个图形化的监控界面,此处我们使用kafka-eagle来搭建一个kafka的管理监控界面。

二 、mac上安装kafka-eagle

1、安装JDK

2、安装eagle

1、下载eagle

kafka-eagle监控界面的搭建_kafka-eagle

2、解压并配置环境变量

1、解压

tar -zxvf kafka-eagle-bin-2.0.3.tar.gz && cd kafka-eagle-bin-2.0.3 && tar -zxvf kafka-eagle-web-2.0.3-bin.tar.gz复制代码

2、重命名

mv kafka-eagle-web-2.0.3 kafka-eagle  
复制代码

3、配置环境变量

vim /etc/profile
export KE_HOME=/Users/huan/soft/kafka/kafka-eagle
export PATH=$PATH:$KE_HOME/bin

source /etc/profile
cd ${KE_HOME}/bin
chomd +x ke.sh复制代码

KE_HOME 为eagle环境变量的名字。

3、启用kafka的JMX

此配置是可选的,放开可以看到更多的监控信息。 1、cd ${KAFKA_HOME}/bin 2、vim kafka-server-start.sh

if [ "x$KAFKA_HEAP_OPTS" = "x" ]; then
    # export KAFKA_HEAP_OPTS="-Xmx1G -Xms1G"
    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="9099"
fi复制代码

JMX_PORT 的端口可以给个没有占用的端口既可。

4、配置eagle

1、cd ${KE_HOME}/conf
2、vim system-config.properties

####################################### multi zookeeper & kafka cluster list# 设置kafka的多集群,此处只需要给zk的地址既可######################################kafka.eagle.zk.cluster.alias=cluster1cluster1.zk.list=localhost:2181,localhost:3181,localhost:4181####################################### zookeeper enable acl######################################cluster1.zk.acl.enable=falsecluster1.zk.acl.schema=digestcluster1.zk.acl.username=testcluster1.zk.acl.password=test123####################################### broker size online list######################################cluster1.kafka.eagle.broker.size=20####################################### zk client thread limit######################################kafka.zk.limit.size=25####################################### kafka eagle webui port# kafka eagle 的前端访问端口######################################kafka.eagle.webui.port=9090####################################### kafka jmx acl and ssl authenticate######################################cluster1.kafka.eagle.jmx.acl=falsecluster1.kafka.eagle.jmx.user=keadmincluster1.kafka.eagle.jmx.password=keadmin123cluster1.kafka.eagle.jmx.ssl=falsecluster1.kafka.eagle.jmx.truststore.location=/Users/dengjie/workspace/ssl/certificates/kafka.truststorecluster1.kafka.eagle.jmx.truststore.password=ke123456####################################### kafka offset storage# kafka集群的offset保存的位置,0.10及以后的kafka集群是保存在kafka中,之前的是保存在zookeeper中######################################cluster1.kafka.eagle.offset.storage=kafka####################################### kafka metrics, 15 days by default# 开启性能监控,数据默认保存的天数######################################kafka.eagle.metrics.charts=truekafka.eagle.metrics.retain=15####################################### kafka sql topic records max######################################kafka.eagle.sql.topic.records.max=5000####################################### delete kafka topic token# 删除kafka topic 时,需要输入的token值######################################kafka.eagle.topic.token=keadmin####################################### kafka sasl authenticate######################################cluster1.kafka.eagle.sasl.enable=falsecluster1.kafka.eagle.sasl.protocol=SASL_PLAINTEXTcluster1.kafka.eagle.sasl.mechanism=SCRAM-SHA-256cluster1.kafka.eagle.sasl.jaas.config=org.apache.kafka.common.security.scram.ScramLoginModule required username="kafka" password="kafka-eagle";cluster1.kafka.eagle.sasl.client.id=cluster1.kafka.eagle.blacklist.topics=cluster1.kafka.eagle.sasl.cgroup.enable=falsecluster1.kafka.eagle.sasl.cgroup.topics=cluster2.kafka.eagle.sasl.enable=falsecluster2.kafka.eagle.sasl.protocol=SASL_PLAINTEXTcluster2.kafka.eagle.sasl.mechanism=PLAINcluster2.kafka.eagle.sasl.jaas.config=org.apache.kafka.common.security.plain.PlainLoginModule required username="kafka" password="kafka-eagle";cluster2.kafka.eagle.sasl.client.id=cluster2.kafka.eagle.blacklist.topics=cluster2.kafka.eagle.sasl.cgroup.enable=falsecluster2.kafka.eagle.sasl.cgroup.topics=####################################### kafka ssl authenticate######################################cluster3.kafka.eagle.ssl.enable=falsecluster3.kafka.eagle.ssl.protocol=SSLcluster3.kafka.eagle.ssl.truststore.location=cluster3.kafka.eagle.ssl.truststore.password=cluster3.kafka.eagle.ssl.keystore.location=cluster3.kafka.eagle.ssl.keystore.password=cluster3.kafka.eagle.ssl.key.password=cluster3.kafka.eagle.blacklist.topics=cluster3.kafka.eagle.ssl.cgroup.enable=falsecluster3.kafka.eagle.ssl.cgroup.topics=####################################### kafka sqlite jdbc driver address#######################################kafka.eagle.driver=org.sqlite.JDBC#kafka.eagle.url=jdbc:sqlite:/hadoop/kafka-eagle/db/ke.db#kafka.eagle.username=root#kafka.eagle.password=www.kafka-eagle.org####################################### kafka mysql jdbc driver address# eagle数据保存的数据库,此处使用mysql######################################kafka.eagle.driver=com.mysql.jdbc.Driverkafka.eagle.url=jdbc:mysql://127.0.0.1:3306/ke?useUnicode=true&characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNullkafka.eagle.username=rootkafka.eagle.password=root复制代码

5、启动 eagle

ke.sh start复制代码

kafka-eagle监控界面的搭建_kafka-eagle_02kafka-eagle监控界面的搭建_kafka-eagle_03

三、ke.sh的用法
命令 解释
ke.sh start 启动eagle
ke.sh stop 停止eagle
ke.sh restart 重新启动eagle
ke.sh status 查看eagle的状态