常用脚本文件

一键开启zookeeper

#!/bin/sh
#获取当前用户
user=`whoami`
for host in $user@hadoop137 $user@hadoop138 $user@hadoop139;
do
 ssh $host "source /etc/profile;/opt/module/zookeeper-3.4.10/bin/zkServer.sh start"
 echo "$host zk is running"

done



 # ssh $host "source /etc/profile;nohup zkServer.sh stop"

一键关闭zookeeper

#!/bin/sh
#获取当前用户
user=`whoami`
for host in $user@hadoop137 $user@hadoop138 $user@hadoop139;
do
 ssh $host "source /etc/profile;/opt/module/zookeeper-3.4.10/bin/zkServer.sh stop"
 echo "$host zk is stop"

done



 # ssh $host "source /etc/profile;nohup zkServer.sh stop"



JPS-utils


#!/bin/sh
#获取当前用户
user=`whoami`

for((host=137; host<=139; host++)); do
        echo ==================hadoop$host==================
        ssh -t $user@hadoop$host "$JAVA_HOME/bin/jps"
done

xsync

#!/bin/bash
#1 获取输入参数个数,如果没有参数,直接退出
pcount=$#
if((pcount==0)); then
echo no args;
exit;
fi

#2 获取文件名称
p1=$1
fname=`basename $p1`
echo fname=$fname

#3 获取上级目录到绝对路径
pdir=`cd -P $(dirname $p1); pwd`
echo pdir=$pdir

#4 获取当前用户名称
user=`whoami`

#5 循环
for((host=137; host<140; host++)); do
        #echo $pdir/$fname $user@hadoop$host:$pdir
        echo --------------- hadoop$host ----------------
        rsync -rvl $pdir/$fname $user@hadoop$host:$pdir
done



start-all

#!/bin/sh
#获取当前用户
user=`whoami`


 echo ====================start hadoop==================

ssh $user@node132 "/opt/module/hadoop-2.7.2/sbin/start-dfs.sh"


 echo ====================dfs running==================

ssh $user@node133 "/opt/module/hadoop-2.7.2/sbin/start-yarn.sh" 



 echo ====================yarn running==================





for host in $user@node132 $user@node133 $user@node134;
do

 echo ====================start zookeeper==================
 ssh $host "source /etc/profile;nohup zkServer.sh start"
 echo "$host zk is running"

done



stop-all

#!/bin/sh
#获取当前用户
user=`whoami`


 echo ====================stop hadoop==================

ssh $user@node132 "/opt/module/hadoop-2.7.2/sbin/stop-dfs.sh"


 echo ====================dfs stop==================

ssh $user@node133 "/opt/module/hadoop-2.7.2/sbin/stop-yarn.sh" 



 echo ====================yarn stop==================





for host in $user@node132 $user@node133 $user@node134;
do

 echo ====================stop zookeeper==================
 ssh $host "source /etc/profile;nohup zkServer.sh stop"
 echo "$host zk is stop"

done



已标记关键词 清除标记
©️2020 CSDN 皮肤主题: 撸撸猫 设计师:C马雯娟 返回首页