一键启动hadoop集群、zookeeper集群、spark集群shell脚本

1. hadoop-cluster.sh

#!/bin/bash
if [ $# -ne 1 ]; then
echo "Usage: sh hadoop-cluster.sh [start|stop]"
exit 2
fi

source /etc/profile  

${HADOOP_HOME}/sbin/$1-all.sh  && ${HADOOP_HOME}/sbin/mr-jobhistory-daemon.sh $1 historyserver

2. zookeeper-cluster.sh

#!/bin/bash
if [ $# -ne 1 ];then
echo "Usage: sh zookeeper-cluster.sh [start|stop|restart]"
exit 2
fi
for node in master.bigdata.com slave01.bigdata.com slave02.bigdata.com
do
echo $node
ssh $node "source /etc/profile && /opt/cdh5.3.6/zookeeper-3.4.5/bin/zkServer.sh $1"

done

3. spark-cluster.sh

#!/bin/bash
if [ $# -ne 1 ];then
echo "Usage: sh spark-cluster.sh [start|stop]"
exit 2
fi

ssh master.bigdata.com 

 "source /etc/profile && ${SPARK_HOME}/sbin/$1-all.sh && && ${SPARK_HOME}/sbin/$1-history-server.sh"

ssh slave01.bigdata.com

 "source /etc/profile && ${SPARK_HOME}/sbin/$1-master.sh"

ssh slave02.bigdata.com 

"source /etc/profile && ${SPARK_HOME}/sbin/$1-master.sh"

你可能感兴趣的:(hadoop,linux,spark)