设为首页 收藏本站
查看: 1446|回复: 0

[经验分享] 【Kafka八】Zookeeper上关于Kafka的配置信息

[复制链接]

尚未签到

发表于 2017-4-19 12:38:10 | 显示全部楼层 |阅读模式
  问题:
  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]}}

运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-366422-1-1.html 上篇帖子: Spark Streaming(1)Spark Streaming Concept and Zookeeper/Kafka on Local 下篇帖子: zabbix 监控kafka方法
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表