shell脚本启动与停止storm集群

一、使用前准备工作介绍:

1.storm安装目录

/hadoop/apache-storm-1.1.0   #storm的安装目录
/root/hyjc_shell  #今后所有shell统一放在指定路径的目录下

2.配置好环境变量

vim /etc/profile  #配置环境变量
source /etc/profile   #使得环境变量立即生效

3.三台主机(或者是虚拟机)修改了主机名、关闭了防火墙、并配置免密码登陆,主机IP与主机名的映射关系

stormfct1 192.168.11.111 
stormfct2 192.168.11.112 
stormfct3 192.168.11.113 

二、脚本介绍

一共4个脚本:

storm_start_all.sh
storm_stop_all.sh
stop_supervisor.sh
start_supervisor.sh
1.其中storm_stop_all.sh为:
#!/bin/bash

# chkconfig: 2345 10 90
# description: zookeeper start

stormhome=/hadoop/apache-storm-1.1.0
stormbin=$stormhome/bin
shell_home=/root/hyjc_shell

nohup storm nimbus >$stormhome/nimbus.log 2>&1 &
nohup storm ui >$stormhome/ui.log 2>&1 &
sleep 5
jps

echo "start storm......"
for i in {1..3};do
   ssh stormfct$i "$shell_home/start_supervisor.sh;hostname;sleep 5;jps;exit"
   echo "-----------------"
done
echo "**************************"
echo "start storm finished !"
2.其中storm_stop_all.sh为:
#!/bin/bash
. /etc/profile
# storm的bin目录
stormbin=/hadoop/apache-storm-1.1.0/bin
shell_home=/root/hyjc_shell

echo "stop storm cluster ........"
kill -9 `ps -ef|grep daemon.nimbus| awk '{print $2}'`
kill -9 `ps -ef|grep ui.core| awk '{print $2}'`
sleep 3
jps
echo "----------------------"

for i in {1..3};do
   ssh stormfct$i "$shell_home/stop_supervisor.sh;jps;exit"
   echo "--------------------------"
done

echo "stop storm cluster finished !"
echo "******************************"
3.其他两个被调用的shell脚本:

>
start_supervisor.sh
stop_supervisor.sh

具体:
(1)start_supervisor.sh

#!/bin/bash
. /etc/profile
#后台启动
nohup storm supervisor >/hadoop/apache-storm-1.1.0/supervisor_log 2>&1 &

(2)stop_supervisor.sh

 #!/bin/bash 
kill -9 `ps -ef|grep daemon.supervisor|awk '{print $2}'`

[注:所有脚本需要分发到各节点的/root/hyjc_shell]

三、启动与关闭storm集群

使用前给四个shell脚本都赋予执行权限
chmod +x *.sh  #赋给该脚本可执行权限
1.关闭脚本:

在指定脚本上调用:storm_stop_all.sh

   ./zookeeper_instorm_stop_all.sh   #执行该脚本

使用命令jps当 不存在 nimbus 、supervisor、ui进程名称时候,表示storm已经关闭

2.启动脚本
./storm_stop_all.sh   #执行该脚本

使用命令jps当 存在 nimbus 、supervisor、ui进程名称时候,表示storm已经启动成功。


(以上已经亲测有效….,欢迎评论与点赞 :) )

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值