Esta página aún no está disponible en su idioma local. Estamos trabajando arduamente para agregar más versiones de idiomas. Gracias por tu apoyo.

On this page

Show all

Shell

Updated on 2022-09-14 GMT+08:00
  1. Query the list of topics in current clusters.

    bin/kafka-topics.sh --list --zookeeper <ZooKeeper cluster IP address:2181/kafka>

    bin/kafka-topics.sh --list --bootstrap-server <Kafka cluster IP address:21007> --command-config config/client.properties

  2. Query the details of a topic.

    bin/kafka-topics.sh --describe --zookeeper <ZooKeeper cluster IP address:2181/kafka> --topic <Topic name>

    bin/kafka-topics.sh --describe --bootstrap-server <Kafka cluster IP address:21007> --command-config config/client.properties --topic <Topic name>

  3. Delete a topic (this operation can be performed by an administrator).

    bin/kafka-topics.sh --delete --zookeeper <ZooKeeperCluster IP address:2181/kafka> --topic <Topic name>

    bin/kafka-topics.sh --delete --bootstrap-server <Kafka cluster IP address:21007>--command-config config/client.properties --topic <Topic name>

  4. Create a topic (this operation can be performed by an administrator).

    bin/kafka-topics.sh --create --zookeeper <ZooKeeperCluster IP address:2181/kafka> --partitions 6 --replication-factor 2 --topic <Topic name>

    bin/kafka-topics.sh --create --bootstrap-server <Kafka cluster IP address:21007> --command-config config/client.properties --partitions 6 --replication-factor 2 --topic <Topic name>

  5. Assign permissions to the Consumer (this operation is performed by an administrator).

    bin/kafka-acls.sh --authorizer-properties zookeeper.connect=<ZooKeeper cluster IP address:2181/kafka > --add --allow-principal User:<User name> --consumer --topic <Topic name> --group <Consumer group name>

    bin/kafka-acls.sh --bootstrap-server <Kafka cluster IP address:21007> --command-config config/client.properties --add --allow-principal User:<User name> --consumer --topic <Topic name> --group <Consumer group name>

  6. Assign permissions to the Producer (this operation is performed by an administrator).

    bin/kafka-acls.sh --authorizer-properties zookeeper.connect=<ZooKeeper cluster IP address:2181/kafka > --add --allow-principal User:<User name> --producer --topic <Topic name>

    bin/kafka-acls.sh --bootstrap-server <Kafka cluster IP address:21007> --command-config config/client.properties --add --allow-principal User:<User name> --producer --topic <Topic name>

  7. Produce messages (this operation requires the producer permission of the desired topic).

    bin/kafka-console-producer.sh --broker-list <KafkaCluster IP address:21007> --topic <Topic name> --producer.config config/producer.properties

  8. Consume data (the producer permission of the topic is required).

    bin/kafka-console-consumer.sh --topic <Topic name> --bootstrap-server <KafkaCluster IP address:21007> --consumer.config config/consumer.properties

Feedback

Feedback

Feedback

0/500

Selected Content

Submit selected content with the feedback