栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Java

kafka配置sasl

Java 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

kafka配置sasl

版本: kafka_2.13-3.2.1

一. zookeeper 配置 1. zookeeper.properties 添加改下配置
authProvider.1=org.apache.zookeeper.server.auth.SASLAuthenticationProvider         
requireClientAuthScheme=sasl                                                       
jaasLoginRenew=3600000 
2. 创建zookeeper_jaas.conf
Server { 
	org.apache.kafka.common.security.plain.PlainLoginModule required 
	username="admin" 
	password="admin123" 
	user_admin="admin123"
	user_zkclient="zkclient123";
};

admin 是zk之间使用的
zkclient是broker与zk之间使用的

3. 添加zookeeper_jass.conf 到启动脚本
vi /bin/zookeeper-server-start.sh
export KAFKA_OPTS="-Djava.security.auth.login.config=/$path/kafka_2.13-3.2.1/config/zookeeper_jaas.conf -Dzookeeper.sasl.serverconfig=Server"
4. 启动zookeeper
./bin/zookeeper-server-start.sh config/zookeeper.properties
二. broker 配置 1. server.properties添加以下配置
listeners=SASL_PLAINTEXT://:9092
security.inter.broker.protocol=SASL_PLAINTEXT
sasl.mechanism.inter.broker.protocol=PLAIN
sasl.enabled.mechanisms=PLAIN
advertised.listeners=SASL_PLAINTEXT://:9092
auto.create.topics.enable=true
2. 创建 kafka_server_jaas.conf
KafkaServer { 
	org.apache.kafka.common.security.plain.PlainLoginModule required 
	username="kafkaadmin"
	password="kafkaadmin123"
	user_kafkaadmin="kafkaadmin123" 
	user_kafkatest="kafkatest000"; 
}; 
Client { 
	org.apache.zookeeper.server.auth.DigestLoginModule required
	username="zkclient" 
	password="zkclient123"; 
};
  • KafkaServer
    • kafkaadmin 是broker之前使用的
    • kafkatest 是client与broker之间使用的(kafkaadmin client可以用,通常做super)
  • Client
    • zkclient 是broker与zk之间使用的,须与zk配置一致,不然会验证出错
3. 添加conf 到启动脚本
vi bin/kafka-server-start.sh
export KAFKA_OPTS=" -Djava.security.auth.login.config=/$path/kafka_2.13-3.2.1/config/kafka_server_jaas.conf"
4. 启动broker
./bin/kafka-server-start.sh ./config/server.properties 
三. kafka client 配置 1. 创建kafka_client.conf
sasl.jaas.config=org.apache.kafka.common.security.plain.PlainLoginModule required 
    username="kafkaadmin" 
    password="kafkaadmin123";
security.protocol=SASL_PLAINTEXT
sasl.mechanism=PLAIN

此处使有kafkaadmin 和kafkatest 都行

创建topic
./bin/kafka-topics.sh --create --topic quickstart-events  --bootstrap-server localhost:9092 --command-config ./config/kafka_client.conf
topic 查看
./bin/kafka-topics.sh --describe  --topic quickstart-events  --bootstrap-server localhost:9092 --command-config ./config/kafka_client.conf

后续自行玩耍各种参数

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/1036338.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号