shell脚本监控Jstorm主从节点进程,无进程自动重启

主宰稳场 提交于 2020-08-19 13:31:04

storm主从节点配置监控脚本
一、目的
配置重启脚本,防止服务停止影响业务。
二、配置思路
通过监测服务进程查看服务是否运行,当服务进程不存在进行自重启
配置Jstorm主节点
配置jstorm从节点 supervisor进行重启
三、配置方法
1.配置jstorm主节点
主节点涉及到两个进程:NimbusServe、supervisor
(当服务停止后,主节点应先启动NimbusServe进程,在启动supervisor)
shell脚本监控Jstorm主从节点进程,无进程自动重启










脚本详情

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#日志输出
Nimerror=/tmp/sup-Nimerror.log
superror=/tmp/sup-error.log
#监控主节点,主节点需先启动NimbusServer进程,再启动upervisor进程
NimbusServer=/usr/local/jdk1.7.0_45/bin/jps | grep NimbusServer | grep -v grep | awk '{print $2}'
#监控从节点,从节点仅包含Supervisor进程
supervisor=/usr/local/jdk1.7.0_45/bin/jps | grep Supervisor | grep -v grep | awk '{print $2}'






if [ -z "$NimbusServer" ]
then

{

echo "date: NimbusServer is down" >>$Nimerror
/usr/local/jstorm-0.9.6.2/bin/jstorm nimbus&
}

elif [ -z "$supervisor" ]
then
{

echo "date: supervisor is down" >>$superror
/usr/local/jstorm-0.9.6.2/bin/jstorm supervisor&
}

fi

+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2.配置jstorm从节点
配置从节点监控脚本:
shell脚本监控Jstorm主从节点进程,无进程自动重启
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#!/bin/sh
#日志输出
suplog=/tmp/sup-start.log
superror=/tmp/sup-error.log







supervisor=/usr/local/jdk1.7.0_45/bin/jps | grep Supervisor | grep -v grep | awk '{print $2}'
if [ -z "$supervisor" ]
then
{


echo "date: listen port is down" >>$superror
/usr/local/jstorm-0.9.6.2/bin/jstorm supervisor&
}

else
{
echo "date :正常 " >>$suplog

}

fi

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
转载请注明出处,谢谢。

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!