当前位置:首页 > 开发 > 开源软件 > 正文

【Kafka八】Zookeeper上关于Kafka的配置信息

发表于: 2015-04-01   作者:bit1129   来源:转载   浏览:
摘要: 问题: 1. Kafka的哪些信息记录在Zookeeper中 2. Consumer Group消费的每个Partition的Offset信息存放在什么位置 3. Topic的每个Partition存放在哪个Broker上的信息存放在哪里 4. Producer跟Zookeeper究竟有没有关系?没有关系!!!   //consumers、config、brokers、cont

问题:

1. Kafka的哪些信息记录在Zookeeper中

2. Consumer Group消费的每个Partition的Offset信息存放在什么位置

3. Topic的每个Partition存放在哪个Broker上的信息存放在哪里

4. Producer跟Zookeeper究竟有没有关系?没有关系!!!

 

//consumers、config、brokers、controller_epoch都是Kafka相关的znode
[zk: localhost:2181(CONNECTED) 0] ls /
[abc, admin, zookeeper, consumers, config, controller, storm, brokers, controller_epoch]
[zk: localhost:2181(CONNECTED) 1] ls

///consumers目录下是所有的consumer group的定义
[zk: localhost:2181(CONNECTED) 2] ls /consumers
[test-consumer-group, topic-p6-r2-consumer-group, learn.topic.consumers.group, learn.topic.p8.r2.consumers.group]
[zk: localhost:2181(CONNECTED) 3] ls learn.topic.p8.r2.consumers.group
Command failed: java.lang.IllegalArgumentException: Path must start with / character

///consumer group下游offsets、owners和ids的定义
[zk: localhost:2181(CONNECTED) 4] ls /consumers/learn.topic.p8.r2.consumers.group
[offsets, owners, ids]

///offsets下面是topic的定义
[zk: localhost:2181(CONNECTED) 5] ls /consumers/learn.topic.p8.r2.consumers.group/offsets
[learn.topic.p8.r2]

///topic下面是partition的定义,learn.topic.p8.r2表示8个partition,2个副本
///partition中的offset的设置在znode的data中,而不是子znode中
[zk: localhost:2181(CONNECTED) 6] ls /consumers/learn.topic.p8.r2.consumers.group/offsets/learn.topic.p8.r2
[3, 2, 1, 0, 7, 6, 5, 4]
[zk: localhost:2181(CONNECTED) 7] ls /consumers/learn.topic.p8.r2.consumers.group/offsets/learn.topic.p8.r2/2
[]
[zk: localhost:2181(CONNECTED) 8] ls /consumers/learn.topic.p8.r2.consumers.group/offsets/learn.topic.p8.r2/3
[]
[zk: localhost:2181(CONNECTED) 9] ls /consumers/learn.topic.p8.r2.consumers.group/offsets/learn.topic.p8.r2/4
[]

///consumer group属于哪个topic所有,代码中不需要显式指定
///consumer group消费哪个topic,kafka自动将topic设置为这个consumer group的owner
[zk: localhost:2181(CONNECTED) 19] ls /consumers/learn.topic.p8.r2.consumers.group/owners
[learn.topic.p8.r2]
[zk: localhost:2181(CONNECTED) 20] ls /consumers/learn.topic.p8.r2.consumers.group/owners/learn.topic.p8.r2
[3, 2, 1, 0, 7, 6, 5, 4]
[zk: localhost:2181(CONNECTED) 21] ls /consumers/learn.topic.p8.r2.consumers.group/owners/learn.topic.p8.r2/3
[]

///后面是broker的ID
[zk: localhost:2181(CONNECTED) 23] ls /consumers/learn.topic.p8.r2.consumers.group/ids
[learn.topic.p8.r2.consumers.group_TP-A383-D-1427853446455-efa1e47b]
[zk: localhost:2181(CONNECTED) 24] ls /consumers/learn.topic.p8.r2.consumers.group/ids/learn.topic.p8.r2.consumers.group_TP-A383-D-1427853446455-efa1e47b
[]

[zk: localhost:2181(CONNECTED) 10] ls /brokers
[topics, ids]
[zk: localhost:2181(CONNECTED) 11] ls /brokers/topics
[topic_p10_r3, topic-p6-r2, test_many_partitions, test, topic_p10_r1, learn.topic.p8.r2, learn.topic, topic-3-replica-1-part]
[zk: localhost:2181(CONNECTED) 12] ls /brokers/topics/learn.topic.p8.r2
[partitions]
[zk: localhost:2181(CONNECTED) 13] ls /brokers/topics/learn.topic.p8.r2/partitions
[3, 2, 1, 0, 7, 6, 5, 4]
[zk: localhost:2181(CONNECTED) 14] ls /brokers/topics/learn.topic.p8.r2/partitions/3
[state]
[zk: localhost:2181(CONNECTED) 15] ls /brokers/topics/learn.topic.p8.r2/partitions/3/state
[]
[zk: localhost:2181(CONNECTED) 16] ls /brokers/ids
[2, 1, 0]
[zk: localhost:2181(CONNECTED) 17] ls /brokers/ids/2
[]
[zk: localhost:2181(CONNECTED) 18] 

 

每个Consumer Group的每个Partition的Offset信息是作为值存放在Partition节点上的,而不是作为子节点,如下所示,4704是3号Partition已经消费的Offset数

