linux ha启停脚本,HADOOP 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

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值