如何从 Kafka cli 访问 SASL 配置 kafka

Upe*_*dra 6 sasl apache-kafka

我有一个 SASL PLAIN 配置的 Kafka,但无法使用 cli 连接到它,并且文档不清楚。以下是我现在正在使用的命令。

bin/kafka-topics.sh --list --bootstrap-server localhost:9093
Run Code Online (Sandbox Code Playgroud)

任何帮助将不胜感激。

Mic*_*son 13

Kafka 文档中有一节详细介绍了使用 SASL Plain 连接到集群所需的配置: https: //kafka.apache.org/documentation/#security_sasl_plain_clientconfig

它列出了以下设置:

security.protocol=SASL_SSL
sasl.mechanism=PLAIN
sasl.jaas.config=org.apache.kafka.common.security.plain.PlainLoginModule required \
        username="alice" \
        password="alice-secret";
Run Code Online (Sandbox Code Playgroud)

显然,根据 SSL 配置,您可能需要添加一些额外的设置,请参阅https://kafka.apache.org/documentation/#security_configclients

将所有这些设置放在一个文件中,然后您可以--command-config在使用时使用kafka-topics.sh. 例如:

bin/kafka-topics.sh --list --bootstrap-server localhost:9093 --command-config /path/to/file.properties
Run Code Online (Sandbox Code Playgroud)