> 文章列表 > Kafka与内置Zookeeper常用命令

Kafka与内置Zookeeper常用命令

Kafka与内置Zookeeper常用命令

存放路径(看自己情况)

d:\\work\\kafka_2.13-3.4.0

 windows运行路径(看自己的情况)

d:\\work\\kafka_2.13-3.4.0\\bin\\windows

启动服务器  (先启动zookeeper服务器,再启动kafka)  !!!千万不要手动暴力关闭

bin\\windows\\zookeeper-server-start.bat config\\zookeeper.properties

bin\\windows\\kafka-server-start.bat config\\server.properties

创建主题

kafka-topics.bat --create --bootstrap-server localhost:9092 --replication-factor 1 --partitions 1 --topic test

查看当前服务器的主题

kafka-topics.bat --list --bootstrap-server localhost:9092

创建生产者,往指定主题上发消息

kafka-console-producer.bat --broker-list localhost:9092 --topic test 

消费者

 kafka-console-consumer.bat --bootstrap-server localhost:9092 --topic test --from-beginning

关闭kafka服务器

bin\\windows\\kafka-server-stop.bat

关闭zookeeper服务器 

bin\\windows\\zookeeper-server-stop.bat