赞
踩
在实际使用Kafka消费的时候我们往往会遇到加密的Kafka集群。
鉴权kafka生产端(SCRAM)
cd /app/kafka_2.11-1.1.1
vi config/client-sasl.properties
security.protocol=SASL_PLAINTEXT
sasl.mechanism=SCRAM-SHA-256
配置config文件指定账号密码:
vi config/kafka_client_jaas_admin.conf
KafkaClient {
org.apache.kafka.common.security.scram.ScramLoginModule required
username="admin"
password="admin-secret";
};
这里可以省略
vi config/consumer-admin.properties
security.protocol=SASL_PLAINTEXT
sasl.mechanism=SCRAM-SHA-256
#group.id=sitech-group
cp bin/kafka-console-consumer.sh bin/kafka-console-consumer-admin.sh
vi bin/kafka-console-consumer-admin.sh
#exec $(dirname $0)/kafka-run-class.sh kafka.tools.ConsoleConsumer "$@"
exec $(dirname $0)/kafka-run-class.sh -Djava.security.auth.login.config=$(dirname $0)/../config/kafka_client_jaas_admin.conf kafka.tools.ConsoleConsumer "$@"
sh bin/kafka-console-consumer-admin.sh --bootstrap-server ip1:port1,ip2:port2,ip3:port3 --topic flink2KafkaTestSrc --consumer.config ./config/client-sasl.properties
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。