当前位置:   article > 正文

Kafka安全认证SASL/PLAIN,并和springBoot整合_kafka2.6.2 开启了sals spring boot如何连接

kafka2.6.2 开启了sals spring boot如何连接

kafka_2.11-1.1.0.tgz、zookeeper-3.4.10.tar.gz版本

1. kafka配置

kafka解压目录下工作

# 1.新建配置文件
vi ./config/kafka_server_jaas.conf
# 文件内容
# username定义一个公共的用户名,用于节点之间进行通信,user_xxxx主要是客户端用来连接kafka的,等号后面是密码,xxxxx是用户名,这里大小写一个字都不能差,除了用户名和密码
KafkaServer {
  org.apache.kafka.common.security.plain.PlainLoginModule required
    username="admin"
    password="admin-sec"
    user_admin="admin-sec"
    user_producer="prod-sec"
    user_consumer="cons-sec";
};
# 2.修改kafka启动时的配置文件,server.properties
# 我的做法是复制一份
cp ./config/server.properties ./config/server_sasl.properties
# 修改内容如下,在文末添加如下内容:
# 注意点:192.168.186.130是我当前主机ip,9092是kafka通信端口,其他的地方保持一致
listeners=SASL_PLAINTEXT://192.168.186.130:9092
security.inter.broker.protocol=SASL_PLAINTEXT
sasl.enabled.mechanisms=PLAIN
sasl.mechanism.inter.broker.protocol=PLAIN
authorizer.class.name=kafka.security.auth
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/weixin_40725706/article/detail/951012
推荐阅读
相关标签
  

闽ICP备14008679号