1.启动集群
文件名: start-cluster.sh
#! /bin/bash
echo "------正在启动集群------"
echo "------正在启动Zookeeper------"
'/home/grid/zookeeper/bin/zkServer.sh start'
ssh grid@Slave1 '/home/grid/zookeeper/bin/zkServer.sh start'
ssh grid@Slave2 '/home/grid/zookeeper/bin/zkServer.sh start'
echo "------正在启动Hadoop-----"
'/home/grid/hadoop/sbin/start-all.sh'
echo "------正在启动Spark------"
'/home/grid/spark/sbin/start-all.sh'
echo "------正在启动Hbase------"
'/home/grid/hbase/bin/start-hbase.sh'
echo "------正在启动Hive-------"
ssh grid@Slave1 '/home/grid/hive/bin/hive --service metastore &'
ssh grid@Slave1 '/home/grid/hive/bin/hive --service hiveserver2 &'
echo "------集群启动完成,检查是否启动成功------"
需要到root下给该文件赋予启动的权限
su root
chmod +x start-cluster.sh
./start-cluster.sh 命令启动即可
2.关闭集群
#! /bin/bash
echo "------正在关闭集群------"
echo "------正在关闭Hbase------"
'/home/grid/hbase/bin/stop-hbase.sh'
echo "------正在关闭Spark------"
'/home/grid/spark/sbin/stop-all.sh'
echo "------正在关闭Hadoop-----"
'/home/grid/hadoop/sbin/stop-all.sh'
echo "------正在关闭Zookeeper------"
'/home/grid/zookeeper/bin/zkServer.sh stop'
ssh grid@Slave1 '/home/grid/zookeeper/bin/zkServer.sh stop'
ssh grid@Slave2 '/home/grid/zookeeper/bin/zkServer.sh stop'
echo "------集群关闭完成,检查是否关闭成功------"
需要到root下给该文件赋予启动的权限
su root
chmod +x stop-cluster.sh
./stop-cluster.sh 命令启动即可