kfaka windows安装
1 官网下载 解压到D:\developTools\kfaka\kafka_2.10-0.9.0.0
2 windows cmd启动
新开cmd命令:cd /d D:\developTools\kfaka\kafka_2.10-0.9.0.0\bin\windows
cd /d D:\developTools\kfaka\kafka_2.10-0.8.2.1\bin\windows
zookeeper-server-start.bat ..\..\config\zookeeper.properties
新开cmd命令:cd /d D:\developTools\kfaka\kafka_2.10-0.9.0.0\bin\windows
cd /d D:\developTools\kfaka\kafka_2.10-0.8.2.1\bin\windows
kafka-server-start.bat ..\..\config\server.properties
3 下载源代码 建maven工程 引入 对应pom文件
把examples下demo运行即可
public Producer(String topic, Boolean isAsync) { Properties props = new Properties(); props.put("bootstrap.servers", "localhost:9092;localhost:9093"); // props.put("metadata.broker.list", "localhost:9092;localhost:9093"); props.put("client.id", "DemoProducer"); props.put("key.serializer", "org.apache.kafka.common.serialization.IntegerSerializer"); props.put("value.serializer", "org.apache.kafka.common.serialization.StringSerializer"); producer = new KafkaProducer<Integer, String>(props); this.topic = topic; this.isAsync = isAsync; }
4 伪分布式:拷贝server.properties,新建副本 server-1.properties,然后cmd启动 kafka-server-start.bat ..\..\config\server-1.properties
broker.id=1 不能超过reserved.broker.max.id:1000
broker.id=1
############################# Socket Server Settings #############################
listeners=PLAINTEXT://:9093
# The port the socket server listens on
port=1
# A comma seperated list of directories under which to store log files
log.dirs=/tmp/kafka-logs-1
5 常用命令 http://blog.csdn.net/laputa73/article/details/48826167
新建topic kafka-topics.bat --create --zookeeper localhost:2181 --replication-factor 1 --partitions 2 --topic zhumltopic
查看所有topic kafka-topics.bat --list --zookeeper localhost:2181
查看指定topic kafka-topics.bat --describe --zookeeper localhost:2181 --topic zhumltopic
删除指定topic kafka-topics.bat --delete --zookeeper localhost:2181 --topic zhumltopic 只是标记删除,不是真正删除
解决方法:server.properties 中添加 delete.topic.enable=true
问题见:http://stackoverflow.com/questions/23976670/when-how-does-a-topic-marked-for-deletion-get-finally-removed