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已经启动成功。


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

猜你喜欢

转载自blog.csdn.net/fct2001140269/article/details/80879877