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

相关推荐
Evand J5 小时前
【MATLAB例程】5个UAV 分布式围捕编队运动仿真 —— 基于PID控制
开发语言·分布式·matlab
heimeiyingwang7 小时前
【架构实战】Kafka深度实战:从消息队列到流处理平台
架构·kafka·linq
蓝眸少年CY7 小时前
Spark - Code 核心教程
大数据·分布式·spark
敖正炀7 小时前
CAP 定理、BASE 理论与一致性模型深度
分布式
青云计划8 小时前
kafka从入门到精通
kafka
倒流时光三十年8 小时前
第9篇 消息不丢:三端协同防丢失方案
spring boot·kafka
勤自省9 小时前
ROS2分布式通信与Launch文件实战:从踩坑到打通(第12-20讲总结)
分布式·ubuntu·ros2·gazebo·launch·rqt·rviz2
明明跟你说过1 天前
Kafka 与 Elasticsearch 的集成应用案例深度解析
大数据·elk·elasticsearch·kafka·big data·bigdata
lifewange1 天前
Nginx + Kafka 可编程精细控制 完整版(可直接落地运行)
运维·nginx·kafka
qq_452396231 天前
第十三篇:《分布式压测:JMeter Master-Slave集群》
分布式·jmeter