一、kafka_manager介绍
kafka_manager是雅虎公司的一款开源的监控工具。这个管理工具可以很容易地发现分布在集群中的哪些topic分布不均匀,或者是分区在整个集群分布不均匀的的情况。它支持管理多个集群、选择副本、副本重新分配以及创建Topic。同时,这个管理工具也是一个非常好的可以快速浏览这个集群的工具。
kafka_manager主要有如下几个功能:
最新版本的项目源码在 https://github.com/yahoo/kafka-manager
二、环境要求
Kafka 0.8.1.1 or 更高
sbt 0.13.x
Java 8+
三、安装部署
因为github上只能下载到项目的源码,并不是打包之后的包,所以需要我们自己去将这个项目下载到服务器上并打包。
该软件是用Scala语言编写的,所以要用到sbt进行打包,下面介绍如何在自己服务器上安装sbt并进行打包。
curl https://bintray.com/sbt/rpm/rpm | sudo tee /etc/yum.repos.d/bintray-sbt-rpm.repo
sudo yum install sbt
直接复制命令安装即可。
Kafka_manager源码下载 要求jdk1.8以上
https://github.com/yahoo/kafka-manager
解压:
unzip kafka-manager-master.zip
进入kafka-manager-master目录执行打包命令 如下:
./sbt clean dist
打包过程可能会非常慢,如果是第一次打包会下载一些相关的jar包,打包成功后可以修改配置文件:修改conf/application.conf,把kafka-manager.zkhosts改为自己的zookeeper服务器地址:
kafka-manager.zkhosts="localhost:2181"
You can specify multiple zookeeper hosts by comma delimiting them, like so:
kafka-manager.zkhosts="my.zookeeper.host.com:2181,other.zookeeper.host.com:2181"
Alternatively, use the environment variable ZK_HOSTS if you don’t want to hardcode any values.
ZK_HOSTS="my.zookeeper.host.com:2181"
You can optionally enable/disable the following functionality by modifying the default list in application.conf :
application.features=["KMClusterManagerFeature","KMTopicManagerFeature","KMPreferredReplicaElectionFeature","KMReassignPartitionsFeature"]
KMClusterManagerFeature - allows adding, updating, deleting cluster from Kafka Manager
KMTopicManagerFeature - allows adding, updating, deleting topic from a Kafka cluster
KMPreferredReplicaElectionFeature - allows running of preferred replica election for a Kafka cluster
KMReassignPartitionsFeature - allows generating partition assignments and reassigning partitions
Consider setting these parameters for larger clusters with jmx enabled :
kafka-manager.broker-view-thread-pool-size=< 3 * number_of_brokers>
kafka-manager.broker-view-max-queue-size=< 3 * total # of partitions across all topics>
kafka-manager.broker-view-update-seconds=< kafka-manager.broker-view-max-queue-size / (10 * number_of_brokers) >
Here is an example for a kafka cluster with 10 brokers, 100 topics, with each topic having 10 partitions giving 1000 total partitions with JMX enabled :
kafka-manager.broker-view-thread-pool-size=30
kafka-manager.broker-view-max-queue-size=3000
kafka-manager.broker-view-update-seconds=30
The follow control consumer offset cache’s thread pool and queue :
kafka-manager.offset-cache-thread-pool-size=< default is # of processors>
kafka-manager.offset-cache-max-queue-size=< default is 1000>
kafka-manager.kafka-admin-client-thread-pool-size=< default is # of processors>
kafka-manager.kafka-admin-client-max-queue-size=< default is 1000>
You should increase the above for large # of consumers with consumer polling enabled. Though it mainly affects ZK based consumer polling.
Kafka managed consumer offset is now consumed by KafkaManagedOffsetCache from the “__consumer_offsets” topic. Note, this has not been tested with large number of offsets being tracked. There is a single thread per cluster consuming this topic so it may not be able to keep up on large # of offsets being pushed to the topic.
以上均是针对kafka-manager的一些启动配置设置,可以参考官方资料https://github.com/yahoo/kafka-manager
一般使用只需配置zk的地址即可。
启动方法
最简单的启动方式:
$ bin/kafka-manager
指定配置文件及端口的启动方式:
$ bin/kafka-manager -Dconfig.file=/path/to/application.conf -Dhttp.port=8080
如果你的jdk环境不是所需的version,你需要运行不同版本的java,你可以通过参数指定jdk的安装位置:
$ bin/kafka-manager -java-home /usr/local/oracle-java-8
至此启动完毕,可以通过访问
http://127.0.0.1:9000
进行访问。
如下如展示:
kafka集群管理页面
topic管理
topic详情查看
消费列表视图
下面提供打包好的链接
kafka-manager-1.3.1.6.zip (密码:FFLT)