赞
踩
kafka的启动依赖zookeeper,先启动zookeeper,再启动kafka
bin/zookeeper-server-start.sh config/zookeeper.properties
bin/kafka-server-start.sh config/server.properties
topic使用文件kafka-topics.sh
,基本使用:
命令必须包含一个操作: - list,–describe, - create, --alter或–delete
创建
./kafka-topics.sh --create --zookeeper "kafka001:2181,kafka002:2181,kafka003:2181" --partitions 1 --replication-factor 1 --topic zaj
新版本需要使用命令:
./kafka-topics.sh --create --bootstrap-server 10.130.44.103:9092 --partitions 1 --replication-factor 1 --topic zaj
和端口
其中参数
--bootstrap-server
替换。--bootstrap-server
填写的是kafka server的ip和端口,--zookeeper
填写的是zookeeper的ip查看
./kafka-topics.sh --zookeeper "kafka001:2181,kafka002:2181,kafka003:2181" --list\
删除
./kafka-topics.sh --zookeeper "kafka001:2181,kafka002:2181,kafka003:2181" --delete --topic zaj13,zaj14
查看topic详情
[kafka@kafka003 bin]$ ./kafka-topics.sh --zookeeper "kafka001:2181,kafka002:2181,kafka003:2181" --describe --topic topic_test
Topic:topic_test PartitionCount:3 ReplicationFactor:3 Configs:
Topic: topic_test Partition: 0 Leader: 2 Replicas: 2,0,1 Isr: 0,2,1
Topic: topic_test Partition: 1 Leader: 0 Replicas: 0,1,2 Isr: 0,2,1
Topic: topic_test Partition: 2 Leader: 1 Replicas: 1,2,0 Isr: 0,2,1
[kafka@kafka003 bin]$ ./kafka-topics.sh --zookeeper "kafka001:2181,kafka002:2181,kafka003:2181" --describe --topic sd_call_result
Topic:sd_call_result PartitionCount:3 ReplicationFactor:1 Configs:
Topic: sd_call_result Partition: 0 Leader: 2 Replicas: 2 Isr: 2
Topic: sd_call_result Partition: 1 Leader: 0 Replicas: 0 Isr: 0
Topic: sd_call_result Partition: 2 Leader: 1 Replicas: 1 Isr: 1
展示信息:
topic名称,有几个分区,几个复制版本
每个消息分区的配置:消息分区的id,消息分区的leader处于哪一个broder,该消息分区的分布情况
“replicas” 信息,在节点1,2,0上,不管node死活,只是列出信息而已.
“isr” 工作中的复制节点的集合. 也就是活的节点的集合.
参考链接:
http://www.cnblogs.com/hopelee/p/7285340.html
https://github.com/Parsely/pykafka
https://cloud.tencent.com/developer/article/1010955
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。