进入kafka安装目录
- 启动zookeeper
bin/zookeeper-server-start.sh -daemon ./config/zookeeper.properties
- 启动kafka
bin/kafka-server-start.sh config/server.properties &
- 查看broker
bin/zookeeper-shell.sh localhost:2181
ls /brokers/ids
- 创建主题
bin/kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor 1 --partitions 1 --topic token_change_notify
- 查看所有主题
bin/kafka-topics.sh --list --zookeeper localhost:2181
- 查看主题详情
bin/kafka-topics.sh --zookeeper localhost:2181 --describe --topic token_change_notify
- 删除主题
bin/kafka-topics.sh --zookeeper localhost:2181 --delete --topic token_change_notify
- 启动生产者
bin/kafka-console-producer.sh --broker-list localhost:9092 --topic token_change_notify
- 启动消费者
bin/kafka-console-consumer.sh --bootstrap-server localhost:9092 --topic token_change_notify --from-beginning
- 消费者起始偏移量 consumeStart