x
#!/bin/bash
# 1 聲明
#--------------------------------------
#請在strom/bin/下執行腳本
#supervisor-hosts:配置supervisor的主機名,請自行配置
#BASH_PATH 須要自行配置
#--------------------------------------
BASH_PATH=/root/apps/storm-1.1.1
cd $BASH_PATH/bin
# 2 建立啓動腳本文件
touch start-supervisor.sh
touch start-storm.sh
touch stop-supervisor.sh
touch stop-storm.sh
touch supervisor-hosts
# 3 賦予執行權限
chmod +x *.sh
# 4 start-supervisor.sh
cat>start-supervisor.sh<<EOF
#!/bin/bash
$BASH_PATH/bin/storm supervisor >/dev/null 2>&1 &
EOF
# 5 start-storm.sh
cat>start-storm.sh<<EOF
#!/bin/bash
$BASH_PATH/bin/storm nimbus >/dev/null 2>&1 &
$BASH_PATH/bin/storm ui >/dev/null 2>&1 &
cat $BASH_PATH/bin/supervisor-hosts | while read supervisor
do
echo "\$supervisor is start..."
ssh \$supervisor $BASH_PATH/bin/start-supervisor.sh &
done
EOF
# 6 stop-supervisor.sh
cat>stop-supervisor.sh<<EOF
#!/bin/bash
kill -9 `ps -ef|grep daemon.supervisor| awk '{print $2}'`
# 選擇是否清除工做目錄文件
#rm -rf /software/storm/workdir/*
EOF
# 7 stop-storm.sh
cat>stop-storm.sh<<EOF
#!/bin/bash
kill -9 `ps -ef|grep daemon.nimbus| awk '{print $2}'`
kill -9 `ps -ef|grep ui.core| awk '{print $2}'`
cat $BASH_PATH/bin/supervisor-hosts | while read supervisor
do
echo "\$supervisor is stop ..."
ssh \$supervisor $BASH_PATH/bin/stop-supervisor.sh &
done
EOF
# 8 supervisor-hosts
cat>supervisor-hosts<<EOF
mini1
mini2
mini3
EOF
# 1 將上文編輯好的start-supervisor和stop-supervisor腳本複製到全部節點相同路徑下
scp *-supervisor.sh mini2:$PWD
scp *-supervisor.sh mini3:$PWD
scp *-supervisor.sh mini4:$PWD
# 2 配置環境變量
#vim /etc/profile
STORM_HOME=/root/apps/storm-1.1.1
PATH=$PATH:$STORM_HOME/bin
export STORM_PATH PATH
source /etc/profile
# 3 啓動集羣中全部節點supervisor進程,並在主節點上啓動nimbus和ui進程
start-storm.sh
# 4 中止集羣中全部節點supervisor進程,並中止nimbus和ui進程
stop-storm.sh
# 開機自動運行下以前的start-all腳本,設置方法以下
vi /etc/rc.d/rc.local
# 添加執行腳本
#!/bin/sh
#
# This script will be executed *after* all the other init scripts.
# You can put your own initialization stuff in here if you don't
# want to do the full Sys V style init stuff.
touch /var/lock/subsys/local
sh /root/apps/storm-1.1.1/bin/start-storm.sh