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博客

相关推荐
凹凸曼说我是怪兽y1 小时前
Redis分布式锁详细实现演进与Redisson深度解析
数据库·redis·分布式
AKAMAI11 小时前
分布式边缘推理正在改变一切
人工智能·分布式·云计算
慧一居士11 小时前
xxl-job服务搭建,以及 springboot 集成xxl-job 项目完整步骤示例
分布式·中间件
oMcLin16 小时前
如何在 Ubuntu 22.04 服务器上实现分布式数据库 Cassandra 集群,优化数据一致性与写入吞吐量
服务器·分布式·ubuntu
2501_9418824817 小时前
互联网分布式系统中的性能优化工程实践与多语言示例随笔分享
kafka·rabbitmq
零度@18 小时前
Java消息中间件-Kafka全解(2026精简版)
java·kafka·c#·linq
2501_9418714518 小时前
从接口限流到全链路流控的互联网工程语法构建与多语言实践分享
kafka·rabbitmq
马达加斯加D19 小时前
系统设计 --- 使用消息队列解决分布式事务
分布式
遇见火星20 小时前
RabbitMQ 高可用:HAProxy 负载均衡实战指南
分布式·消息队列·rabbitmq·负载均衡·haproxy
Blossom.11821 小时前
基于多智能体协作的自动化数据分析系统实践:从单点工具到全流程智能
运维·人工智能·分布式·智能手机·自动化·prompt·边缘计算