我一直在尝试使用SASL_PLAINTEXT SCRAM-SHA-256为我的Kafka Brokers添加SASL身份验证一段时间,但没有任何成功 . 我在Kafka的日志文件中不断收到以下错误 .

ERROR [Controller id = 0,targetBrokerId = 0]由于以下原因,与节点0的连接验证失败:由于SASL机制SCRAM-SHA-256(org.apache.kafka.clients.NetworkClient)的凭据无效,验证失败 .

但是我一直在关注SCRAM Config上的Kafka文档到这封信,并没有成功实现这一点 .

我使用kafka-configs.sh在Zookeeper上注册了一个管理员用户,如下所示:

bin/kafka-configs.sh --zookeeper localhost:2181 --alter --add-config 'SCRAM-SHA-256=[password=admin-secret],SCRAM-SHA-512=[password=admin-secret]' --entity-type users --entity-name admin

以下是我配置SCRAM-SHA-256的server.properties的一部分 .

broker.id=50
sasl.enabled.mechanisms=SCRAM-SHA-256
sasl.mechanism.inter.broker.protocol=SCRAM-SHA-256
security.inter.broker.protocol=SASL_PLAINTEXT
listeners=SASL_PLAINTEXT://172.16.3.21:9092
advertised.listeners=SASL_PLAINTEXT://172.16.3.21:9092
listener.name.sasl_plaintext.scram-sha-256.sasl.jaas.config=org.apache.kafka.common.security.scram.ScramLoginModule required \
    username="admin" \
    password="admin-secret";