1. 创建topic
$KAFKA_HOME/bin/kafka-topics.sh --create --zookeeper hadoop01:2181,hadoop02:2181,hadoop03:2181 --replication-factor 2 --partitions 3 --topic test
2. 查看所有的topic
$KAFKA_HOME/bin/kafka-topics.sh --list --zookeeper hadoop01:2181,hadoop02:2181,hadoop03:2181
3.模拟生产者生产数据
$KAFKA_HOME/bin/kafka-console-producer.sh --broker-list hadoop01:9092,hadoop02:9092,hadoop03:9092 --topic test
4.模拟消费者消费数据
$KAFKA_HOME/bin/kafka-console-consumer.sh --from-beginning --bootstrap-server hadoop01:9092,hadoop02:9092,hadoop03:9092 --topic test
5. 查看指定topic的详情信息
$KAFKA_HOME/bin/kafka-topics.sh --describe --zookeeper hadoop01:2181,hadoop02:2181,hadoop03:2181 --topic test
6. 查看每个分区中分别有多少条数据
$KAFKA_HOME/bin/kafka-run-class.sh kafka.tools.GetOffsetShell --broker-list hadoop01:9092,hadoop02:9092,hadoop03:9092 --topic test
7. 增加topic分区数
$KAFKA_HOME/bin/kafka-topics.sh --zookeeper hadoop01:2181,hadoop02:2181,hadoop03:2181 --alter --topic test --partitions 8
8. 增加配置
$KAFKA_HOME/bin/kafka-topics.sh --zookeeper hadoop01:2181,hadoop02:2181,hadoop03:2181 --alter --topic test --config flush.messages=1
9. 删除配置
$KAFKA_HOME/bin/kafka-topics.sh --zookeeper hadoop01:2181,hadoop02:2181,hadoop03:2181 --alter --topic test --delete-config flush.messages
10. 删除topic
$KAFKA_HOME/bin/kafka-topics.sh --zookeeper hadoop01:2181,hadoop02:2181,hadoop03:2181 --delete --topic topicName