- 创建topic:
bin/kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor 1 --partitions 1 --topic test_ee
- 查看topic列表:
bin/kafka-topics.sh --list --zookeeper localhost:2181
- 查看指定topic的主题描述
bin/kafka-topics.sh --describe --zookeeper localhost:2181 --topic test_ee
- 生产者
bin/kafka-console-producer.sh --broker-list localhost:6667 --topic test3 --producer.config config/producer.properties
- 消费者
bin/kafka-console-consumer.sh --topic test3 --from-beginning --bootstrap-server node1:6667,node2:6667,node3:6667 --consumer.config config/consumer.properties
注意,消费topic时的server列表尽量填完整,因为kafka的分布式存储,只有所有server才存储了所有数据。
- 修改更新topic配置
bin/kafka-topics.sh --zookeeper localhost:2181 --alter --topic test-yst-source_topic --partitions 3
- 删除topic
bin/kafka-topics.sh --zookeeper localhost:2181 --delete --topic test-yst-source_topic