• 【4】Kafka集群启动/关闭脚本


    说明:本脚本基于SSH服务器免密登录,如集群未配置SSH,参照:《SSH安装配置》 。

    一、启动脚本:start-kafka-cluster.sh

    #!/bin/bash
    brokers="server1 server2 server3"
    KAFKA_HOME="/usr/local/services/kafka/kafka_2.11-2.3.0"
    KAFKA_NAME="kafka_2.11-2.3.0"
    
    echo "INFO : Begin to start kafka cluster ..."
    
    for broker in $brokers
    do
      echo "INFO : Starting ${KAFKA_NAME} on ${broker} ..."
      ssh ${broker} -C "source /etc/profile; sh ${KAFKA_HOME}/bin/kafka-server-start.sh -daemon ${KAFKA_HOME}/config/server.properties"
      if [[ $? -eq 0 ]]; then
          echo "INFO:[${broker}] Start successfully"
      fi
    done
    echo "INFO:Kafka cluster starts successfully !"
    

    为脚本添加执行权限:

    chmod a+x start-kafka-cluster.sh
    

    二、停止脚本:stop-kafka-cluster.sh

    #!/bin/bash
    brokers="server1 server2 server3"
    KAFKA_HOME="/usr/local/services/kafka/kafka_2.11-2.3.0"
    KAFKA_NAME="kafka_2.11-2.3.0"
    
    echo "INFO : Begin to stop kafka cluster ..."
    
    for broker in $brokers
    do
      echo "INFO : Shut down ${KAFKA_NAME} on ${broker} ..."
      ssh ${broker} "source /etc/profile;bash ${KAFKA_HOME}/bin/kafka-server-stop.sh"
      if [[ $? -ne 0 ]]; then
          echo "INFO : Shut down ${KAFKA_NAME} on ${broker} is down"
      fi
    done
    
    echo "INFO : kafka cluster shut down completed!"
    

    为脚本添加执行权限:

    chmod a+x stop-kafka-cluster.sh
    

    参考资料

    参考书籍:Kafka入门与实践

  • 作者: DeepInThought
    出处: https://www.cnblogs.com/DeepInThought
    本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。
  • 相关阅读:
    A Survey of Deep Clustering Algorithms
    随机傅里叶特征(Random Fourier Features)
    MATLAB实例:二元高斯分布图
    MATLAB实例:PCA(主成成分分析)详解
    MATLAB用“fitgmdist”函数拟合高斯混合模型(一维数据)
    Extreme Learning Machine
    在MATLAB R2018b中配置VLFeat
    Deep Clustering Algorithms
    机器学习优化算法
    sql注入总结
  • 原文地址:https://www.cnblogs.com/DeepInThought/p/11143981.html
  • Copyright © 2020-2023  润新知