Kafka一键启动脚本:
代码语言:javascript复制cat /export/onekey/slave | while read line
do
{
echo $line
ssh $line "source /etc/profile;export JMX_PORT=9988;nohup ${KAFKA_HOME}/bin/kafka-server-start.sh ${KAFKA_HOME}/config/server.properties >/dev/nul* 2>&1 & "
}&
wait
done
Kafka一键关闭脚本:
代码语言:javascript复制cat /export/onekey/slave | while read line
do
{
echo $line
ssh $line "source /etc/profile;jps |grep Kafka |cut -d' ' -f1 |xargs kill -s 9"
}&
wait
done
nohup bin/zookeeper-server-start.sh config/zookeeper.properties &
代码语言:javascript复制#!/bin/bash
ZK_HOME=/export/server/zookeeper-3.4.6
for number in {1..3}
do
host=node${number}
echo ${host}
/usr/bin/ssh ${host} "cd ${ZK_HOME};source /etc/profile;${ZK_HOME}/bin/zkServer.sh start"
echo "${host} started"
done
一键启动集群脚本:
代码语言:javascript复制#!/bin/bash
p=$1
cmd=''
if [ ! $p ]
then echo "please input [start|stop]"
exit 1
fi
if [ $p == 'start' ]
then
cmd='start'
else
cmd='stop'
fi
#start hadoop
/export/server/hadoop/sbin/${cmd}-all.sh >> /export/server/hadoop/${cmd}.log
sleep 3s
#start zookeeper
for (( i=1; i<=3; i ))
do
# << E0F 只是一个标识,可以换做其他任意字符,多行复杂脚本使用
echo "node$i zk ${cmd} ..."
ssh root@node$i "source /etc/profile; zkServer.sh ${cmd} ;exit; sleep 2s"
done
echo "zk集群${cmd} 完成."
sleep 1s
# start kafka
for (( i=1; i<=3; i ))
do
echo "node$i kafka ${cmd} ..."
ssh root@node$i "source /etc/profile; kafka-server-${cmd}.sh -daemon /export/server/kafka/config/server.properties; exit; sleep 1s;"
done
# start flink
/export/server/flink/bin/${cmd}-cluster.sh