kafka
基本命令
- 启动kafka
/bin/kafka-server-start.sh -daemon config/server.properties
- 关闭kafka
/bin/kafka-server-stop.sh stop
- 查看topic
bin/kafka-topics.sh --zookeeper localhost:2181 --list
- 创建topic
bin/kafka-topics.sh --zookeeper localhost:2181 --create --replication-factor 1 --partitions 1 -- topic first
选项说明:—topic 定义 topic 名
—replication-factor 定义副本数
—partitions 定义分区数
- 删除topic
bin/kafka-topics.sh --zookeeper
localhost:2181 --delete --topic test_topic
- 生产者
bin/kafka-console-producer.sh --broker-list localhost:9092 --topic test_topic
- 消费者
bin/kafka-console-consumer.sh --bootstrap-server localhost:9092 --topic test_topic