1)下载kafka_2.10-0.8.2.1.tgz并解压(整合scala)
2)修改配置文件(可选)config/zookeeper.properties dataDir=/zookeeper这么写建到d盘根目录 dataDir=zookeeper这么写建到bin/windows目录3)启动zookeeper(窗口1)zookeeper-server-start.sh ../config/zookeeper.properties 4)zookeeper测试(窗口2)echo stat | nc 192.168.159.133 21815)启动kafka(窗口3)kafka-server-start.sh ../config/server.properties6)创建topic(窗口4)kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor 1 --partitions 3 --topic mytopic7)查看topic(窗口4)kafka-topics.sh --describe --zookeeper localhost:2181 --topic mytopicTopic: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: 08)发布/生产消息窗口(窗口5)kafka-console-producer.sh --broker-list localhost:9092 --topic mytopic有一个错误提示,但是不影响(kafa的bugKAFKA-1711,KAFKA-1824,预计0.9修复)9)消费消息窗口(窗口6)
kafka-console-consumer.sh --zookeeper localhost:2181 --from-beginning --topic mytopic10)znode查看
ls /[consumers, config, controller, admin, brokers, zookeeper, controller_epochls /consumers[console-consumer-21728]ls /config[topics, changes]ls /controller[]ls /admin[delete_topics]ls /brokers[topics, ids]ls /zookeeper[quota]ls /controller_epoch[]11)检查offset(窗口4) 注意:group为consumerid,需要在zk里面查ls /consumerkafka-consumer-offset-checker.sh --topic mytopic --zookeeper localhost:2181 --broker-info 127.0.0.1:9092 --group console-consumer-64061Group Topic Pid Offset logSize Lag Ownerconsole-consumer-64061 mytopic 0 4 4 0 console-consumer-64061_zynb0411-1443580144073-95285fc3-0console-consumer-64061 mytopic 1 1 1 0 console-consumer-64061_zynb0411-1443580144073-95285fc3-0console-consumer-64061 mytopic 2 1 1 0 console-consumer-64061_zynb0411-1443580144073-95285fc3-0BROKER INFO0 -> zynb0411:9092