准备:
1、免密码登录
ssh-keygen -t rsa
ssh-copy-id hostname(前提:配置好了hosts文件)
2、在脚本同级目录创建
vim supervisor-hosts
master
slave01
start-all.sh
#!/bin/bash
. /etc/profile
bin=/opt/soft/storm-0.9.7/bin
supervisors=/opt/soft/storm-0.9.7/bin/supervisor-hosts
nohup storm nimbus &
nohup storm ui &
nohup storm logviewer &
echo master 启动nimbus...[done]
cat $supervisors | while read supervisor
do
{
echo $supervisor
ssh $supervisor "source /etc/profile;zkServer.sh start"
ssh $supervisor $bin/start-supervisor.sh &
}&
done
注:在while循环内启动zookeeper集群脚本需要并行启动,方法:在do与done中间加上{}&
start-supervisor.sh
#!/bin/bash
. /etc/profile
nohup storm supervisor &
注:需要分发到各个子节点
stop-all.sh
#!/bin/bash
. /etc/profile
bin=/opt/soft/storm-0.9.7/bin
supervisors=/opt/soft/storm-0.9.7/bin/supervisor-hosts
kill -9 `ps -ef|grep daemon.nimbus | awk '{print $2}' | head -n 1`
kill -9 `ps -ef|grep core | awk '{print $2}' | head -n 1`
kill -9 `ps -ef|grep daemon.logviewer | awk '{print $2}' | head -n 1`
cat $supervisors | while read supervisor
do
{
echo $supervisor
ssh $supervisor "source /etc/profile;zkServer.sh stop"
ssh $supervisor $bin/stop-supervisor.sh &
}&
done
注:停止zookeeper集群同样需要并行停止,方法同start-all.sh
core进程不要加daemon.否则获取的进程号不对
stop-supervisor.sh
#!/bin/bash
. /etc/profile
kill -9 `ps -ef|grep daemon.supervisor | awk '{print $2}' | head -n 1`
注:需要分发到各节点