HDFS启动脚本(非HA)(_start-hdfs-cluster)_
cd /usr/local/bin
sudo vi start-hdfs-cluster
脚本内容如下:_
#!/bin/bash
HADOOP_HOME=/home/vagrant/modules/hadoop-2.7.2
echo "start hdfs-----------------------------------------------------"
for i in bigdata-node1
do
ssh $i "source /etc/profile;${HADOOP_HOME}/sbin/start-dfs.sh"
done
sleep 3s
echo "start done..."
echo "cluster jps status------------------------------------------------"
jpsx
exit 0
设置脚本执行权限:_
sudo chmod +x start-hdfs-cluster
sudo chown vagrant:vagrant start-hdfs-cluster
HDFS停止脚本(非HA)(stop-_hdfs-cluster)_
cd /usr/local/bin
sudo vi stop-hdfs-cluster
脚本内容如下:_
#!/bin/bash
HADOOP_HOME=/home/vagrant/modules/hadoop-2.7.2
echo "stop hdfs-----------------------------------------------------"
for i in bigdata-node1
do
ssh $i "source /etc/profile;${HADOOP_HOME}/sbin/stop-dfs.sh"
done
sleep 3s
echo "stop done..."
echo "cluster jps status------------------------------------------------"
jpsx
exit 0
设置脚本执行权限:_
sudo chmod +x stop-hdfs-cluster
sudo chown vagrant:vagrant stop-hdfs-cluster
YARN启动脚本(非HA)(_start-yarn-cluster)_
cd /usr/local/bin
sudo vi start-yarn-cluster
脚本内容如下:_
#!/bin/bash
HADOOP_HOME=/home/vagrant/modules/hadoop-2.7.2
echo "start yarn-----------------------------------------------------"
for i in bigdata-node1
do
ssh $i "source /etc/profile;${HADOOP_HOME}/sbin/start-yarn.sh"
done
sleep 3s
echo "start mr-jobhistory-----------------------------------------------------"
for i in bigdata-node1
do
ssh $i "source /etc/profile;${HADOOP_HOME}/sbin/mr-jobhistory-daemon.sh start historyserver"
ssh $i "source /etc/profile;${HADOOP_HOME}/sbin/yarn-daemon.sh start timelineserver"
done
sleep 3s
echo "start done..."
echo "cluster jps status------------------------------------------------"
jpsx
exit 0
设置脚本执行权限:_
sudo chmod +x start-yarn-cluster
sudo chown vagrant:vagrant start-yarn-cluster
YARN停止脚本(非HA)(_stop-yarn-cluster)_
cd /usr/local/bin
sudo vi stop-yarn-cluster
脚本内容如下:_
#!/bin/bash
HADOOP_HOME=/home/vagrant/modules/hadoop-2.7.2
# 关闭mr-jobhistory
echo "stop mr-jobhistory"
for i in bigdata-node1
do
ssh $i "source /etc/profile;${HADOOP_HOME}/sbin/mr-jobhistory-daemon.sh stop historyserver"
ssh $i "source /etc/profile;${HADOOP_HOME}/sbin/yarn-daemon.sh stop timelineserver"
done
sleep 3s
echo "stop yarn"
for i in bigdata-node1
do
ssh $i "source /etc/profile;${HADOOP_HOME}/sbin/stop-yarn.sh"
done
sleep 3s
echo "stop done..."
echo "cluster jps status------------------------------------------------"
jpsx
exit 0
设置脚本执行权限:_
sudo chmod +x stop-yarn-cluster
sudo chown vagrant:vagrant stop-yarn-cluster
分发(选做):
# 使用root账户分发至其他节点
sudo scp -r /usr/local/bin/*-{hdfs,yarn}-cluster root@bigdata-node2:/usr/local/bin/
sudo scp -r /usr/local/bin/*-{hdfs,yarn}-cluster root@bigdata-node3:/usr/local/bin/