当前位置: 首页 > Linux

常用Kafka命令

时间:2023-04-06 01:31:48 Linux

1。启动kafka:./kafka-server-start.sh-daemon../config/server.properties启动后默认监听端口为90922,列出集群中所有topic。./kafka-topics.sh--zookeeperlocalhost:2181--list3,在kafka的路径下创建一个专门的topic,./kafka-topics.sh--create--zookeeper192.168.1.11:2181--replication-factor1--partitions5--topicmytopic4,查看topictopic./kafka-topics.sh--describe--zookeeper192.168.1.11:2181--topicmytopic5,修改partition./kafka-topics.sh--zookeeper192.168。1.11:2181--alter--topicmytopic--partition10修改fragmentsize为106,启动producer-生产数据路径下(发送)kafka,bin/kafka-console-producer.sh--broker-list192.168.1.11:9092--topicmytopicThisisamessageThisisanothermessage7.在启动consumerkafka的路径下./kafka-console-consumer.sh--bootstrap-server192.168.1.11:9092--topicmytopic--from-beginning--from-beginning:从头开始读;remove–from-beginning:从最新的开始阅读。8、删除主题第一步:删除主题./kafka-topics.sh–zookeeper192.168.1.11:2181–delete–topicmytopic