List all kafka topics

后端 未结 15 721
谎友^
谎友^ 2020-12-24 00:13

I\'m using kafka 0.10 without zookeeper. I want to get kafka topics list. This command is not working since we\'re not using zookeeper: <

相关标签:
15条回答
  • 2020-12-24 00:30

    Kafka is a distributed system and needs Zookeeper. you have to start zookeeper too. Follow "Quick Start" here : https://kafka.apache.org/0100/documentation.html#quickstart

    0 讨论(0)
  • 2020-12-24 00:33

    You can try using the below two command and list all Kafka topic

    • bin/kafka-topics.sh --describe --zookeeper 192.168.0.142:2181,192.168.9.115:2181,192.168.4.57:2181
    • bin/kafka-topics.sh --zookeeper 192.168.0.142:2181,192.168.9.115:2181,192.168.4.57:218 --list
    0 讨论(0)
  • 2020-12-24 00:34

    Commands:

    1. To start the kafka:

      $ nohup ~/kafka/bin/kafka-server-start.sh ~/kafka/config/server.properties > ~/kafka/kafka.log 2>&1 &

    2. To list out all the topic on on kafka;

      $ bin/kafka-topics.sh --list --zookeeper localhost:2181

    3. To check the data is landing on kafka topic and to print it out;

      $ bin/kafka-console-consumer.sh --bootstrap-server localhost:9092 --topic your_topic_name --from-beginning

    0 讨论(0)
  • 2020-12-24 00:34

    To read messages you should use:

    kafka-console-consumer.sh --bootstrap-server kafka1:9092,kafka2:9092,kafka3:9092 --topic messages --from-beginning
    

    --bootstrap-server is required attribute. You can use only single kafka1:9020 node.

    0 讨论(0)
  • 2020-12-24 00:38

    Kafka uses ZooKeeper so you need to first start a ZooKeeper server if you don't already have one.

    If you do not want to install and have a separate zookeeper server, you can use the convenience script packaged with kafka to get a quick-and-dirty single-node ZooKeeper instance.

    Starting the single-node Zookeeper instance:

    bin/zookeeper-server-start.sh config/zookeeper.properties
    

    Starting the Kafka Server:

    bin/kafka-server-start.sh config/server.properties
    

    Listing the Topics available in Kafka:

    bin/kafka-topics.sh --list --zookeeper localhost:2181
    
    0 讨论(0)
  • 2020-12-24 00:39

    For dockerized kafka/zookeeper

    docker ps
    

    find you zookeeper container id

    docker exec -it <id> bash
    
    cd bin
    
    ./zkCli.sh
    
    ls /brokers/topics
    
    0 讨论(0)
提交回复
热议问题