当前位置: 代码迷 >> 综合 >> 黑猴子的家:kafka.sh
  详细解决方案

黑猴子的家:kafka.sh

热度:97   发布时间:2023-09-14 21:30:02.0

在/usr/local/bin 目录下

[alex@hadoop102 ~]$ cd /usr/local/bin/
[alex@hadoop102 bin]$ sudo touch kafka.sh
[alex@hadoop102 bin]$ sudo chown alex:alex kafka.sh
[alex@hadoop102 bin]$ chmod 755 kafka.sh
[alex@hadoop102 bin]$ vim kafka.sh
#!/bin/bashuser=`whoami`
kafka_home=/opt/module/kafkacase $1 instart)for((host=102; host<=104; host++)); doecho -e "---启动 $user@hadoop$host kafka---"ssh $user@hadoop$host "source /etc/profile; $kafka_home/bin/kafka-server-start.sh -daemon $kafka_home/config/server.properties"done;;stop)for((host=102; host<=104; host++)); do# 睡5秒钟sleep 5echo -e "---关闭 $user@hadoop$host kafka---"ssh $user@hadoop$host "source /etc/profile; nohup $kafka_home/bin/kafka-server-stop.sh $kafka_home/config/server.properties"done;;*)echo "你启动的姿势不对"echo "  start   启动kafka集群"echo "  stop    停止kafka集群";;
esac