gpt4 book ai didi

apache-kafka - 卡夫卡 : Connection to node failed authentication due to: Authentication failed due to invalid credentials with SASL mechanism SCRAM-SHA-256

转载 作者:行者123 更新时间:2023-12-04 16:04:48 30 4
gpt4 key购买 nike

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

ERROR [Controller id=0, targetBrokerId=0] Connection to node 0 failed authentication due to: Authentication failed due to invalid credentials with SASL mechanism 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";

最佳答案

在一个节点上生成 CA 并将其复制到其他节点手动为我工作
步骤 1- 在每个节点上运行它
keytool -keystore server.keystore.jks -alias kafka -dname "cn=kafka, ou= it , o= stackoverflow , l= “1094”, 710 alpha = 测试版,c=中“-storepass test123-validity 365-keyalg RSA-genkey-ext SAN=DNS:,“167091919”,“DNS”1670194” kafka-host2 ,DNS: kafka-host3 ,DNS:localhost,DNS:kafka
第 2 步 - 验证证书
keytool -list -v -keystore server.keystore.jks
第 3 步 - 在单个节点上生成一次,然后复制到其他节点。
openssl req -new -x509 -keyout ca-key -out ca-cert -days 365 -subj "/C=IN/ST= beta /O= stackoverflow /OU= /L=阿尔法/CN=卡夫卡
其余步骤需要在每个节点上运行
keytool -keystore server.truststore.jks -alias CARoot -import -file ca-cert -storepass test123 -noprompt
keytool -keystore client.truststore.jks -alias CARoot -import -file ca-cert -storepass test123 -noprompt
keytool -keystore server.keystore.jks -alias kafka -certreq -file cert-file -storepass test123
openssl x509 -req -CA ca-cert -CAkey ca-key -in cert-file -out cert-signed -days 3650 -CAcreateserial -passin pass:test123
keytool -keystore server.keystore.jks -alias CARoot -import -file ca-cert -storepass test123 -noprompt
keytool -keystore server.keystore.jks -alias kafka -import -file cert-signed -storepass test123 -noprompt

关于apache-kafka - 卡夫卡 : Connection to node failed authentication due to: Authentication failed due to invalid credentials with SASL mechanism SCRAM-SHA-256,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50684904/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com