在'/kafka/kafka_2.12-2.3.0/config/zookeeper_jaas.conf'

时间:2019-07-29 16:34:12

标签: apache-kafka apache-zookeeper jaas apache-kafka-security

当我从kakfa_2.12-2.3.0中的程序包运行zookeeper时,出现以下错误

$ export KAFKA_OPTS="-Djava.security.auth.login.config=/kafka/kafka_2.12-2.3.0/config/zookeeper_jaas.conf"
    $ ./bin/zookeeper-server-start.sh  config/zookeeper.properties

zookeeper_jaas.conf

KafkaServer {
   org.apache.kafka.common.security.plain.PlainLoginModule required
   username="admin"
   password="admin-secret"
   user_admin="admin-secret";
};

zookeeper.properties文件

server=localhost:9092
#server=localhost:2888:3888
sasl.jaas.config=org.apache.kafka.common.security.plain.PlainLoginModule required username="ibm" password="ibm-secret";

security.protocol=SASL_SSL
sasl.mechanism=PLAIN
ssl.truststore.location=**strong text**/kafka/apache-zookeeper-3.5.5-bin/zookeeperkeys/client.truststore.jks
ssl.truststore.password=test1234

 authProvider.1=org.apache.zookeeper.server.auth.SASLAuthenticationProvider 
 jaasLoginRenew=3600000 
 requireClientAuthScheme=sasl 

任何人都可以提出原因

1 个答案:

答案 0 :(得分:3)

您似乎已经将一堆Kafka SASL配置混入了Zookeeper配置文件中。 Zookeeper和Kafka都具有不同的SASL支持,因此无法正常工作。

我猜您想在Kafka和Zookeeper之间启用SASL身份验证。在这种情况下,您需要遵循Zookeeper服务器-客户端指南:https://cwiki.apache.org/confluence/display/ZOOKEEPER/Client-Server+mutual+authentication

Zookeeper不支持SASL Plain,但DigestMD5非常相似。在这种情况下,您的jaas.conf文件应如下所示:

Server {
   org.apache.zookeeper.server.auth.DigestLoginModule required
   user_super="adminsecret"
   user_bob="bobsecret";
};

然后,您需要配置您的Kafka代理以使用SASL连接到Zookeeper。您可以使用另一个jaas.conf文件(这次将其加载到Kafka中)进行操作:

Client {
   org.apache.zookeeper.server.auth.DigestLoginModule required
   username="bob"
   password="bobsecret";
};

注意:您还可以在Zookeeper服务器之间启用SASL。为此,请遵循服务器-服务器指南:https://cwiki.apache.org/confluence/display/ZOOKEEPER/Server-Server+mutual+authentication