Hadoop编写一键集群全起start-cluster.sh、全关stop-cluster.sh、显示所有jps进程show-jps.sh脚本 以及解决方案

 

Hadoop编写一键集群全起start-cluster.sh、全关stop-cluster.sh、显示所有jps进程show-jps.sh脚本 以及解决方案

 

 

 

一、首先进入:/usr/local/bin 文件夹下,编写start-cluster.sh脚本

vim start-cluster.sh              (需要root权限) 下面的各个节点的信息根据自身情况进行修改

#!/bin/bash
user=`whoami`

echo "===============     开始启动所有节点服务        ==============="
for((host=102; host<=104; host++)); do
                echo "--------------- hadoop$host Zookeeper...... ----------------"
        ssh $user@hadoop$host '/opt/module/zookeeper-3.4.10/bin/zkServer.sh start'
done

echo "================    正在启动HDFS                ==============="
ssh $user@hadoop102 '/opt/module/hadoop-2.7.2/sbin/start-dfs.sh'

echo "================    正在启动YARN                ==============="
ssh $user@hadoop102 '/opt/module/hadoop-2.7.2/sbin/start-yarn.sh'

echo "================ hadoop102正在启动JobHistoryServer  ==============="
ssh $user@hadoop102 '/opt/module/hadoop-2.7.2/sbin/mr-jobhistory-daemon.sh start historyserver'

保存,退出。修改执行权限 chmod 777 start-cluster.sh 运行:

Hadoop编写一键集群全起start-cluster.sh、全关stop-cluster.sh、显示所有jps进程show-jps.sh脚本 以及解决方案

二、编写stop-cluster.sh

#!/bin/bash
user=`whoami`
echo "================     开始停止所有节点服务        ==============="
echo "================ hadoop102正在停止JobHistoryServer  ==============="
ssh $user@hadoop102 '/opt/module/hadoop-2.7.2/sbin/mr-jobhistory-daemon.sh stop historyserver'

echo "================    正在停止YARN                ==============="
ssh $user@hadoop102 '/opt/module/hadoop-2.7.2/sbin/stop-yarn.sh'

echo "================    正在停止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

修改执行权限

 

上一篇:查看JVM参数


下一篇:jdk 自带命令行工具