Kafka:动态更新jaas配置

问题描述 投票:1回答:1

我使用sasl.jaas.config属性为kafka设置了jaas配置。我想更新此配置并动态添加用户。

按照这个文档 - http://kafka.apache.org/11/documentation.html#dynamicbrokerconfigs,我们可以通过使用bin/kafka-configs.sh来做到这一点。

上面的doc有config列,如下所示 - enter image description here

我尝试使用以下命令更新sasl.jaas.config

bin/kafka-configs.sh --bootstrap-server localhost:9092 --entity-type brokers --entity-name 59 --alter --add-config sasl.jaas.config="KafkaServer {\n org.apache.kafka.common.security.plain.PlainLoginModule required\n username=\"myuser\"\n password=\"mypassword\";\n};\nClient {\n org.apache.zookeeper.server.auth.DigestLoginModule required\n username=\"myuser2\"\n password=\"mypassword2\";\n};"

但它给了我以下错误:

requirement failed: Invalid entity config: all configs to be added must be in the format "key=val"

如果我查看上面的列,它说sasl.jaas.config属性的值的格式是(=)*。这意味着什么?

应该如何传递'sasl.jaas.config'的值来动态更新jaas配置?

configuration apache-kafka jaas broker
1个回答
2
投票

虽然可以动态更新sasl.jaas.config以添加更多用户,但默认的Plain登录模块不适用于生产。

相反,您应该定义回调处理程序来处理用户的身份验证。这在Kafka Sasl Plain docs中有描述。

另一个需要更多工作(但提供更大灵活性)的选项是创建自己的登录模块。该过程在Can Kafka be provided with custom LoginModule to support LDAP?中描述


关于你得到的错误信息,这似乎是kafka-config.sh工具的一个问题。它不期望配置值包含=。您应该能够使用AdminClient API更新该配置。

我在JIRA中找不到现有问题所以创建了一个新问题:https://issues.apache.org/jira/browse/KAFKA-8010

© www.soinside.com 2019 - 2024. All rights reserved.