• CentOS7 kafka安装


    cd /opt
    下载对应的kafka https://mirrors.tuna.tsinghua.edu.cn/apache/kafka/
    tar -xvf kafka_2.12-2.2.1.tgz -C /opt
    
    修改对应的配置
    #集群内id从0开始,不能重复
    sed -i 's$broker.id=0$broker.id=1$g' /opt/kafka_2.12-2.2.1/config/server.properties
    #替换为当前节点ip
    sed -i 's$#listeners=PLAINTEXT://:9092$listeners=PLAINTEXT://192.168.6.117:9092$g' /opt/kafka_2.12-2.2.1/config/server.properties
    #设置副本数量为3(默认1)
    sed -i 's$num.partitions=1$num.partitions=3$g' /opt/kafka_2.12-2.2.1/config/server.properties
    #设置zk
    sed -i 's$zookeeper.connect=localhost:2181$zookeeper.connect=192.168.6.117:2181,192.168.6.118:2181,192.168.6.119:2181$g' /opt/kafka_2.12-2.2.1/config/server.properties
    #设置超时时间
    sed -i 's$zookeeper.connection.timeout.ms=6000$zookeeper.connection.timeout.ms=60000$g' /opt/kafka_2.12-2.2.1/config/server.properties
    
    
    #启动kafka
    ./kafka-server-start.sh -daemon ../config/server.properties
    
    #增加kafka服务并设置为开机启动
    cat > /usr/lib/systemd/system/kafka.service <<"EOF"
    [Unit]
    Description=Kafka service
    After=network.target zookeeper.service
    
    [Service]
    Type=simple
    PIDFile=/var/run/kafka.pid
    ExecStart=/opt/kafka_2.12-2.2.1/bin/kafka-server-start.sh ../config/server.properties
    ExecStop=/opt/kafka_2.12-2.2.1/bin/kafka-server-stop.sh
    
    [Install]
    WantedBy=multi-user.target
    EOF
    
    systemctl daemon-reload
    systemctl enable kafka
    
    
    #定期清理日志
    cat > /opt/kafka_2.12-2.2.1/bin/clean_kafka_logs.sh << "EOF"
    #!/bin/bash
    find /opt/kafka_2.12-2.2.1/logs/ -type f -mtime +7|xargs rm -rf
    EOF
    
    chmod +x /opt/kafka_2.12-2.2.1/bin/clean_kafka_logs.sh
    
    执行crontab -e,加入一行
    0 0 * * * /bin/bash /opt/kafka_2.12-2.2.1/bin/clean_kafka_logs.sh
    
    调整已有topic副本数目
    
    kafka-topics.sh --alter --zookeeper localhost:2181 --partitions 10 --topic mytopic
  • 相关阅读:
    事件总线2
    微信小程序视频录制教程
    vue插件开发-toast
    云计算中的测试,可从哪些维度入手
    ES配置及FAQ
    Azkaban安装及问题
    python 反编译 compileall
    平凡利用redis进行数据读写的一种优化
    彻底弄懂Redis的内存淘汰策略
    c# 判断年龄精确到日
  • 原文地址:https://www.cnblogs.com/xiaochangwei/p/kafka-install.html
Copyright © 2020-2023  润新知