Community Articles

Find and share helpful community-sourced technical articles.
Labels (1)
avatar
Expert Contributor

In a non-Kerberized environment, for Kafka console consumer command displays all messages, perform the following:

Note:
Here, <broker_host> is Kafka broker hostname, <zk_host> is zookeeper hostname and Kafka port will be 6667:
  1. Using Old consumer API (prior to HDP 2.5.x), run the following:
    bin/kafka-console-consumer.sh --zookeeper <zk_host>:2181 --topic test --from-beginning
  2. Using New consumer API ( From HDP 2.5.x onwards), run the following:
    bin/kafka-console-consumer.sh --bootstrap-server <broker_host>:6667 --topic test --from-beginnin

To view a specific number of message in a Kafka topic, use the --max-messages option. To view the oldest message, run the console consumer with --from-beginning and --max-messages 1:

  1. Using Old consumer API ( Prior to HDP 2.5.x):
    bin/kafka-console-consumer.sh --zookeeper <zk_host>:2181 --topic test --from-beginning 
    --max-messages 1
  2. Using New consumer API ( From HDP 2.5.x onwards):
    bin/kafka-console-consumer.sh --bootstrap-server <broker_host>:6667 --topic test --from-beginning 
    --max-messages
39,480 Views
Comments
avatar
Expert Contributor

Using the ConsoleConsumer with old consumer is deprecated and will be removed in a future major release. Consider using the new consumer by passing [bootstrap-server] instead of [zookeeper].

@dbains you should update