KafkaConsumer及其监控
来源:互联网 发布:阿里云国际版价格 2017 编辑:程序博客网 时间:2024/06/01 16:30
Kafka目前为java提供了两种consumer的API:
- high level consumer api
该consumer api 封装了很多consumer需要的高级功能,如
- Auto/Hidden Offset Management
- Auto(Simple) Partition Assignment
- Broker Failover => Auto Rebalance
- Consumer Failover => Auto Rebalance
- If user do not want any of these, then simple consumer is sufficient
- If user want to control over offset management with others unchanged, one option is to expose the current ZK implementation of the high-level consumer to users and allow them to override; another option is to change the high-level consumer API to return the offset vector associated with messages
- If user want to control partition assignment, one option is to change the high-level consumer API to allow such config info be passed in while creating the stream; another option is ad-hoc: just make a single-partition topic and assign it to the consumer.
- If user just want the automatic partition assignment be more "smart" with co-location consideration, etc, one option is to store the host/rack info in ZK and let the rebalance algorithm read them while doing the computation.
该consumer默认会把自己的信息写在zk路径 /consumers/<groupId>,其中包括
- offsets 该topic的<partition_num>上的offset的值
- owners 当前<topic>的每个partition,在该<groupId>下能收取数据的consumer的唯一ID
- ids 当前<groupId>的所有consumer列表
正常情况下,High level consumer可以满足我们日常大多数用途。
- simple consumer api
只有最基本的链接、读取功能,可以自己去读offset,并指定offset的读取方式。适合于各种自定义。
Kafka的监控目前有两种方式:
1. JMX
Kafka内置有一个Mx4jLoader的程序,该程序如果在classpath中发现了mx4j-tools.jar,就会加载该jar,在8082 可以查看MX4J提供的网页信息。
除该内置的接口外,也可以自行修改Java启动命令,加入jmx。然后基于jmx集成到各大监控系统,如Zabbix, Ganglia等。后者直接github上直接有一个项目(猛击这里)
2. zookeeper
典型监控有kafkamonitor 和kafka-web-console
两者的安装都比较简单。这里就不再多写了,可直接参见。
看官方wiki说,0.9开始似乎要对consumer的api有大改动,个人是比较支持的。目前consumer的api看上去是有点要么过于简单、要么封装过深。
wiki:https://cwiki.apache.org/confluence/display/KAFKA/Consumer+Client+Re-Design
0 0
- KafkaConsumer及其监控
- KafkaConsumer分析
- Apache Kafka 0.9 KafkaConsumer
- KafkaConsumer流程简述
- KafkaConsumer流程简述
- KafkaConsumer使用详解
- 【Kafka源码】KafkaConsumer
- Redis及其监控工具简介
- KafkaConsumer 抛出KafkaConsumer is not safe for multi-threaded
- Kafka 0.10 KafkaConsumer流程简述
- Kafka 0.10 KafkaConsumer流程简述
- Kafka 0.10 KafkaConsumer流程简述
- Kafka 0.10 KafkaConsumer流程简述
- Kafka 0.10 KafkaConsumer流程简述
- Kafka 0.10 KafkaConsumer流程简述
- Kafka 0.10 KafkaConsumer流程简述
- 监控图象传输方式及其特性
- 监控组态软件及其发展《转》
- OCP 1Z0 053 230
- 使用android ProgressBar和Toast生成一个界面
- Linux I2C驱动分析(三)----i2c_dev驱动和应用层分析
- HTTP协议简介和多线程断点续传(转)
- (总结)CentOS Linux搭建SVN Server配置详解
- KafkaConsumer及其监控
- 【Java】迭代的几种控制方法
- C++ primer(第五版) 练习 5.9 个人code
- 编译内核模块出现 include/linux/autoconf.h or include/config/auto.conf are missing.解决方法
- perl dbm文件操作总结
- 凸边形外壳
- HWOJ 字符统计
- 第三方
- ORA-12514: TNS: 监听程序当前无法识别连接描述符中请求的服务