码迷,mamicode.com
首页 > 其他好文 > 详细

kafka集群起停脚本

时间:2021-06-20 18:41:23      阅读:0      评论:0      收藏:0      [点我收藏+]

标签:$1   hup   脚本   main   输出   集群   ash   文件权限   权限   

脚本位置

cd /home/hadoop/bin

脚本内容

vi kafka.sh

#输入以下内容
#!/bin/bash
case $1 in
"start" ){
  for(( i = 1;i <= 3;i = $i +1));do
    echo ============ hadoop0$i kafka $1 ===================
    ssh hadoop$i "source /etc/profile;nohup kafka-server-start.sh /bigdata/install/kafka/config/server.properties >/dev/null 2>&1 &"
  done
};;
"stop" ){
  for(( i = 1;i <= 3;i = $i +1));do
    echo ============ hadoop0$i kafka $1 ===================
    ssh hadoop$i "source /etc/profile;kafka-server-stop.sh"
  done
};;
esac

修改文件权限

chmod 777 kafka.sh

执行脚本,验证脚本

# 先确保已经启动了zookeeper
kafka.sh start
xcall jps

# 输出以下内容
============= hadoop1 jps =============
9616 Jps
9267 Kafka
9191 QuorumPeerMain
============= hadoop2 jps =============
8291 Kafka
8213 QuorumPeerMain
8632 Jps
============= hadoop3 jps =============
7129 Kafka
7053 QuorumPeerMain
7470 Jps

kafka.sh stop
xcall jps

# 输出以下内容
============= hadoop1 jps =============
9191 QuorumPeerMain
9740 Jps
============= hadoop2 jps =============
8213 QuorumPeerMain
8748 Jps
============= hadoop3 jps =============
7585 Jps
7053 QuorumPeerMain

kafka集群起停脚本

标签:$1   hup   脚本   main   输出   集群   ash   文件权限   权限   

原文地址:https://www.cnblogs.com/tenic/p/14906807.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!