• kafka配置sasl


    版本: kafka_2.13-3.2.1

    一. zookeeper 配置

    1. zookeeper.properties 添加改下配置

    authProvider.1=org.apache.zookeeper.server.auth.SASLAuthenticationProvider         
    requireClientAuthScheme=sasl                                                       
    jaasLoginRenew=3600000 
    
    • 1
    • 2
    • 3

    2. 创建zookeeper_jaas.conf

    Server { 
    	org.apache.kafka.common.security.plain.PlainLoginModule required 
    	username="admin" 
    	password="admin123" 
    	user_admin="admin123"
    	user_zkclient="zkclient123";
    };
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7

    admin 是zk之间使用的
    zkclient是broker与zk之间使用的

    3. 添加zookeeper_jass.conf 到启动脚本

    vi /bin/zookeeper-server-start.sh
    export KAFKA_OPTS="-Djava.security.auth.login.config=/$path/kafka_2.13-3.2.1/config/zookeeper_jaas.conf -Dzookeeper.sasl.serverconfig=Server"
    
    • 1
    • 2

    4. 启动zookeeper

    ./bin/zookeeper-server-start.sh config/zookeeper.properties
    
    • 1

    二. broker 配置

    1. server.properties添加以下配置

    listeners=SASL_PLAINTEXT://:9092
    security.inter.broker.protocol=SASL_PLAINTEXT
    sasl.mechanism.inter.broker.protocol=PLAIN
    sasl.enabled.mechanisms=PLAIN
    advertised.listeners=SASL_PLAINTEXT://:9092
    auto.create.topics.enable=true
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6

    2. 创建 kafka_server_jaas.conf

    KafkaServer { 
    	org.apache.kafka.common.security.plain.PlainLoginModule required 
    	username="kafkaadmin"
    	password="kafkaadmin123"
    	user_kafkaadmin="kafkaadmin123" 
    	user_kafkatest="kafkatest000"; 
    }; 
    Client { 
    	org.apache.zookeeper.server.auth.DigestLoginModule required
    	username="zkclient" 
    	password="zkclient123"; 
    };
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • KafkaServer
      • kafkaadmin 是broker之前使用的
      • kafkatest 是client与broker之间使用的(kafkaadmin client可以用,通常做super)
    • Client
      • zkclient 是broker与zk之间使用的,须与zk配置一致,不然会验证出错

    3. 添加conf 到启动脚本

    vi bin/kafka-server-start.sh
    export KAFKA_OPTS=" -Djava.security.auth.login.config=/$path/kafka_2.13-3.2.1/config/kafka_server_jaas.conf"
    
    • 1
    • 2

    4. 启动broker

    ./bin/kafka-server-start.sh ./config/server.properties 
    
    • 1

    三. kafka client 配置

    1. 创建kafka_client.conf

    sasl.jaas.config=org.apache.kafka.common.security.plain.PlainLoginModule required \
        username="kafkaadmin" \
        password="kafkaadmin123";
    security.protocol=SASL_PLAINTEXT
    sasl.mechanism=PLAIN
    
    • 1
    • 2
    • 3
    • 4
    • 5

    此处使有kafkaadmin 和kafkatest 都行

    创建topic

    ./bin/kafka-topics.sh --create --topic quickstart-events  --bootstrap-server localhost:9092 --command-config ./config/kafka_client.conf
    
    • 1

    topic 查看

    ./bin/kafka-topics.sh --describe  --topic quickstart-events  --bootstrap-server localhost:9092 --command-config ./config/kafka_client.conf
    
    • 1

    后续自行玩耍各种参数

  • 相关阅读:
    【ubuntu】chmod命令
    JS-项目实战-点击水果名修改特定水果库存记录
    [源码解析] TensorFlow 分布式环境(7) --- Worker 动态逻辑
    互联网摸鱼日报(2023-10-19)
    半监督和无监督极限学习机(SS-US-ELM)(Matlab代码实现)
    在Form表单中对上传附件a-upload组件配置必填校验
    Kotlin注解
    华为云Stack南向开放框架,帮助生态伙伴高效入云
    音视频开发进阶——YUV与RGB的采样与存储格式
    windows nignx 常用操作命令(启动、停止、重启服务)
  • 原文地址:https://blog.csdn.net/u012385733/article/details/126163439