kafka shell脚本

#!/bin/bash
# shell脚本头部

case $1 in

"start"){
  # in{} 当前目录kafka目录名字
  for i in {kafka1 kafka2 kafka3} ; do
      # echo用于字符串输出
      echo "$i 启动中"
      ssh $i "/opt/kafka/bin/kafka-server-start.sh -daemon /opt/kafka/config/server.properties"
  done
};;

"stop"){
  for i in {kafka1 kafka2 kafka3} ; do
      echo "$i 关闭中"
      ssh $i "/opt/kafka/bin/kafka-server-stop.sh /opt/kafka/config/server.properties"
  done
};;

esac

# 保存在文件中.文件名字为kk.sh   启动命令:kk.sh start 关闭命令:kk.sh stop

 

posted @ 2021-04-05 21:21  饭后咖啡  阅读(206)  评论(0编辑  收藏  举报