Kafka常用命令汇总

云计算 waitig 584℃ 百度已收录 0评论

kafka和zookerper基本信息:

kafka = "172.17.76.4:6667"

zookeeper = "172.17.76.1:2181,172.17.76.2:2181,172.17.76.3:2181"

进入目录:

# cd /usr/hdp/2.6.1.0-129/kafka 或者 # cd /usr/hdp/current/kafka-broker

1)查看当前集群主题topic列表:

bin/kafka-topics.sh –list –zookeeper 172.17.76.1:2181

2)创建主题:

bin/kafka-topics.sh –create –zookeeper 172.17.76.1:2181 –topic zy-test –replication-factor 1 –partitions 1

3)查看单个主题详细信息:

bin/kafka-topics.sh –describe –zookeeper 172.17.76.1:2181 –topic zy-test

4)生成:

bin/kafka-console-producer.sh –broker-list 172.17.76.4:6667 –sync –topic zy-test

5)消费:

bin/kafka-console-consumer.sh –zookeeper 172.17.76.1:2181 –topic zy-test –from-beginning

6)分区:

bin/kafka-topics.sh –zookeeper 172.17.76.1:2181,172.17.76.2:2181,172.17.76.3:2181 –alter –partitions 2 –topic zy-test

7)运行:

bin/run-example org.apache.spark.examples.streaming.KafkaWordCount 172.17.76.1:2181 test-consumer-group zy-test 1

bin/kafka-run-class.sh org.apache.kafka.streams.examples.wordcount.WordCountDemo

8)删除主题:

bin/kafka-topics.sh –delete –zookeeper 172.17.76.1 –topic
zy-test

注:如果Kafka配置的delete.topic.enable参数为false,表示作标识删除;此参数为true直接删除


本文由【waitig】发表在等英博客
本文固定链接:Kafka常用命令汇总
欢迎关注本站官方公众号,每日都有干货分享!
等英博客官方公众号
点赞 (0)分享 (0)