kafka版本
kafka_2.10-0.9.0.1
后台启动
./bin/zookeeper-server-start.sh -daemon config/zookeeper.properties
./bin/kafka-server-start.sh -daemon config/server.properties
创建topic
bin/kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor 1 --partitions 1 --topic test2
查看topic
./bin/kafka-topics.sh --list --zookeeper localhost:2181
写入带有key的消息
./bin/kafka-console-producer.sh --topic test2 --broker-list 127.0.0.1:9092 --property "parse.key=true" --property "key.separator=:"
#开始写入(要以:分割,否则报错)
id:1243
id:34
消费消息(打印key)
./bin/kafka-console-consumer.sh --zookeeper localhost:2181 --topic test2 --from-beginning --property print.key=true
删除topic
配置文件config/server.properties 配置delete.topic.enable=true
./bin/kafka-topics.sh --delete --zookeeper localhost:2181 --topic test2