1一键脚本
x
1
#!/bin/bash2
3
# 1 声明4
#--------------------------------------5
#请在strom/bin/下执行脚本6
#supervisor-hosts:配置supervisor的主机名,请自行配置7
#BASH_PATH 需要自行配置8
#--------------------------------------9
BASH_PATH=/root/apps/storm-1.1.110
cd $BASH_PATH/bin11
# 2 创建启动脚本文件12
touch start-supervisor.sh13
touch start-storm.sh14
touch stop-supervisor.sh15
touch stop-storm.sh16
touch supervisor-hosts17
18
# 3 赋予执行权限19
chmod +x *.sh20
21
# 4 start-supervisor.sh22
cat>start-supervisor.sh<<EOF23
#!/bin/bash24
$BASH_PATH/bin/storm supervisor >/dev/null 2>&1 &25
EOF26
27
# 5 start-storm.sh28
cat>start-storm.sh<<EOF29
#!/bin/bash30
$BASH_PATH/bin/storm nimbus >/dev/null 2>&1 &31
$BASH_PATH/bin/storm ui >/dev/null 2>&1 &32
cat $BASH_PATH/bin/supervisor-hosts | while read supervisor33
do34
echo "$supervisor is start..."35
ssh $supervisor $BASH_PATH/bin/start-supervisor.sh &36
done37
EOF38
39
# 6 stop-supervisor.sh40
cat>stop-supervisor.sh<<EOF41
#!/bin/bash42
kill -9 `ps -ef|grep daemon.supervisor| awk '{print $2}'`43
# 选择是否清除工作目录文件44
#rm -rf /software/storm/workdir/*45
EOF46
47
# 7 stop-storm.sh48
cat>stop-storm.sh<<EOF49
#!/bin/bash50
kill -9 `ps -ef|grep daemon.nimbus| awk '{print $2}'`51
kill -9 `ps -ef|grep ui.core| awk '{print $2}'`52
cat $BASH_PATH/bin/supervisor-hosts | while read supervisor53
do54
echo "$supervisor is stop ..."55
ssh $supervisor $BASH_PATH/bin/stop-supervisor.sh &56
done57
EOF58
59
# 8 supervisor-hosts60
cat>supervisor-hosts<<EOF61
mini162
mini263
mini364
EOF2使用
17
1
# 1 将上文编辑好的start-supervisor和stop-supervisor脚本复制到所有节点相同路径下2
scp *-supervisor.sh mini2:$PWD3
scp *-supervisor.sh mini3:$PWD4
scp *-supervisor.sh mini4:$PWD5
6
# 2 配置环境变量 7
#vim /etc/profile8
STORM_HOME=/root/apps/storm-1.1.19
PATH=$PATH:$STORM_HOME/bin10
export STORM_PATH PATH11
12
source /etc/profile13
# 3 启动集群中所有节点supervisor进程,并在主节点上启动nimbus和ui进程14
start-storm.sh15
16
# 4 停止集群中所有节点supervisor进程,并停止nimbus和ui进程17
stop-storm.sh3添加开启启动
x
1
# 开机自动运行下之前的start-all脚本,设置方法如下2
vi /etc/rc.d/rc.local 3
4
# 添加执行脚本5
#!/bin/sh6
#7
# This script will be executed *after* all the other init scripts.8
# You can put your own initialization stuff in here if you don't9
# want to do the full Sys V style init stuff.10
11
touch /var/lock/subsys/local12
sh /root/apps/storm-1.1.1/bin/start-storm.sh