• kafka单机部署


    进入/home/appuser/application文件夹,将kafka安装包上传至此处

    解压安装包并改名:

    1. tar -xvf kafka_2.13-3.3.1.tgz
    2. mv kafka_2.13-3.3.1.tgz kafka

    在kafka文件夹下创建zookeeper数据文件夹,kafka和zookeeper的日志文件存放文件夹:

    1. mkdir zookeeper
    2. mkdir log
    3. cd log
    4. mkdir zookeeper
    5. mkdir kafka

    修改相关配置文件:

    zookeeper.properties:

    1. authProvider.1=org.apache.zookeeper.server.auth.SASLAuthenticationProvider
    2. requireClientAuthScheme=sasl
    3. jaasLoginRenew=3600000
    4. dataDir=/home/appuser/application/kafka/zookeeper
    5. #zookeeper端口
    6. clientPort=2282
    7. tickTime=2000
    8. initLimit=10
    9. syncLimit=5
    10. server.0=当前服务器ip:2999:3999

    server.properties:

    1. broker.id=0
    2. listeners=SASL_PLAINTEXT://当前服务器ip:9092
    3. advertised.listeners=SASL_PLAINTEXT://当前服务器ip:9092
    4. security.inter.broker.protocol=SASL_PLAINTEXT
    5. sasl.enabled.mechanisms=PLAIN
    6. sasl.mechanism.inter.broker.protocol=PLAIN
    7. authorizer.class.name=kafka.security.authorizer.AclAuthorizer
    8. allow.everyone.if.no.acl.found=true
    9. super.users=User:admin
    10. zookeeper.set.acl=true
    11. log.dirs=/home/appuser/application/kafka/log/kafka
    12. zookeeper.connect=当前服务器ip:2282

    密码校验

    新建jaas.conf文件,放置在kafka/config下

    配置如下:

    1. Server {
    2. org.apache.kafka.common.security.plain.PlainLoginModule required
    3. username="admin"
    4. password="admin@1234"
    5. user_kafka="admin@1234"
    6. user_admin="admin@1234";
    7. };
    8. Client {
    9. org.apache.kafka.common.security.plain.PlainLoginModule required
    10. username="kafka"
    11. password="admin@1234";
    12. };
    13. KafkaServer {
    14. org.apache.kafka.common.security.plain.PlainLoginModule required
    15. username="kafka"
    16. password="admin@1234"
    17. user_admin="admin@1234"
    18. user_kafka="admin@1234";
    19. };
    20. KafkaClient {
    21. org.apache.kafka.common.security.plain.PlainLoginModule required
    22. username="kafka"
    23. password="admin@1234";
    24. };

    将jaas.conf文件加入到kafka启动脚本(/kafka/bin/kafka-server-start.sh)和zookeeper启动脚本(/kafka/bin/zookeeper-server-start.sh)中:

    1. if [ "x$KAFKA_HEAP_OPTS" = "x" ]; then
    2. export KAFKA_HEAP_OPTS="-Xmx1G -Xms1G -Djava.security.auth.login.config=/home/appuser/application/kafka/config/jaas.conf"
    3. fi
    4. if [ "x$KAFKA_HEAP_OPTS" = "x" ]; then
    5. export KAFKA_HEAP_OPTS="-Xmx512M -Xms512M -Djava.security.auth.login.config=/home/appuser/application/kafka/config/jaas.conf"
    6. fi

    启动服务

    进入kafka目录,执行如下命令:

    1. nohup ./bin/zookeeper-server-start.sh ./config/zookeeper.properties >./log/zookeeper/zookeeper.log 2>1 &
    2. nohup ./bin/kafka-server-start.sh ./config/server.properties >./log/kafka/kafka.log 2>1 &

  • 相关阅读:
    Java 8中stream流处理(入门教程)
    .NET Core(.NET6)中gRPC使用
    力扣(LeetCode)323. 无向图中连通分量的数目(2022.11.20)
    八叉树(Octree)和KD树区别?2d tree与3d tree区别?
    10个问题带你看懂 Compose Multiplatform 1.0
    【MySQL从入门到精通】【高级篇】(五)MySQL的SQL语句执行流程
    @Elasticsearch之深度应用及原理剖析--文档搜索机制剖析
    [Django 0-1] Core.Cache模块
    敏捷12原则
    【C语言指针】用指针提升数组的运算效率
  • 原文地址:https://blog.csdn.net/weixin_44076260/article/details/133988986