
就是我的经历 stackoverflow question, 分享一下
更多安全配置,参见 https://kafka.apache.org/documentation/#security
listeners=PLAINTEXT://localhost:9092, SASL_PLAINTEXT://localhost:9093
security.inter.broker.protocol=SASL_PLAINTEXT
sasl.mechanism.inter.broker.protocol=PLAIN
sasl.enabled.mechanisms=PLAIN
# we can also specify the sasl config information instead of using the followign cinfig file 'kafka_jaas.conf'
listener.name.sasl_plaintext.plain.sasl.jaas.config=org.apache.kafka.common.security.plain.PlainLoginModule required \
username="admin"
password="admin-secret"
user_admin="admin-secret"
user_alice="alice-secret";sasl_plaintext.KafkaServer{
org.apache.kafka.common.security.plain.PlainLoginModule required
username="admin"
password="admin-secret"
user_admin="admin-secret"
user_alice="alice-secret";
};set JAAS_OPTS=-Djava.security.auth.login.config=file:%~dp0../../config/kafka_jaas.confset COMMAND=%JAVA% %KAFKA_HEAP_OPTS% %KAFKA_JVM_PERFORMANCE_OPTS% %KAFKA_JMX_OPTS% %KAFKA_LOG4J_OPTS% %JAAS_OPTS% -cp "%CLASSPATH%" %KAFKA_OPTS% %*zookeeper-server-start.bat .\config\zookeeper.properties
kafka-server-start.bat .\config\server.propertiesbootstrap.servers=localhost:9092, localhost:9093kafka-topics.bat --create --topic gaming-events --bootstrap-server localhost:9092kafka-console-consumer.bat --topic gaming-events --from-beginning --bootstrap-server localhost:9092kafka-console-producer.bat --topic gaming-events --bootstrap-server localhost:9092security.protocol=SASL_PLAINTEXT
sasl.mechanism=PLAINsasl.jaas.config=org.apache.kafka.common.security.plain.PlainLoginModule required username="alice" password="alice-secret";kafka-console-consumer.bat --topic gaming-events --from-beginning --bootstrap-server localhost:9093 --consumer.config .\config\consumer.properties
kafka-console-producer.bat --topic gaming-events --bootstrap-server localhost:9093 --producer.config .\config\producer.propertiesKafkaClient {
org.apache.kafka.common.security.plain.PlainLoginModule required
username="alice"
password="alice-secret";
};sasl.jaas.config=org.apache.kafka.common.security.plain.PlainLoginModule required username="alice" password="alice-secret";set JAAS_OPTS=-Djava.security.auth.login.config=file:%~dp0../../config/kafka_jaas.confkafka-console-consumer.bat --topic gaming-events --from-beginning --bootstrap-server localhost:9093 --consumer.config .\config\consumer.properties
kafka-console-producer.bat --topic gaming-events --bootstrap-server localhost:9093 --producer.config .\config\producer.properties原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。