windows环境下用命令行操作kafka
2018-02-28 09:46
746 查看
转载自https://www.cnblogs.com/mignet/p/window_kafka.html
1.通过cmd进入kafka_2.11-0.9.0.1\bin\windows目录
2.启动zk
zookeeper-server-start ..\..\config\zookeeper.properties
测试连接一下
zookeeper-shell.bat 0.0.0.0:2181
3.启动Kafka
kafka-server-start.bat ..\..\config\server.properties
4.创建topic
kafka-topics.bat --create --zookeeper localhost:2181 --replication-factor 1 --partitions 3 --topic mytopic
参数的含义可以自查,当前无视
Created topic "mytopic".
5.查看topic
kafka-topics.bat --describe --zookeeper localhost:2181 --topic mytopic
----------------------------------------------------------
Topic:mytopic PartitionCount:3 ReplicationFactor:1 Configs:
Topic: mytopic Partition: 0 Leader: 0 Replicas: 0 Isr: 0
Topic: mytopic Partition: 1 Leader: 0 Replicas: 0 Isr: 0
Topic: mytopic Partition: 2 Leader: 0 Replicas: 0 Isr: 0
6.发布/生产消息窗口
kafka-console-producer.bat --broker-list localhost:9092 --topic mytopic
7.消费消息窗口
kafka-console-consumer.bat --zookeeper localhost:2181 --from-beginning --topic mytopic
8.在生产者producer窗口输入,可以在consumer窗口看到输出
bin\windows>kafka-console-producer.bat --broker-list localhost:9092 --topic mytopic
--------------------------------------------------------------------
你真坚决
niaho
heelo
我是中文啊
bin\windows>kafka-console-consumer.bat --zookeeper localhost:2181 --from-beginning --topic mytopic
--------------------------------------------------------------------
你真坚决
niaho
heelo
我是中文啊
--------------------------------------------------------------------
1.通过cmd进入kafka_2.11-0.9.0.1\bin\windows目录
2.启动zk
zookeeper-server-start ..\..\config\zookeeper.properties
测试连接一下
zookeeper-shell.bat 0.0.0.0:2181
3.启动Kafka
kafka-server-start.bat ..\..\config\server.properties
4.创建topic
kafka-topics.bat --create --zookeeper localhost:2181 --replication-factor 1 --partitions 3 --topic mytopic
参数的含义可以自查,当前无视
Created topic "mytopic".
5.查看topic
kafka-topics.bat --describe --zookeeper localhost:2181 --topic mytopic
----------------------------------------------------------
Topic:mytopic PartitionCount:3 ReplicationFactor:1 Configs:
Topic: mytopic Partition: 0 Leader: 0 Replicas: 0 Isr: 0
Topic: mytopic Partition: 1 Leader: 0 Replicas: 0 Isr: 0
Topic: mytopic Partition: 2 Leader: 0 Replicas: 0 Isr: 0
6.发布/生产消息窗口
kafka-console-producer.bat --broker-list localhost:9092 --topic mytopic
7.消费消息窗口
kafka-console-consumer.bat --zookeeper localhost:2181 --from-beginning --topic mytopic
8.在生产者producer窗口输入,可以在consumer窗口看到输出
bin\windows>kafka-console-producer.bat --broker-list localhost:9092 --topic mytopic
--------------------------------------------------------------------
你真坚决
niaho
heelo
我是中文啊
bin\windows>kafka-console-consumer.bat --zookeeper localhost:2181 --from-beginning --topic mytopic
--------------------------------------------------------------------
你真坚决
niaho
heelo
我是中文啊
--------------------------------------------------------------------
相关文章推荐
- Git - 在windows环境中使用命令行操作github
- 在 Linux的命令行下,像在 Windows环境下 一样操作管理文件和目录
- Windows环境下VMware虚拟机的自启动与自动关机--命令行操作
- Windows环境下VMware虚拟机的自启动与自动关机--命令行操作
- 在windows环境下使用命令行控制Mysql(一、基础操作)
- windows 环境变量 命令行操作 符号链接
- MySQL---Windows环境下从命令行进入MySQL命令行程序
- 惊艳的cygwin——Windows下的Linux命令行环境的配置和使用
- windows下搭建Kafka运行环境
- Windows平台搭建Kafka源代码开发环境(Eclipse版本)
- Windows如何在cmd命令行中查看、修改、删除与添加、设置环境变量
- windows平台搭建命令行环境
- mysql命令行的导入导出sql,txt,excel(都在linux或windows命令行操作)
- 为想学SQLite或练习SQL语言的朋友搭建简单的命令行环境------在Windows, Linux, Android(用adb连接安卓手机)上玩转SQLite数据库的sqlite3命令行
- Windows单机配置Kafka环境
- 环境搭建与DOS命令行的操作
- Python在Windows环境下命令行中使用UTF-8编码输出乱码解决
- MongoDB搭建和简单操作(windows环境)
- 在Windows中实现sudo命令——命令行环境中获取管理员权限