kafka

基本命令

  1. 启动kafka

/bin/kafka-server-start.sh -daemon config/server.properties

  1. 关闭kafka

/bin/kafka-server-stop.sh stop

  1. 查看topic

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

  1. 创建topic

bin/kafka-topics.sh --zookeeper localhost:2181 --create --replication-factor 1 --partitions 1 -- topic first
选项说明:—topic 定义 topic 名
—replication-factor 定义副本数
—partitions 定义分区数

  1. 删除topic

bin/kafka-topics.sh --zookeeper localhost:2181 --delete --topic test_topic

  1. 生产者

bin/kafka-console-producer.sh --broker-list localhost:9092 --topic test_topic

  1. 消费者

bin/kafka-console-consumer.sh --bootstrap-server localhost:9092 --topic test_topic