kafka 开启用户认证

1.kafka_server_jaas.conf

复制代码
KafkaServer {  
   org.apache.kafka.common.security.plain.PlainLoginModule required  
   username="admin"  
   password="admin"  
   user_admin="admin"  
   user_reader="reader"
   user_writer="writer";  
};

2.kafka_client_jaas.conf

复制代码
KafkaClient {
   org.apache.kafka.common.security.plain.PlainLoginModule required
   username="writer"  
   password="writer";   
};

3.server.properties

复制代码
#开启超级用户
super.user.name=admin
super.user.password=admin@2023

############################# Server Basics #############################

broker.id=0

############################# Socket Server Settings #############################
#开启ACL
authorizer.class.name=kafka.security.auth.SimpleAclAuthorizer
#使用SASL_PLAINTEXT协议
listeners=SASL_PLAINTEXT://127.0.0.1:9092  
#Broker之间不启用ssl
security.inter.broker.protocol=SASL_PLAINTEXT 
#PLAIN认证
sasl.enabled.mechanisms=PLAIN
#broker之间开启PLAIN认证
sasl.mechanism.inter.broker.protocol=PLAIN  


allow.everyone.if.no.acl.found=true

num.network.threads=3

num.io.threads=8

socket.send.buffer.bytes=102400

socket.receive.buffer.bytes=102400

socket.request.max.bytes=104857600


############################# Log Basics #############################
log.dirs=/data/kafka/kafka_data/log/kafka

num.partitions=1

num.recovery.threads.per.data.dir=1

############################# Internal Topic Settings  #############################
offsets.topic.replication.factor=1
transaction.state.log.replication.factor=1
transaction.state.log.min.isr=1

############################# Log Flush Policy #############################
#log.flush.interval.messages=10000

#log.flush.interval.ms=1000

############################# Log Retention Policy #############################
log.retention.hours=168

#log.retention.bytes=1073741824

log.segment.bytes=1073741824

log.retention.check.interval.ms=300000

############################# Zookeeper #############################
zookeeper.connect=10.22.245.173:2181

zookeeper.connection.timeout.ms=6000

############################# Group Coordinator Settings #############################
group.initial.rebalance.delay.ms=0
port=9092 
host.name=127.0.0.1
zookeeper.connect=127.0.0.1:2181

4.consumer.properties

复制代码
security.protocol=SASL_PLAINTEXT

sasl.mechanism=PLAIN

5.producer.properties

复制代码
security.protocol=SASL_PLAINTEXT

sasl.mechanism=PLAIN

6.kafka-server-start.sh

复制代码
export KAFKA_OPTS=" -Djava.security.auth.login.config=/data/kafka/kafka2.3/config/kafka_server_jaas.conf"

参考 kafka 设置用户密码和通过SpringBoot测试_kafka设置密码-CSDN博客

相关推荐
掘金-我是哪吒7 分钟前
分布式微服务系统架构第158集:JavaPlus技术文档平台日更-JVM基础知识
jvm·分布式·微服务·架构·系统架构
东窗西篱梦41 分钟前
Redis集群部署指南:高可用与分布式实践
数据库·redis·分布式
Acrel_Fanny42 分钟前
Acrel-1000系列分布式光伏监控系统在湖北荆门一马光彩大市场屋顶光伏发电项目中应用
分布式
xufwind1 小时前
spark standlone 集群离线安装
大数据·分布式·spark
半新半旧2 小时前
Redis集群和 zookeeper 实现分布式锁的优势和劣势
redis·分布式·zookeeper
亲爱的非洲野猪2 小时前
Kafka “假死“现象深度解析与解决方案
分布式·kafka
CodeWithMe2 小时前
【Note】《Kafka: The Definitive Guide》第三章: Kafka 生产者深入解析:如何高效写入 Kafka 消息队列
分布式·kafka
虾条_花吹雪2 小时前
2、Connecting to Kafka
分布式·ai·kafka
Edingbrugh.南空4 小时前
Hadoop高可用集群搭建
大数据·hadoop·分布式
Bug退退退1235 小时前
RabbitMQ 高级特性之重试机制
java·分布式·spring·rabbitmq