[新星计划]OneKey_一键启动集群 启动Kafka/Zookeeper命令
Posted ChinaManor
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了[新星计划]OneKey_一键启动集群 启动Kafka/Zookeeper命令相关的知识,希望对你有一定的参考价值。
Kafka一键启动脚本:
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一键关闭脚本:
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 &
#!/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
一键启动集群脚本:
#!/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
以上是关于[新星计划]OneKey_一键启动集群 启动Kafka/Zookeeper命令的主要内容,如果未能解决你的问题,请参考以下文章
[新星计划]一文快速了解Elastic Search 开源搜索引擎(技术选型+启动命令)
[新星计划]十年项目经验面试官亲传大数据面试__大数据面试独孤九剑
kakfa从入门到放弃: kafka入门,环境搭建,命令行操作