vim /opt/kafka_server_jaas.conf #其中kafka为admin用户,格式:user_用户名="密码" KafkaServer { org.apache.kafka.common.security.plain.PlainLoginModule required username="kafka" password="kafka-secret" user_kafka="kafka-secret" user_test="test-secret"; }; vim /opt/kafka_client_jaas.conf KafkaClient { org.apache.kafka.common.security.plain.PlainLoginModule required username="kafka" password="kafka-secret"; };页面修改配置
listeners --> SASL_PLAINTEXT://localhost:6667 sasl.enabled.mechanisms --> PLAIN sasl.mechanism.inter.broker.protocol --> PLAIN security.inter.broker.protocol --> SASL_PLAINTEXT
添加配置 export KAFKA_OPTS="-Djava.security.auth.login.config=/opt/kafka_server_jaas.conf"
添加配置 super.users --> User:kafka修改配置
**在 conf/consumer.properties、conf/producer.properties 添加以下两行** security.protocol=SASL_PLAINTEXT sasl.mechanism=PLAIN 需要在 kafka-console-consumer.sh、kafka-console-producer.sh 添加 -Djava.security.auth.login.config=/opt/kafka_client_jaas.conf 修改后: exec $(dirname )/kafka-run-class.sh -Djava.security.auth.login.config=/opt/kafka_client_jaas.conf kafka.tools.ConsoleProducer "$@" 消费: bin/kafka-console-consumer.sh --bootstrap-server ambari1:6667 --topic topic01 --from-beginning --consumer.config conf/consumer.properties --group test-consumer-group 生产: bin/kafka-console-producer.sh --broker-list ambari1:6667 --topic topic01 --producer.config conf/producer.properties
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)