Azkaban启动停止脚本


我们在上一篇文章中已经安装部署了Azkaban,但是启动的时候要去每个机器上执行一下命令。来回切换机器太麻烦,今天我们输出一个脚本,搞定自动启动停止。

1 登录到hadoop01上,在~/bin 目录下创建一个azkaban.sh脚本

[hadoop@hadoop01 ~] cd bin
[hadoop@hadoop01 ~] vi azkaban.sh

2 编写脚本文件,保持退出

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

if ((pcount==1)); then
echo no second param;
exit;
fi

#2 获取启动类型 exec 还是 web
p1=$1
p2=$2

if [[ $p1 == "exec" ]]; then
       if [[ $p2 == "start" ]]; then
               for (( i = 1; i <= 3; i++ )); do
               echo ====================hadoop$i azkaban exec $p2 ==============================
               ssh hadoop$i "source /etc/profile;cd /bigdata/install/azkaban-exec-server-4.0.0; bin/start-exec.sh"
               done
       elif [[ $p2 == "active" ]]; then
               for (( i =1; i <= 3; i++ )); do
               echo ====================hadoop$i azkaban exec $p2 ===============================
               ssh hadoop$i 'source /etc/profile;curl http://hadoop'${i}':$('cat /bigdata/install/azkaban-exec-server-4.0.0/executor.port')/executor?action=activate'
               done
       elif [[ $p2 == "stop" ]]; then
               for (( i = 1; i <= 3; i++ )); do
               echo ====================hadoop$i azkaban exec $p2 ==============================
               ssh hadoop$i "cd /bigdata/install/azkaban-exec-server-4.0.0/;bin/shutdown-exec.sh"
           done
       fi
elif [[ $p1 == "web" ]]; then
       if [[ $p2 == "start" ]]; then
               echo ====================azkaban web $p2 ==============================
               ssh hadoop3 "source /etc/profile;cd /bigdata/install/azkaban-web-server-4.0.0/; bin/start-web.sh"
       elif [[ $p2 == "stop" ]]; then
               echo ====================azkaban web $p2 ==============================
               ssh hadoop3 "source /etc/profile;cd /bigdata/install/azkaban-web-server-4.0.0/; bin/shutdown-web.sh"
       fi
fi

3 修改脚本权限

[hadoop@hadoop01 bin] sudo chmod 777 azkaban.sh

4 启动/停止脚本

  • 启动服务
[hadoop@hadoop01 bin] azkaban.sh exec start
[hadoop@hadoop01 bin] azkaban.sh exec active
[hadoop@hadoop01 bin] azkaban.sh web start
[hadoop@hadoop01 bin] xcall jps

  • 停止服务
[hadoop@hadoop01 bin] azkaban.sh exec stop
[hadoop@hadoop01 bin] azkaban.sh web stop
[hadoop@hadoop01 bin] xcall jps


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM