Kafka:动态更新 jaas 配置

Kafka : Update jaas config dynamically

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

根据此文档 - http://kafka.apache.org/11/documentation.html#dynamicbrokerconfigs,我们可以使用 bin/kafka-configs.sh.

上面的文档有配置栏,内容如下 -

我尝试使用以下命令更新 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 配置?

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

相反,您应该定义回调处理程序来处理用户身份验证。 Kafka Sasl Plain docs.

中对此进行了描述

另一个需要更多工作(但提供更多灵活性)的选项是创建您自己的登录模块。

中描述了该过程

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

更新该配置

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