Prerequisite: Make sure that you have enabled access to the topic (via Ranger or native ACLs) for the user associated with the consumer process. We recommend that you use Ranger to manage permissions. For more information, see the Apache Ranger User Guide for Kafka.
During the installation process, Ambari configures a series of Kafka client and producer settings, and creates a JAAS configuration file for the Kafka client. It is not necessary to modify these values, but for more information see see Appendix A, Kafka Configuration Options.
Note: Only the Kafka Java API is supported for Kerberos. Third-party clients are not supported.
To consume events/messages:
Specify the path to the JAAS configuration file as one of your JVM parameters. For example:
-Djava.security.auth.login.config=/usr/hdp/current/kafka-broker/config/kafka_client_jaas.conf
For more information about the
kafka_client_jaas
file, see "JAAS Configuration File for the Kafka Client" in Kafka Configuration Options.kinit
with the principal's keytab.Launch
kafka-console-consumer.sh
with the following configuration settings. (Note: these settings are the same as in previous versions, except for the addition of--security-protocol SASL_PLAINTEXT
.)./bin/kafka-console-consumer.sh --zookeeper c6401.ambari.apache.org:2181 --topic test_topic --from-beginning --security-protocol SASL_PLAINTEXT
Troubleshooting
Issue: If you launch the consumer without specifying the
security-protocol
option, you will see the following
error:
2015-07-21 04:14:06,611] ERROR fetching topic metadata for topics [Set(test_topic)] from broker [ArrayBuffer(BrokerEndPoint(0,c6401.ambari.apache.org,6667), BrokerEndPoint(1,c6402.ambari.apache.org,6667))] failed (kafka.utils.CoreUtils$) kafka.common.KafkaException: fetching topic metadata for topics [Set(test_topic)] from broker [ArrayBuffer(BrokerEndPoint(0,c6401.ambari.apache.org,6667), BrokerEndPoint(1,c6402.ambari.apache.org,6667))] failed at kafka.client.ClientUtils$.fetchTopicMetadata(ClientUtils.scala:73) Caused by: java.io.EOFException: Received -1 when reading from channel, socket has likely been closed. at kafka.utils.CoreUtils$.read(CoreUtils.scala:193) at kafka.network.BoundedByteBufferReceive.readFrom(BoundedByteBufferReceive.scala:54)
Solution: Add --security-protocol
SASL_PLAINTEXT
to the kafka-console-consumer.sh
runtime options.