1一键脚本
x
1
#!/bin/bash
2
3
# 1 声明
4
#--------------------------------------
5
#请在strom/bin/下执行脚本
6
#supervisor-hosts:配置supervisor的主机名,请自行配置
7
#BASH_PATH 需要自行配置
8
#--------------------------------------
9
BASH_PATH=/root/apps/storm-1.1.1
10
cd $BASH_PATH/bin
11
# 2 创建启动脚本文件
12
touch start-supervisor.sh
13
touch start-storm.sh
14
touch stop-supervisor.sh
15
touch stop-storm.sh
16
touch supervisor-hosts
17
18
# 3 赋予执行权限
19
chmod +x *.sh
20
21
# 4 start-supervisor.sh
22
cat>start-supervisor.sh<<EOF
23
#!/bin/bash
24
$BASH_PATH/bin/storm supervisor >/dev/null 2>&1 &
25
EOF
26
27
# 5 start-storm.sh
28
cat>start-storm.sh<<EOF
29
#!/bin/bash
30
$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 supervisor
33
do
34
echo "$supervisor is start..."
35
ssh $supervisor $BASH_PATH/bin/start-supervisor.sh &
36
done
37
EOF
38
39
# 6 stop-supervisor.sh
40
cat>stop-supervisor.sh<<EOF
41
#!/bin/bash
42
kill -9 `ps -ef|grep daemon.supervisor| awk '{print $2}'`
43
# 选择是否清除工作目录文件
44
#rm -rf /software/storm/workdir/*
45
EOF
46
47
# 7 stop-storm.sh
48
cat>stop-storm.sh<<EOF
49
#!/bin/bash
50
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 supervisor
53
do
54
echo "$supervisor is stop ..."
55
ssh $supervisor $BASH_PATH/bin/stop-supervisor.sh &
56
done
57
EOF
58
59
# 8 supervisor-hosts
60
cat>supervisor-hosts<<EOF
61
mini1
62
mini2
63
mini3
64
EOF
2使用
17
1
# 1 将上文编辑好的start-supervisor和stop-supervisor脚本复制到所有节点相同路径下
2
scp *-supervisor.sh mini2:$PWD
3
scp *-supervisor.sh mini3:$PWD
4
scp *-supervisor.sh mini4:$PWD
5
6
# 2 配置环境变量
7
#vim /etc/profile
8
STORM_HOME=/root/apps/storm-1.1.1
9
PATH=$PATH:$STORM_HOME/bin
10
export STORM_PATH PATH
11
12
source /etc/profile
13
# 3 启动集群中所有节点supervisor进程,并在主节点上启动nimbus和ui进程
14
start-storm.sh
15
16
# 4 停止集群中所有节点supervisor进程,并停止nimbus和ui进程
17
stop-storm.sh
3添加开启启动
x
1
# 开机自动运行下之前的start-all脚本,设置方法如下
2
vi /etc/rc.d/rc.local
3
4
# 添加执行脚本
5
#!/bin/sh
6
#
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't
9
# want to do the full Sys V style init stuff.
10
11
touch /var/lock/subsys/local
12
sh /root/apps/storm-1.1.1/bin/start-storm.sh