kafka基本操作

来源:互联网 发布:丹特丽安的书架 知乎 编辑:程序博客网 时间:2024/06/08 07:28
启动kafka
bin/kafka-server-start.sh config/server.properties


创建topic
bin/kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor 1 --partitions 1 --topic test




查看topic
bin/kafka-topics.sh --list --zookeeper localhost:2181


删除topic
/home/zhubao/Code/kafka/bin/kafka-run-class.sh kafka.admin.DeleteTopicCommand --topic syslogTopic --zookeeper localhost:2181
./kafka_2.10-0.8.2.1/bin/kafka-topics.sh --delete --zookeeper bsa860:2181 bsa861:2181 bsa862:2181 --topic ips_tac_log




发数据
bin/kafka-console-producer.sh --broker-list localhost:9092 --topic test 
This is a messageThis is another message


ctrl+c可以退出发送。


收数据
bin/kafka-console-consumer.sh --zookeeper localhost:2181 --topic test --from-beginning




bin/kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor 3 --partitions 1 --topic my-replicated-topic
0 0