Spark集群启动脚本(start-spark-cluster)
cd /usr/local/bin
sudo vi start-spark-cluster
脚本内容如下:
#!/bin/bash
SPARK_HOME=/home/vagrant/modules/spark
echo "start spark-cluster-------------------------------------------------"
for i in bigdata-node1
do
ssh $i "source /etc/profile;${SPARK_HOME}/sbin/start-all.sh"
ssh $i "source /etc/profile;${SPARK_HOME}/sbin/start-history-server.sh"
done
sleep 5s
jpsx
exit 0
设置脚本执行权限:
sudo chmod +x start-spark-cluster
sudo chown vagrant:vagrant start-spark-cluster
Spark集群停止脚本(stop-spark-cluster)
cd /usr/local/bin
sudo vi stop-spark-cluster
脚本内容如下:
#!/bin/bash
SPARK_HOME=/home/vagrant/modules/spark
echo "stop spark-cluster"
for i in bigdata-node1 bigdata-node2 bigdata-node3
do
ssh $i "source /etc/profile;${SPARK_HOME}/sbin/stop-history-server.sh"
ssh $i "source /etc/profile;${SPARK_HOME}/sbin/stop-all.sh"
done
sleep 5s
jpsx
exit 0
设置脚本执行权限:
sudo chmod +x stop-spark-cluster
sudo chown vagrant:vagrant stop-spark-cluster
分发(选做):
# 使用root账户分发至其他节点
sudo scp -r /usr/local/bin/*-spark-cluster root@bigdata-node2:/usr/local/bin/
sudo scp -r /usr/local/bin/*-spark-cluster root@bigdata-node3:/usr/local/bin/