hadoop集群及相关服务的启动、停止shell脚本

之前一直是手动启动,一个一个命令敲,好麻烦,最近写了一个启动和暂停的脚本分享给大家

启动脚本start-cluster.sh

#!/bin/sh
echo -e "\033[31m ========Start The Cluster======== \033[0m"

# start hadoop cluster
echo -e "\033[31m Starting Hadoop Now !!! \033[0m"
/usr/local/hadoop/hadoop-2.7.3/sbin/start-dfs.sh
/usr/local/hadoop/hadoop-2.7.3/sbin/start-yarn.sh
echo -e "\n"
sleep 2s

# start zookeeper on master
echo -e "\033[31m Starting zookeeper on master Now !!! \033[0m"
/usr/local/zookeeper/zookeeper-3.4.9/bin/zkServer.sh start
echo -e "\n"
sleep 2s

# start zookeeper on node1
echo -e "\033[31m Starting zookeeper on node1 Now !!! \033[0m"
ssh root@node1 << remotessh
"start-cluster.sh" 47L, 1254C
#!/bin/sh
echo -e "\033[31m ========Start The Cluster======== \033[0m"

# start hadoop cluster
echo -e "\033[31m Starting Hadoop Now !!! \033[0m"
/usr/local/hadoop/hadoop-2.7.3/sbin/start-dfs.sh
/usr/local/hadoop/hadoop-2.7.3/sbin/start-yarn.sh
echo -e "\n"
sleep 2s

# start zookeeper on master
echo -e "\033[31m Starting zookeeper on master Now !!! \033[0m"
/usr/local/zookeeper/zookeeper-3.4.9/bin/zkServer.sh start
echo -e "\n"
sleep 2s

# start zookeeper on node1
echo -e "\033[31m Starting zookeeper on node1 Now !!! \033[0m"
ssh root@node1 << remotessh
/usr/local/zookeeper/zookeeper-3.4.9/bin/zkServer.sh start
echo -e "\n"
sleep 2s
exit
remotessh


# start zookeeper on node1
echo -e "\033[31m Starting zookeeper on node2 Now !!! \033[0m"
ssh root@node2 << remotessh
/usr/local/zookeeper/zookeeper-3.4.9/bin/zkServer.sh start
echo -e "\n"
sleep 2s
exit
remotessh

# start hbase cluster
echo -e "\033[31m Starting hbase cluster Now !!! \033[0m"
/usr/local/hbase/hbase-1.2.4/bin/start-hbase.sh
echo -e "\n"
sleep 2s


#echo -e "\033[31m Starting Spark Now !!! \033[0m"
#/usr/local/spark/spark-2.1.1-bin-hadoop2.7/sbin/start-all.sh
echo -e "\033[31m The Result Of The Command \"jps\" :  \033[0m"

停止脚本stop-cluster.sh

#!/bin/sh
echo -e "\033[31m ===== Stoping The Cluster ====== \033[0m"
#echo -e "\033[31m Stoping Spark Now !!! \033[0m"
#/usr/local/spark/spark-2.1.1-bin-hadoop2.7/sbin/stop-all.sh

# stop hbase cluster
echo -e "\033[31m Stopping hbase cluster Now !!! \033[0m"
/usr/local/hbase/hbase-1.2.4/bin/stop-hbase.sh
echo -e "\n"
sleep 2s

# stop zookeeper on master
echo -e "\033[31m Stopping zookeeper on master Now !!! \033[0m"
/usr/local/zookeeper/zookeeper-3.4.9/bin/zkServer.sh stop
echo -e "\n"
sleep 2s

# stop zookeeper on node1
echo -e "\033[31m Stopping zookeeper on node1 Now !!! \033[0m"
ssh root@node1 << remotessh
/usr/local/zookeeper/zookeeper-3.4.9/bin/zkServer.sh stop
echo -e "\n"
sleep 2s
exit
remotessh


# stop zookeeper on node2
echo -e "\033[31m Stopping zookeeper on node2 Now !!! \033[0m"
ssh root@node2 << remotessh
/usr/local/zookeeper/zookeeper-3.4.9/bin/zkServer.sh stop
echo -e "\n"
sleep 2s
exit
remotessh

# stop hadoop cluster
echo -e "\033[31m Stopping Hadoop Now !!! \033[0m"
/usr/local/hadoop/hadoop-2.7.3/sbin/stop-dfs.sh
/usr/local/hadoop/hadoop-2.7.3/sbin/stop-yarn.sh
echo -e "\n"
sleep 5s

#echo -e "\033[31m Stopting Hadoop Now !!! \033[0m"
#/usr/local/hadoop/hadoop-2.7.3/sbin/stop-all.sh
"stop-cluster.sh" 48L, 1337C

github地址:https://github.com/lieyanhaipo/hadoop

你可能感兴趣的:(hadoop)