First, first enter: / usr / local / bin files in the folder, write a script start-cluster.sh
Vim start-cluster.sh (requires root privileges) the information of each node to modify surfaces according to their
#! / bin / bash the User = ` whoami ` echo " =============== started all nodes service =============== " for ((Host = 102 ; Host <= 104 ; ++ Host)); do echo " --------------- ------- Hadoop $ ...... Host the Zookeeper --------- " SSH $ $ hadoop the User @ Host ' /opt/module/zookeeper-3.4.10/bin/zkServer.sh Start ' DONE echo " =========== ===== being HDFS =============== start " SSH $ @ hadoop102 the User ' /opt/module/hadoop-2.7.2/sbin/start-dfs.sh' Echo " ================ =============== Starting YARN " SSH $ @ hadoop102 the User ' / opt / Module / hadoop -2.7.2 / sbin / start-yarn.sh ' echo " ================ hadoop102 starting JobHistoryServer =============== " SSH $ @ hadoop102 the User ' /opt/module/hadoop-2.7.2/sbin/mr-jobhistory-daemon.sh Start historyserver '
Save and exit. Modify execute permissions chmod 777 start-cluster.sh run:
Second, write stop-cluster.sh
#! / bin / bash the User = ` whoami ` echo ' ================ start stop all node services =============== " echo " ================ =============== hadoop102 stopping JobHistoryServer " SSH $ @ hadoop102 the User ' / opt / Module / hadoop -2.7.2 / sbin / mr-jobhistory-daemon.sh sTOP historyserver ' echo " ================ stopping YARN ============ === " SSH $ @ hadoop102 the User ' /opt/module/hadoop-2.7.2/sbin/stop-yarn.sh ' echo "================ =============== Stopping HDFS " ssh $user@hadoop102 '/opt/module/hadoop-2.7.2/sbin/stop-dfs.sh' echo "=============== 正在停止Zookeeper...... ===============" for((host=102; host<=104; host++)); do echo "--------------- hadoop$host Zookeeper...... ----------------" ssh $user@hadoop$host '/opt/module/zookeeper-3.4.10/bin/zkServer.sh stop' done
Modify execute permissions