#!/bin/sh
echo "#######################"
echo "###"
echo "## 这是storm的一键启动脚本"
echo "##"
echo "########################"
##首先启动当前机器,即master上的storm进程: nimbus 和 ui [core]
echo "启动master上的nimbus"
nohup /opt/storm/bin/storm nimbus > /dev/null 2 >&1 &
echo "启动master上的ui"
## master的ui
nohup /opt/storm/bin/storm ui > /dev/null 2>&1 &
##接下来就要启动slave01和slave02上的进程
## 首先,需要知道storm集群的其他节点,可以将其他节点的地址或者ip或者host配置到一个文件中[storm-slaves],
##类似hadoop中的slaves文件,hbase中的regionservers文件
## 其次,需要遍历读取storm-slaves中的host,一次来远程ssh启动其它机器上的进程
## 使用while循环对去到storm-slaves中的数据
## cat storm-slaves | while read host
## do
## echo $host
## 拿到host之后,就可以通过ssh来远程执行相关的启动脚本
## eg.ssh root@slave01 nohup /opt/storm/bin/storm nimbus > /dev/null 2>&1
## eg.ssh root@slave01 nohup /opt/storm/bin/storm supervisor > /dev/null 2>&1
## eg.ssh root@slave01 nohup /opt/storm/bin/storm logviewer > /dev/null 2>&1
## 问题的关键在于slave01和slave02上面启动的进程不一致,所以需要使用if判断来加以区分
## 所以我们可以通过当前的host是否为slave01来进行区别启动,
## 如果是slave01,需要额外启动nimbus进程
## 判断host==> echo $host | grep -q "slave01",如果host包含slave01的话,这条命令的执行结果返回码为0,反之为非0
## if [ $? -eq 0 ]
## then
## 在slave01上启动nimbus即可
## fi
## 再来启动其它进程即可
## done
##
##
cat /opt/storm/bin/storm-slaves | while read host
do
echo $host | grep -q "slave01"
if [$ -eq 0]
then
echo "启动slave01上的nimbus"
ssh "root@"$host nohup /opt/storm/bin/storm nimbus >/dev/null 2>&1 &
fi
echo "启动supervisor 和 logviewer"
ssh "root@"$host nohup /opt/storm/bin/storm supervisor > /dev/null 2>&1 &
ssh "root@"$host nohup /opt/storm/bin/storm logviewer > /dev/null 2>&1 &
done
集群storm启动脚本
最新推荐文章于 2022-10-16 00:08:39 发布