注意配置/home/atguigu目录下的(.bashrc)文件,在其中配置JAVA_HOME,并source /home/atguigu/.bashrc
脚本如下

jps:

#!/bin/bash
for i in atguigu@hadoop102 atguigu@hadoop103 atguigu@hadoop104
do
        echo "================           $i             ================"
        ssh $i '/opt/module/jdk1.8.0_144/bin/jps'
done

群起ZK

#!/bin/bash
for i in atguigu@hadoop102 atguigu@hadoop103 atguigu@hadoop104
do
        echo "================           $i             ================"
        ssh $i '/opt/module/zookeeper-3.4.10/bin/zkServer.sh start'
done

群起ZK以及hadoop相关进程脚本:

#!/bin/bash
for i in atguigu@hadoop102 atguigu@hadoop103 atguigu@hadoop104
do
        echo "================           $i             ================"
        ssh $i '/opt/module/zookeeper-3.4.10/bin/zkServer.sh start'
done
[atguigu@hadoop102 bin]$ cat startcluster.sh 
#!/bin/bash
echo "================     开始启动所有节点服务            ==========="
echo "================     正在启动Zookeeper               ==========="
for i in atguigu@hadoop102 atguigu@hadoop103 atguigu@hadoop104
do
        ssh $i '/opt/module/zookeeper-3.4.10/bin/zkServer.sh start'
done
echo "================     正在启动HDFS                    ==========="
ssh atguigu@hadoop102 '/opt/module/hadoop-2.7.2/sbin/start-dfs.sh'
echo "================     正在启动YARN                    ==========="
ssh atguigu@hadoop103 '/opt/module/hadoop-2.7.2/sbin/start-yarn.sh'
echo "================     正在开启JobHistoryServer        ==========="
ssh atguigu@hadoop102 '/opt/module/hadoop-2.7.2/sbin/mr-jobhistory-daemon.sh start historyserver'

群关ZK以及hadoop相关进程脚本:

#!/bin/bash
echo "================     开始关闭所有节点服务            ==========="
echo "================     正在关闭Zookeeper               ==========="
for i in atguigu@hadoop102 atguigu@hadoop103 atguigu@hadoop104
do
        ssh $i '/opt/module/zookeeper-3.4.10/bin/zkServer.sh stop'
done
echo "================     正在关闭HDFS                    ==========="
ssh atguigu@hadoop102 '/opt/module/hadoop-2.7.2/sbin/stop-dfs.sh'
echo "================     正在关闭YARN                    ==========="
ssh atguigu@hadoop103 '/opt/module/hadoop-2.7.2/sbin/stop-yarn.sh'
echo "================     正在关闭JobHistoryServer        ==========="
ssh atguigu@hadoop102 '/opt/module/hadoop-2.7.2/sbin/mr-jobhistory-daemon.sh stop historyserver'

 

Logo

权威|前沿|技术|干货|国内首个API全生命周期开发者社区

更多推荐