Hadoop-群起脚本

[server@hadoop102 bin]$ pwd
/home/server/bin
#!/bin/bash

if [ $# -lt 1 ]
then
        echo No Argument Input!
        exit;
fi

case $1 in
"start")
        echo "=================启动 Hadoop集群========================"
        
        echo "------------------启动 hdfs-----------------------------"
        ssh hadoop102 "/opt/module/hadoop-3.1.3/sbin/start-dfs.sh"
        echo "------------------启动 yarn-----------------------------"
        ssh hadoop103 "/opt/module/hadoop-3.1.3/sbin/start-yarn.sh"
        echo "------------------启动 historyserver--------------------"
        ssh hadoop102 "/opt/module/hadoop-3.1.3/bin/mapred --daemon start historyserver"
;;
"stop")
        echo "==================关闭 Hadoop集群==================="
            
        echo "------------------关闭 historyserver-----------------------------"
        ssh hadoop102 "/opt/module/hadoop-3.1.3/bin/mapred --daemon stop historyserver"
        echo "------------------关闭 yarn--------------------------------------"
        ssh hadoop103 "/opt/module/hadoop-3.1.3/sbin/stop-yarn.sh"
        echo "------------------关闭 hdfs-----------------------------"
        ssh hadoop102 "/opt/module/hadoop-3.1.3/sbin/stop-dfs.sh"
;;
*)
    echo "input Args Error..."
;;
esac

[server@hadoop102 bin]$ chmod 777 myhadoop.sh 
[server@hadoop102 bin]$ myhadoop.sh start
=================启动 Hadoop集群========================
------------------启动 hdfs-----------------------------
Starting namenodes on [hadoop102]
Starting datanodes
Starting secondary namenodes [hadoop104]
------------------启动 yarn-----------------------------
Starting resourcemanager
Starting nodemanagers
------------------启动 historyserver--------------------
[server@hadoop102 bin]$ xsync myhadoop.sh
[server@hadoop102 bin]$ vim jpsall
#!/bin/bash

for host in hadoop102 hadoop103 hadoop104
do
        echo =================$host===================
        ssh $host jps
done
[server@hadoop102 bin]$ chmod 777 jpsall 
[server@hadoop102 bin]$ xsync jpsall 
[server@hadoop102 bin]$ jpsall
=================hadoop102===================
10656 DataNode
11589 Jps
10999 NodeManager
11176 JobHistoryServer
10539 NameNode
=================hadoop103===================
9865 NodeManager
9754 ResourceManager
9549 DataNode
10431 Jps
=================hadoop104===================
9488 NodeManager
9831 Jps
9231 DataNode
9343 SecondaryNameNode
[server@hadoop102 bin]$ myhadoop.sh stop
==================关闭 Hadoop集群===================
------------------关闭 historyserver-----------------------------
------------------关闭 yarn--------------------------------------
Stopping nodemanagers
Stopping resourcemanager
------------------关闭 hdfs-----------------------------
Stopping namenodes on [hadoop102]
Stopping datanodes
Stopping secondary namenodes [hadoop104]

你可能感兴趣的:(Hadoop-群起脚本)