Create multiple consumers in Kafka in command line

前端 未结 5 678
孤城傲影
孤城傲影 2021-02-08 05:59

I\'m new in Kafka. When I was running the quick start example in command line, I found I can\'t create multiple consumers in command line.

Condition:

I built a t

相关标签:
5条回答
  • 2021-02-08 06:26

    Besides using --consumer.config option like the secfree's answer, you can also use

    --consumer-property group.id=your_group

    option to specify a group name without editing the config file.

    0 讨论(0)
  • 2021-02-08 06:29

    When you consume Topic without groupid Kafka create random groupid for your session. You can specify groupid --consumer-property group.id=test-consumer-group if groupid exist or you can add to your session new groupid(name) when you consume if group not exist --topic second-topic --group my-first-group p and Kafka will create new group

    0 讨论(0)
  • 2021-02-08 06:30
    1. Default, kafka-console-consumer.sh will create a random group.
    2. If you want to specify the group name, you can:
      1. Add group.id=group_name to a local file filename
      2. Use --consumer.config filename option of kafka-console-consumer.sh to set group
    3. You can check your groups at zookeeper's /consumers/ directory.

    Refer: kafka/core/src/main/scala/kafka/tools/ConsoleConsumer.scala

    0 讨论(0)
  • 2021-02-08 06:36

    use this:

    --partition <Integer: partition>        The partition to consume from. 
    
    0 讨论(0)
  • 2021-02-08 06:41

    You can use the below command to create the consumers in the group "test-consumer-group" to "test" topic:

    bin/kafka-console-consumer.sh --bootstrap-server <brokerIP>:9092 --topic test --consumer-property group.id=test-consumer-group
    

    Below command will list the consumer group configuration:

    bin/kafka-consumer-groups.sh --bootstrap-server <brokerIP>:9092 --describe --group test-consumer-group
    

    Eg:

    GROUP || TOPIC || PARTITION || CURRENT-OFFSET || LOG-END-OFFSET || LAG      || OWNER
    test-consumer-group || test || 0 || 10 || 10 || 0 || consumer-1_/10.210.223.170
    
    0 讨论(0)
提交回复
热议问题