Kafka使用

1、启动Kafka:

bin/kafka-server-start.sh /home/hadoop/kafka_2.10-0.8.2.1/config/server.properties &

2、创建topic:
bin/kafka-topics.sh --create --topic test --replication-factor 3 --partitions 2 --zookeeper Master1:2181,Master2:2181,Slave1:2181,Slave2:2181,Slave3:2181
3、查看topic
bin/kafka-topics.sh --list --zookeeper Master1:2181,Master2:2181,Slave1:2181,Slave2:2181,Slave3:2181
4、发送消息:
bin/kafka-console-producer.sh --broker-list Master1:9092 --sync --topic test
5、开始一个消费者:
bin/kafka-console-consumer.sh --zookeeper Master1:2181,Master2:2181,Slave1:2181,Slave2:2181,Slave3:2181 --topic test --from-beginning
6、删除topic:
kafka-topics.sh --delete --zookeeper Master1:2181,Master2:2181,Slave1:2181,Slave2:2181,Slave3:2181 --topic test
7、删除kafka存储目录(server.properties文件log.dirs配置,默认为"/tmp/kafka-logs")相关topic目录删除zookeeper "/brokers/topics/"目录下相关topic节点
log.dirs=/tmp/kafka-logs

你可能感兴趣的:(Kafka使用)