
# Kafka Shell命令介绍
- 查看当前集群Topic列表。 **bin/kafka-topics.sh --list --zookeeper \<** *ZooKeeper集群IP:2181* ***/kafka\>***
  **bin/kafka-topics.sh --list --bootstrap-server** *\<Kafka* *集群IP:21007\>* **--command-config config/client.properties**
  
- 查看单个Topic详细信息。 **bin/kafka-topics.sh --describe --zookeeper \<** *ZooKeeper集群IP:2181* ***/kafka\>* --topic** ***\<** Topic名称**\>***
  **bin/kafka-topics.sh --describe --bootstrap-server** *\<Kafka* *集群IP:21007\>* **--command-config config/client.properties** **--topic** ***\<** Topic名称**\>***
  
- 删除Topic，由管理员用户操作。 **bin/kafka-topics.sh --delete --zookeeper \<** *ZooKeeper* *集群IP:2181* ***/kafka\>* --topic** ***\<** Topic名称**\>***
  **bin/** **kafka-topics.sh --delete** **--bootstrap-server** *\<Kafka* *集群IP:21007* \>**--command-config config/client.properties** **--topic** ***\<** Topic名称**\>***
  
- 创建Topic，由管理员用户操作。 **bin/kafka-topics.sh --create --zookeeper \<** *ZooKeeper* *集群IP:2181* ***/kafka\>* --partitions 6 --replication-factor 2 --topic** ***\<** Topic名称**\>***
  **bin/kafka-topics.sh --create** **--** **bootstrap-server** *\<Kafka* *集群IP:21007* \>**--command-config config/client.properties** **--partitions 6 --replication-factor 2 --topic** ***\<** Topic名称**\>***
  
- 赋Consumer权限命令，由管理员用户操作。 **bin/kafka-acls.sh --authorizer-properties zookeeper.connect=\<** ZooKeeper集群IP:*2181* **/kafka \> --add --allow-principal User:** ***\<** 用户名**\>*** **--consumer --topic** ***\<** Topic名称**\>*** **--group** ***\<** 消费者组名称**\>***
  **bin/kafka-acls.sh --bootstrap-server** **\<*Kafka* *集群IP:21007\>*** **--command-config config/client.properties --add --allow-principal User:** ***\<*** *用户名* ***\>*** **--consumer --topic *\<*** *Topic* *名称* ***\>*** **--group *\<*** *消费者组名称* ***\>***
  
- 赋Producer权限命令，由管理员用户操作。 **bin/kafka-acls.sh --authorizer-properties zookeeper.connect=\<** ZooKeeper集群IP:*2181* **/kafka \> --add --allow-principal User:** ***\<** 用户名**\>*** **--producer --topic** ***\<** Topic名称**\>***
  **bin/kafka-acls.sh --bootstrap-server** **\<** *Kafka* *集群IP* ***:21007\>*** **--command-config config/client.properties --add --allow-principal User:** ***\<*** *用户名* ***\>*** **--producer --topic \<** *Topic* *名称* **\>**
  
- 生产消息，需要拥有该Topic生产者权限。 **bin/kafka-console-producer.sh --broker-list \<** *Kafka* *集群IP* ***:21007\>* --topic** ***\<** Topic名称**\>*** **--producer.config config/producer.properties**
  
- 消费数据，需要拥有该Topic的消费者权限。 **bin/kafka-console-consumer.sh --topic** ***\<** Topic名称**\>*** **--bootstrap-server \<** *Kafka* *集群IP* ***:21007\>* --consumer.config config/consumer.properties**
  
 
