kafka的命令行操作

查看当前服务器中的所有topic

kafka-topics.sh --zookeeper hadoop102:2281 --list

创建topic

kafka-topic.sh --zookeeper hadoop102:2181 --create --replication-factor 3 --partitions 1 --topic first

--topic #定义topic名称
--replication-factor 定义副本数
--partitions 定义分区数

删除topic

kafka-topics.sh --zookeeper hadoop102:2181 --delete topic first

发送消息

kafka-sonsole-producer.sh --broker-list hadoop102:9092 --topic first

消费消息

kafka-console-consumer.sh --zookeeper hadoop102:2181 --topic first
kafka-console-consumer.sh --bootstrap-server hadoop102:9092 --topic first
kafka-console-consomer.sh --bootstrap-server hadoop102:9092 --from-beginning --topic first

#from-beginning :把主题中以往所有的数据都读出来

查看某个topic的详情

kafka-topics.sh --zookeeper hadoop102:2181 --descrobe --topic first

修改分区数

kafka-topics.sh --zookeeper hadoop102:2181 --alter --topic first --partitions 6

 

                                                                                                                      

posted @ 2020-06-30 01:05  阿布都日  阅读(117)  评论(0)    收藏  举报