启动和停止storm和zookeeper集群的shell脚本

准备:
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`
注:需要分发到各节点
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值