快速启动Hadoop集群、hbase脚本(超详细)
注意:具体代码在最后
一、启动hadoop集群脚本
1、在/usr/local/bin目录下创建脚本文件,脚本文件名字为“hadoopstart”
2、更改脚本文件权限
3、编辑脚本、添加脚本内容
#!/bin/bash
echo “================ Start all node services ="
echo "====== Zookeeper is starting ="
for i in root@hadoop102 root@hadoop103 root@hadoop104
do
ssh $i ‘/opt/module/zookeeper-3.4.14/bin/zkServer.sh start’
done
echo "====== Starting HDFS ="
ssh root@hadoop102 ‘/opt/module/hadoop-2.7.7/sbin/start-dfs.sh’
echo "====== Starting YARN ="
ssh root@hadoop103 ‘/opt/module/hadoop-2.7.7/sbin/start-yarn.sh’
echo "====== Starting JobHistoryServer ===========”
ssh root@hadoop102 ‘/opt/module/hadoop-2.7.7/sbin/mr-jobhistory-daemon.sh start historyserver’
4、运行脚本
二、关闭hadoop集群脚本
1、前三步与上面相同,脚本名字改为hadoopstop
2、运行脚本
三、启动hbase脚本
1、前三步同上,脚本名字为hbasestart
2、运行方法同上
四、关闭hbase脚本
1、前三步同上,脚本名为hbasestop
2、运行方法同上
脚本代码
一、hadoopstart
#!/bin/bash
echo “================ Start all node services ="
echo "====== Zookeeper is starting ="
for i in root@hadoop102 root@hadoop103 root@hadoop104
do
ssh $i ‘/opt/module/zookeeper-3.4.14/bin/zkServer.sh start’
done
echo "====== Starting HDFS ="
ssh root@hadoop102 ‘/opt/module/hadoop-2.7.7/sbin/start-dfs.sh’
echo "====== Starting YARN ="
ssh root@hadoop103 ‘/opt/module/hadoop-2.7.7/sbin/start-yarn.sh’
echo "====== Starting JobHistoryServer ===========”
ssh root@hadoop102 ‘/opt/module/hadoop-2.7.7/sbin/mr-jobhistory-daemon.sh start historyserver’
二、hadoopstop
#!/bin/bash
echo “================ make all nodes closed ="
echo "====== Zookeeper is Closing ="
for i in root@hadoop102 root@hadoop103 root@hadoop104
do
ssh $i ‘/opt/module/zookeeper-3.4.14/bin/zkServer.sh stop’
done
echo "====== Closing HDFS ="
ssh root@hadoop102 ‘/opt/module/hadoop-2.7.7/sbin/stop-dfs.sh’
echo "====== Closing YARN ="
ssh root@hadoop103 ‘/opt/module/hadoop-2.7.7/sbin/stop-yarn.sh’
echo "====== Closing JobHistoryServer ===========”
ssh root@hadoop102 ‘/opt/module/hadoop-2.7.7/sbin/mr-jobhistory-daemon.sh stop historyserver’
三、hbasestart
#!/bin/bash
echo “================ Starting Hbase ===========”
ssh root@hadoop102 ‘/opt/module/hbase/bin/start-hbase.sh’
四、hbasestop
#!/bin/bash
echo “================ Closing Hbase ===========”
ssh root@hadoop102 ‘/opt/module/hbase/bin/stop-hbase.sh’