Kafka常用命令
以下是kafka常用命令行总结:
1.查看topic的详细信息
./kafka-topics.sh-zookeeper127.0.0.1:2181-describe-topictestKJ1
2、为topic增加副本
./kafka-reassign-partitions.sh-zookeeper127.0.0.1:2181-reassignment-json-filejson/partitions-to-move.json-execute
3、创建topic
./kafka-topics.sh--create--zookeeperlocalhost:2181--replication-factor1--partitions1--topictestKJ1
4、为topic增加partition
./bin/kafka-topics.sh–zookeeper127.0.0.1:2181–alter–partitions20–topictestKJ1
5、kafka生产者客户端命令
./kafka-console-producer.sh--broker-listlocalhost:9092--topictestKJ1
6、kafka消费者客户端命令
./kafka-console-consumer.sh-zookeeperlocalhost:2181--from-beginning--topictestKJ1
7、kafka服务启动
./kafka-server-start.sh-daemon../config/server.properties
8、下线broker
./kafka-run-class.shkafka.admin.ShutdownBroker--zookeeper127.0.0.1:2181--broker#brokerId#--num.retries3--retry.interval.ms60
shutdownbroker
9、删除topic
./kafka-run-class.shkafka.admin.DeleteTopicCommand--topictestKJ1--zookeeper127.0.0.1:2181
./kafka-topics.sh--zookeeperlocalhost:2181--delete--topictestKJ1
10、查看consumer组内消费的offset
./kafka-run-class.shkafka.tools.ConsumerOffsetChecker--zookeeperlocalhost:2181--grouptest--topictestKJ1
学习参考:
http://www.infoq.com/cn/articles/kafka-analysis-part-1
http://flychao88.iteye.com/category/350737
http://shift-alt-ctrl.iteye.com/blog/1930791