[zk: localhost:2181(CONNECTED) 28] get /consumers/learn.topic.p8.r2.consumers.group/offsets/learn.topic.p8.r2/3 
4704
cZxid = 0x1bf14
ctime = Tue Mar 31 06:25:39 EDT 2015
mZxid = 0x1c658
mtime = Tue Mar 31 22:03:48 EDT 2015
pZxid = 0x1bf14
cversion = 0
dataVersion = 177
aclVersion = 0
ephemeralOwner = 0x0
dataLength = 4
numChildren = 0

 

Topic的每个Partition存放在哪个Broker上的信息存放在哪里?

[zk: localhost:2181(CONNECTED) 30] ls /brokers                                                                 
[topics, ids]
[zk: localhost:2181(CONNECTED) 31] ls /brokers/topics
[topic_p10_r3, topic-p6-r2, test_many_partitions, test, topic_p10_r1, learn.topic.p8.r2, learn.topic, topic-3-replica-1-part]
[zk: localhost:2181(CONNECTED) 32] ls /brokers/topics/learn.topic.p8.r2
[partitions]
[zk: localhost:2181(CONNECTED) 33] ls /brokers/topics/learn.topic.p8.r2/partitions
[3, 2, 1, 0, 7, 6, 5, 4]
[zk: localhost:2181(CONNECTED) 34] ls /brokers/topics/learn.topic.p8.r2/partitions/3
[state]
[zk: localhost:2181(CONNECTED) 35] ls /brokers/topics/learn.topic.p8.r2/partitions/3/state
[]

///
[zk: localhost:2181(CONNECTED) 36] get  /brokers/topics/learn.topic.p8.r2/partitions/3/state
{"controller_epoch":42,"leader":0,"version":1,"leader_epoch":2,"isr":[0,1]}
cZxid = 0x1bee8
ctime = Tue Mar 31 05:34:16 EDT 2015
mZxid = 0x1c247
mtime = Tue Mar 31 21:48:01 EDT 2015
pZxid = 0x1bee8
cversion = 0
dataVersion = 5
aclVersion = 0
ephemeralOwner = 0x0
dataLength = 75
numChildren = 0

 

每个Broker的信息:包括host和port

//三个broker
[zk: localhost:2181(CONNECTED) 38] ls  /brokers/ids                                         
[2, 1, 0]
[zk: localhost:2181(CONNECTED) 39] ls  /brokers/ids/2
[]

///host和port信息
[zk: localhost:2181(CONNECTED) 40] get  /brokers/ids/2
{"jmx_port":-1,"timestamp":"1427852973061","host":"192.168.26.140","version":1,"port":9094}
cZxid = 0x1c257
ctime = Tue Mar 31 21:49:33 EDT 2015
mZxid = 0x1c257
mtime = Tue Mar 31 21:49:33 EDT 2015
pZxid = 0x1c257
cversion = 0
dataVersion = 0
aclVersion = 0
ephemeralOwner = 0x14c72a6b3610003
dataLength = 91
numChildren = 0

 

每个Topic的Partion存放在哪个或者哪些Broker上,信息存放在

///每个partition的leaderpartition和follower partition信息
[zk: localhost:2181(CONNECTED) 53] get /brokers/topics/learn.topic.p8.r2
{"version":1,"partitions":{"4":[2,1],"5":[0,2],"6":[1,2],"1":[2,0],"0":[1,2],"2":[0,1],"7":[2,0],"3":[1,0]}}

 

 

 

【Kafka八】Zookeeper上关于Kafka的配置信息

  • 0

    开心

    开心

  • 0

    板砖

    板砖

  • 0

    感动

    感动

  • 0

    有用

    有用

  • 0

    疑问

    疑问

  • 0

    难过

    难过

  • 0

    无聊

    无聊

  • 0

    震惊

    震惊

编辑推荐
REDIS 环境搭建 1.下载Redis 下载地址:http://download.redis.io/releases/redis-2.8.13.tar.gz 2.
2 kafka
kafka设计原理介绍 背景介绍 Kafka简介   Kafka是一种分布式的,基于发布/订阅的消息系统。主要设
3 kafka
topics主题 producers 生产者(发布消息到主题) consumers 消费者(订阅主题并处理消息) broker
4 kafka
【原创声明】本文属作者原创,已授权InfoQ中文站首发,转载请务必在文章开头标明出自“Jason's Blog
5 kafka
转载自:http://www.cnblogs.com/tangr206/articles/2274845.html 基本概念 kafka的工作方式和其他M
转载自:http://blog.csdn.net/cfeibiao/article/details/8934423 Kafka默认的zookeeper.properties
转载自:http://blog.csdn.net/cfeibiao/article/details/8934423 Kafka默认的zookeeper.properties
问题导读: 1.zookeeper在kafka的作用是什么? 2.kafka中几乎不允许对消息进行“随机读写”的原因是
参考site:http://kafka.apache.org/documentation.html#impl_zookeeper 1、zookeeper客户端相关命
转自:http://my.oschina.net/ielts0909/blog/94153 如果你第一次看kafka的文章,请先看《分布式消
版权所有 IT知识库 CopyRight © 2009-2015 IT知识库 IT610.com , All Rights Reserved. 京ICP备09083238号