Shell
- Query the list of topics in the current cluster.
sh kafka-topics.sh --list --zookeeper <IP address of the ZooKeeper cluster :2181/kafka>
sh kafka-topics.sh --list --bootstrap-server <IP address of the Kafka cluster:21007> --command-config config/client.properties
- Query the details of a topic.
sh kafka-topics.sh --describe --zookeeper <IP address of the ZooKeeper cluster:2181/kafka> --topic <Topic name>
sh kafka-topics.sh --describe --bootstrap-server <IP address of the Kafka cluster:21007> --command-config config/client.properties --topic <Topic name>
- Delete a topic (performed by an administrator).
sh kafka-topics.sh --delete --zookeeper <IP address of the ZooKeeper cluster:2181/kafka> --topic <Topic name>
sh kafka-topics.sh --delete --bootstrap-server <IP address of the Kafka cluster:21007>--command-config config/client.properties --topic <Topic name>
- Create a topic (performed by an administrator).
sh kafka-topics.sh --create --zookeeper <IP address of the ZooKeeper cluster:2181/kafka> --partitions 6 --replication-factor 2 --topic <Topic name>
sh kafka-topics.sh --create --bootstrap-server <IP address of the Kafka:21007> --command-config config/client.properties --partitions 6 --replication-factor 2 --topic <Topic name>
- Assign permissions to the Consumer (performed by an administrator).
sh kafka-acls.sh --authorizer-properties zookeeper.connect=<IP address of the ZooKeeper cluster:2181/kafka > --add --allow-principal User:<Username> --consumer --topic <Topic name> --group <Consumer group name>
sh kafka-acls.sh --bootstrap-server <IP address of the Kafka cluster:21007> --command-config config/client.properties --add --allow-principal User:< user name > --consumer --topic <Topic name > --group < consumer group name >
- Assign permissions to the Producer (performed by an administrator).
sh kafka-acls.sh --authorizer-properties zookeeper.connect=<IP address of the ZooKeeper cluster:2181/kafka > --add --allow-principal User:<Username> --producer --topic <Topic name>
sh kafka-acls.sh --bootstrap-server <IP address of the Kafkacluster:21007> --command-config config/client.properties --add --allow-principal User:<Username> --producer --topic <Topic name>
- Produce messages (this operation requires the producer permission of the desired topic).
sh kafka-console-producer.sh --broker-list <IP address of the Kafkacluster:21007> --topic <Topic name> --producer.config config/producer.properties
- Consume data (this operation requires the consumer permission of the desired topic).
sh kafka-console-consumer.sh --topic <Topic name> --bootstrap-server <IP address of the Kafkacluster:21007> --consumer.config config/consumer.properties
- Shell commands must be executed in the Client installation directory/Kafka/kafka/bin directory.
- The asterisk (*) can be specified to represent all values in the format of --Parameter Value, for example, --group *. The value must be enclosed in single quotation marks or equal signs, for example, --group'*' or --group=*.
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot