storm集群启动/停止脚本

storm集群启动脚本

    在$STORM_HOME/bin下touch start-storm-cluster.sh并chmod a+x start-storm-cluster.sh

#!/bin/bash
#nimbus节点
nimbusServers='mini01 mini02'

#supervisor节点
supervisorServers='mini01 mini02 mini03'

#启动所有的nimbus
for nim in $nimbusServers
do
    ssh -T $nim <source /etc/profile
        cd \$STORM_HOME
        bin/storm nimbus >/dev/null 2>&1 &
EOF
echo 从节点 $nim 启动nimbus...[ done ]
sleep 1
done

#启动所有的ui
for u in $nimbusServers
do
    ssh -T $u <source /etc/profile
        cd \$STORM_HOME
        bin/storm ui >/dev/null 2>&1 &
EOF
echo 从节点 $u 启动ui...[ done ]
sleep 1
done

#启动所有的supervisor
for visor in $supervisorServers
do
    ssh -T $visor <source /etc/profile
        cd \$STORM_HOME
        bin/storm supervisor >/dev/null 2>&1 &
EOF
echo 从节点 $visor 启动supervisor...[ done ]
sleep 1
done


storm集群停止脚本

    在$STORM_HOME/bin下touch stop-storm-cluster.sh并chmod a+x stop-storm-cluster.sh

#!/bin/bash

#nimbus节点
nimbusServers='mini01 mini02'

#supervisor节点
supervisorServers='mini01 mini02 mini03'

#停止所有的nimbus和ui
for nim in $nimbusServers
do
    echo 从节点 $nim 停止nimbus和ui...[ done ]
    ssh $nim "kill -9 `ssh $nim ps -ef | grep nimbus | awk '{print $2}'| head -n 1`" >/dev/null 2>&1
    ssh $nim "kill -9 `ssh $nim ps -ef | grep core | awk '{print $2}'| head -n 1`" >/dev/null 2>&1
done

#停止所有的supervisor
for visor in $supervisorServers
do
    echo 从节点 $visor 停止supervisor...[ done ]
    ssh $visor "kill -9 `ssh $visor ps -ef | grep supervisor | awk '{print $2}'| head -n 1`" >/dev/null 2>&1
done

你可能感兴趣的:(Storm)