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

相关推荐
未秃头的程序猿9 小时前
从零到一:深入浅出分布式锁原理与Spring Boot实战(Redis + ZooKeeper)
spring boot·分布式·后端
eSsO KERF10 小时前
RabbitMQ之交换机
分布式·rabbitmq·ruby
Albert Edison11 小时前
【RabbitMQ】Topics 通配符模式(使用案例)
分布式·rabbitmq
yaoyouzhong20 小时前
分布式与集群,二者区别是什么?
分布式
橙露21 小时前
SpringBoot 整合 MinIO:分布式文件存储上传下载
spring boot·分布式·后端
Ulyanov1 天前
Apache Kafka在雷达仿真数据流处理中的应用
分布式·python·kafka·apache·雷达电子战
路飞说AI1 天前
Kafka: 一条消息的完整“生命之旅”
kafka
Ssan PRIN1 天前
深度掌握 RabbitMQ 消息确认(ACK)机制,确保消息万无一失
分布式·rabbitmq
切糕师学AI1 天前
深入理解 CAP 定理:分布式系统中的一致性、可用性与分区容错
分布式·cap
indexsunny1 天前
互联网大厂Java面试实战:核心技术与微服务架构在电商场景中的应用
java·spring boot·redis·kafka·maven·spring security·microservices