当前位置:   article > 正文

linux ha启停脚本,HADOOP HA集群一键启动脚本

linux ha执行启动脚本状态判断

#!/bin/bash

#启动hadoop ha集群

start(){

md hadoop"zkServer.sh start"node1 node2 node3

md hadoop"start-dfs.sh"master1

md hadoop"start-yarn.sh"master1

md hadoop"yarn-daemon.sh start resourcemanager"master2

}

#启动hadoop ha集群

stop(){

md hadoop"yarn-daemon.sh stop resourcemanager"master2

md hadoop"stop-yarn.sh"master1

md hadoop"stop-dfs.sh"master1

md hadoop"zkServer.sh stop"node1 node2 node3

}

#验证hadoop NameNode状态

statusNN(){

success=0nn=$1

echo "[INFO] check hadoop in $nn status..."rm1=`ssh hadoop@$nn "source /etc/profile; jps | grep ResourceManager"`

nn1=`ssh hadoop@$nn "source /etc/profile; jps | grep NameNode"`

zkfc1=`ssh hadoop@$nn "source /etc/profile; jps |grep DFSZKFailoverController"`

len_rm1=${#rm1}

len_nn1=${#nn1}

len_zkfc1=${#zkfc1}if [ $len_rm1 == 0]then

echo -e "[WARING] ResourceManager in $nn do not running"let success=1

fi

if [ $len_nn1 == 0]then

echo -e "[WARING] NameNode in $nn do not running"let success=1

fi

if [ $len_zkfc1 == 0]then

echo -e "[WARING] DFSZKFailoverController in $nn do not running"let success=1

fi

if [ $success != 1]then

echo -e "[INFO] hadoop in $nn is running well"

fi}

#验证Hadoop DataNode状态

statusDN(){

success=0dn=$1

echo "[INFO] check hadoop in $dn status..."qpm1=`ssh hadoop@$dn "source /etc/profile; jps | grep QuorumPeerMain"`

jn1=`ssh hadoop@$dn "source /etc/profile; jps | grep JournalNode"`

nm1=`ssh hadoop@$dn "source /etc/profile; jps | grep NodeManager"`

dn1=`ssh hadoop@$dn "source /etc/profile; jps | grep DataNode"`

len_qpm1=${#qpm1}

len_jn1=${#jn1}

len_nm1=${#nm1}

len_dn1=${#dn1}if [ $len_qpm1 == 0 ]; then

echo -e "[WARING] QuorumPeerMain in $dn is not running"let success=1

fi

if [ $len_jn1 == 0 ]; then

echo -e "[WARING] JournalNode in $dn is not running"let success=1

fi

if [ $len_nm1 == 0 ]; then

echo -e "[WARING] NodeManager in $dn is not running"let success=1

fi

if [ $len_dn1 == 0 ]; then

echo -e "[WARING] DataNode in $dn is not running"let success=1

fi

if [ $success != 1 ]; then

echo -e "[INFO] hadoop in $dn is running well"

fi}

status(){

statusNN master1

statusNN master2

statusDN node1

statusDN node2

statusDN node3

}

opt=$1

if [ "$opt" == "start"]then

echo "[INFO] start hadoop..."startelif [ "$opt" == "stop"]then

echo "[INFO] stop hadoop..."stopelif [ "$opt" == "restart"]then

echo "[INFO] restart hadoop..."stop

startelif [ "$opt" == "status"]then

echo "checking hadoop status...."statuselse

echo "Usage: hadoop-admin "

fi

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/小桥流水78/article/detail/880014
推荐阅读
相关标签
  

闽ICP备14008679号