kafka命令行生产者报错,无法启动命令行生产者报错!

报错信息如下

org.apache.kafka.common.KafkaException: Failed to construct kafka producer
at org.apache.kafka.clients.producer.KafkaProducer.(KafkaProducer.java:431)
at org.apache.kafka.clients.producer.KafkaProducer.(KafkaProducer.java:301)
at kafka.tools.ConsoleProducer$.main(ConsoleProducer.scala:45)
at kafka.tools.ConsoleProducer.main(ConsoleProducer.scala)
Caused by: org.apache.kafka.common.KafkaException: java.lang.IllegalArgumentException: Conflicting serviceName values found in JAAS and Kafka configs value in JAAS file impala, value in Kafka config kafka
at org.apache.kafka.common.network.SaslChannelBuilder.configure(SaslChannelBuilder.java:153)
at org.apache.kafka.common.network.ChannelBuilders.create(ChannelBuilders.java:140)
at org.apache.kafka.common.network.ChannelBuilders.clientChannelBuilder(ChannelBuilders.java:65)
at org.apache.kafka.clients.ClientUtils.createChannelBuilder(ClientUtils.java:108)
at org.apache.kafka.clients.producer.KafkaProducer.newSender(KafkaProducer.java:439)
at org.apache.kafka.clients.producer.KafkaProducer.(KafkaProducer.java:420)
… 3 more
Caused by: java.lang.IllegalArgumentException: Conflicting serviceName values found in JAAS and Kafka configs value in JAAS file impala, value in Kafka config kafka
at org.apache.kafka.common.security.kerberos.KerberosLogin.getServiceName(KerberosLogin.java:293)
at org.apache.kafka.common.security.kerberos.KerberosLogin.configure(KerberosLogin.java:92)
at org.apache.kafka.common.security.authenticator.LoginManager.(LoginManager.java:60)
at org.apache.kafka.common.security.authenticator.LoginManager.acquireLoginManager(LoginManager.java:111)
at org.apache.kafka.common.network.SaslChannelBuilder.configure(SaslChannelBuilder.java:142)

报错原因

因为配置了两个环境变量且两个环境变量配置的不一致!
export KAFKA_OPTS="$KAFKA_OPTS -Djava.security.krb5.conf=/etc/krb5.conf -Djava.security.auth.login.config=/opt/flink-1.8.1/conf/jaas.conf"

第一个配置,在命令行生产者脚本中。
kafka-console-producer.sh
第二个配置,配置在系统环境中,系统环境存在三种配置,以下只是其中一种。(https://www.cnblogs.com/jpfss/p/11107080.html)
/etc/profile

解决办法

删除脚本kafka-console-producer.sh中的相同配置

你可能感兴趣的:(灭霸)