标签:ati 添加 this mon his grep while 集群 文件
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
标签:ati 添加 this mon his grep while 集群 文件
原文地址:http://www.cnblogs.com/edgedance/p/8007598.html