Kafka - 在JAAS配置java中找不到'KafkaClient'条目

时间:2018-06-04 16:25:19

标签: apache-spark apache-kafka kerberos

我在简单的卡夫卡消费者计划中遇到了一些麻烦:

18/06/04 18:13:49 ERROR /log/log.txt: org.apache.kafka.common.KafkaException: Failed to construct kafka consumer
org.apache.kafka.common.KafkaException: Failed to construct kafka consumer
        at org.apache.kafka.clients.consumer.KafkaConsumer.<init>(KafkaConsumer.java:647)
        at org.apache.kafka.clients.consumer.KafkaConsumer.<init>(KafkaConsumer.java:542)
        at org.apache.kafka.clients.consumer.KafkaConsumer.<init>(KafkaConsumer.java:524)
        at com.carrefour.entequadratura.KafkaHandler.createConsumer(KafkaHandler.java:96)
        at com.carrefour.entequadratura.KafkaHandler.runConsumer(KafkaHandler.java:104)
        at com.carrefour.entequadratura.Main.main(Main.java:48)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at org.apache.spark.deploy.SparkSubmit$.org$apache$spark$deploy$SparkSubmit$$runMain(SparkSubmit.scala:730)
        at org.apache.spark.deploy.SparkSubmit$.doRunMain$1(SparkSubmit.scala:181)
        at org.apache.spark.deploy.SparkSubmit$.submit(SparkSubmit.scala:206)
        at org.apache.spark.deploy.SparkSubmit$.main(SparkSubmit.scala:121)
        at org.apache.spark.deploy.SparkSubmit.main(SparkSubmit.scala)
Caused by: org.apache.kafka.common.KafkaException: java.lang.IllegalArgumentException: Could not find a 'KafkaClient' entry in the JAAS configuration. System property 'java.security.auth.login.config' is not set
        at org.apache.kafka.common.network.SaslChannelBuilder.configure(SaslChannelBuilder.java:74)
        at org.apache.kafka.common.network.ChannelBuilders.create(ChannelBuilders.java:60)
        at org.apache.kafka.clients.ClientUtils.createChannelBuilder(ClientUtils.java:79)
        at org.apache.kafka.clients.consumer.KafkaConsumer.<init>(KafkaConsumer.java:577)
        ... 14 more
Caused by: java.lang.IllegalArgumentException: Could not find a 'KafkaClient' entry in the JAAS configuration. System property 'java.security.auth.login.config' is not set
        at org.apache.kafka.common.security.kerberos.Login.login(Login.java:295)
        at org.apache.kafka.common.security.kerberos.Login.<init>(Login.java:104)
        at org.apache.kafka.common.security.kerberos.LoginManager.<init>(LoginManager.java:44)
        at org.apache.kafka.common.security.kerberos.LoginManager.acquireLoginManager(LoginManager.java:85)
        at org.apache.kafka.common.network.SaslChannelBuilder.configure(SaslChannelBuilder.java:55)
        ... 17 more

这些是我的财产:

BOOTSTRAP_SERVERS=xxxxxxxxxxxxxxxxxx:6667
GROUP_ID=EnteLoader
AUTO_COMMIT=false
AUTO_COMMIT_INTERVAL=10000
SESSION_TIMEOUT=30000
MAX_POLL_RECORDS=5
KEY_DESERIALIZER=org.apache.kafka.common.serialization.StringDeserializer
VALUE_DESERIALIZER=org.apache.kafka.common.serialization.StringDeserializer
SECURITY_PROTOCOL=SASL_PLAINTEXT
SASL_MECHANISM=GSSAPI
SASL_KERBEROS_SERVICE_NAME=kafka

我读到这可能是一个与jaas.conf相关的可能问题,但我是Kafka的新手,我不知道如何找到它..

你能帮帮我吗? 谢谢!

1 个答案:

答案 0 :(得分:0)

检查您的 application.properties 是否设置为 kafka.security.protocol=SASL_PLAINTEXT

然后需要在您的财产中设置 JAAS 身份验证。 System.setProperty("java.security.auth.login.config","/File_Location/jaas.conf");

如果您使用身份验证测试本地。将身份验证协议设置为纯文本

kafka.security.protocol=PLAINTEXT

它经过测试的代码。对我来说很好。