当前位置: 首页 > news >正文

网站模板制作教程视频高质量内容的重要性

网站模板制作教程视频,高质量内容的重要性,手机移动端网站,wordpress视频加密目录 一.引言 二.Flink 程序监控 1.shell 脚本 2.crontab 配置 三.Python 程序监控 1.shell 脚本 2.crontab 配置 四.总结 一.引言 业务有流式处理数据的需求,需要 7x24 通过 Flink Python 程序进行处理。为了监控 Flink 与 Python 的程序运行状态并在程…

目录

一.引言

二.Flink 程序监控

1.shell 脚本

2.crontab 配置

三.Python 程序监控

1.shell 脚本

2.crontab 配置 

四.总结


一.引言

业务有流式处理数据的需求,需要 7x24 通过 Flink + Python 程序进行处理。为了监控 Flink 与 Python 的程序运行状态并在程序异常时重启对应程序,开发了对应的流式程序监控脚本。特此记录,供以后类似任务快捷使用。

二.Flink 程序监控

1.shell 脚本

在 linux 机器 vim cron_protect.sh 填入下述信息:

#!/bin/bashdat=`date +%Y%m%d`
# 任务在 linux 机器的对应目录
base_path='your_path'
cd $base_path
time=`date "+%Y%m%d-%H%M"`function check() {
# Flinl、Spark Streaming 程序的 appName
appname=$1
appnum=`yarn --config /data0/yarn-streaming application -list | grep $appname| awk '{print $1}'|wc -l`
if [ "$appnum" -eq "1" ];thenecho "$appname $time ok"
elif [ "$appnum" -eq "0" ];thensh killAndRerun.shsendMail
elseecho "任务存在多个实例"appId=`yarn --config /data0/yarn-streaming application -list | grep $appname| awk '{print $1}'`arr=(${appId// / })for i in ${arr[@]}doyarn --config /data0/yarn-streaming application -kill $iecho 'kill' $idonesh killAndRerun.shsendMail
fi
}check yourAppName

 yarn-streaming 获取当前 AppName 存在的实例数

 app_num 判断当前 app_num 分别为 0、1、其他

        - 0 代表任务异常,调用启动程序重启服务

        - 1 代表任务正常,do nothing

        - 其他 存在多个实例,kill 掉全部异常任务,重启对应服务

send_mail  调用告警系统发报警提示任务异常重启

Tips:

不同环境下,yarn-streaming 的命令可能存在差异,上面 yarn-streaming 相关操作请根据自己服务器环境的命令进行修改。如果是 Flink 流程序,也可以在内部调用 env.setRestartStrategy 方法定义对应的重启策略。

2.crontab 配置

0-59/5 * * * * source ~/.bash_profile && cd $base_path && sh cron_protect.sh >> cron.log

这里任务是 7x24 执行,博主设置了 0-59/5 即 5 min 检查一次,也可以根据自己的需求调整 crontab 的频率。运行后,会每 5 min 打印程序运行状态:

三.Python 程序监控

1.shell 脚本

#!/bin/bashcd $base_path# 脚本名称
PYTHON_PROGRAM_NAME='your.py'
# 任务 pid
PYTHON_PID=$(pgrep -f $PYTHON_PROGRAM_NAME)# 检查pid是否存在
if [ -z "$PYTHON_PID" ]; then# pid不存在,python程序未运行,需要重启echo "Python程序未运行,正在重启..."nohup python -u $PYTHON_PROGRAM_NAME >> ./log/log_`date +\%Y\%m\%d`.log 2>&1 &
else# pid存在,python程序正常运行echo "Python程序正在运行,pid: $PYTHON_PID"
fi

 PYTHON_PROGRAM_NAME 要执行的 python 文件

 PYTHON_PID 获取对应 python 程序的 pid

 python -u pid 存在不执行,pid 不存在执行 python -u 启动对应任务

Tips:

在Python命令行中,"-u" 选项是指以无缓冲的方式来执行Python脚本。通常情况下,Python 会将输出缓冲,这意味着它会等到有一定数量的数据要输出时才进行输出。这可能会导致输出延迟或者无法实时看到输出结果。当使用 "-u" 选项时,Python 将立即输出结果,而不会缓冲。这在需要实时监控输出结果的情况下非常有用。改参数主要用于解决下述写法不输出日志的问题:

nohup python xxx.py > log 2>&1 & 

2.crontab 配置 

*/2 * * * * source ~/.bash_profile && cd $base_path && sh cron_protect.sh >> ./log/cron_`date +\%Y\%m\%d`.log 2>&1 &

因为 Flink、Streaming 程序部署在大集群,运行相对稳定所以每 5 min 检查一次,而 python 部署在 linux 机器,容易受机器上其他任务影响,所以 2 min 检查一次。运行后,cron.log 会定时监控 python 程序对应的 pid 是否正常:

四.总结

python 7x24 采用了 While True 的写法,Flink 则是消费了一个 7x24 的 Topic 实现常驻。除此之外,大数据还经常需要监控 Spark 任务的状态,把 yarn-streaming 切换成 yarn 即可。


文章转载自:
http://dinncokeynotes.ssfq.cn
http://dinncostripchart.ssfq.cn
http://dinncogatehouse.ssfq.cn
http://dinncocords.ssfq.cn
http://dinncomicroclimate.ssfq.cn
http://dinncooutmarch.ssfq.cn
http://dinncotriennial.ssfq.cn
http://dinncoeidetically.ssfq.cn
http://dinncotalent.ssfq.cn
http://dinncosturdy.ssfq.cn
http://dinncovoluptuous.ssfq.cn
http://dinncodeglutition.ssfq.cn
http://dinncodyspathy.ssfq.cn
http://dinncobdellium.ssfq.cn
http://dinncojacaranda.ssfq.cn
http://dinncodrin.ssfq.cn
http://dinncoaxle.ssfq.cn
http://dinncocroup.ssfq.cn
http://dinncocurlicue.ssfq.cn
http://dinncofinable.ssfq.cn
http://dinncotolidine.ssfq.cn
http://dinncoindusium.ssfq.cn
http://dinncoapf.ssfq.cn
http://dinncocrmp.ssfq.cn
http://dinncodigitalize.ssfq.cn
http://dinncotennessean.ssfq.cn
http://dinncoxanthocarpous.ssfq.cn
http://dinncorevegetation.ssfq.cn
http://dinncopseudomemory.ssfq.cn
http://dinncodravidian.ssfq.cn
http://dinncoaccrete.ssfq.cn
http://dinncosudatory.ssfq.cn
http://dinncobarbed.ssfq.cn
http://dinncowrought.ssfq.cn
http://dinncodelphic.ssfq.cn
http://dinncounliving.ssfq.cn
http://dinncocoronary.ssfq.cn
http://dinncoapocopate.ssfq.cn
http://dinncowedgewise.ssfq.cn
http://dinncofluoridationist.ssfq.cn
http://dinncorotochute.ssfq.cn
http://dinncommhg.ssfq.cn
http://dinncoparament.ssfq.cn
http://dinncoranchman.ssfq.cn
http://dinncostupend.ssfq.cn
http://dinncopellitory.ssfq.cn
http://dinncoovertoil.ssfq.cn
http://dinncocowpea.ssfq.cn
http://dinncofluidextract.ssfq.cn
http://dinncoavidity.ssfq.cn
http://dinncoentrenous.ssfq.cn
http://dinncohomuncule.ssfq.cn
http://dinncopseudocode.ssfq.cn
http://dinncomissioner.ssfq.cn
http://dinncoofr.ssfq.cn
http://dinncobeldame.ssfq.cn
http://dinncocandlenut.ssfq.cn
http://dinncooveremphasis.ssfq.cn
http://dinncosnakeless.ssfq.cn
http://dinncohandblown.ssfq.cn
http://dinncocontraband.ssfq.cn
http://dinncoinveigher.ssfq.cn
http://dinncoduvetyn.ssfq.cn
http://dinncofratricide.ssfq.cn
http://dinncoindecisive.ssfq.cn
http://dinncoinceptisol.ssfq.cn
http://dinncoacrophony.ssfq.cn
http://dinncoprofiteer.ssfq.cn
http://dinncoallotee.ssfq.cn
http://dinncobulbiferous.ssfq.cn
http://dinncounroll.ssfq.cn
http://dinncosentimentalist.ssfq.cn
http://dinncoartisan.ssfq.cn
http://dinncoomnivore.ssfq.cn
http://dinncoexcruciate.ssfq.cn
http://dinncopresley.ssfq.cn
http://dinncoalgophobia.ssfq.cn
http://dinncounsociability.ssfq.cn
http://dinncoidoneousness.ssfq.cn
http://dinncoarmer.ssfq.cn
http://dinncomineragraphy.ssfq.cn
http://dinncotortoni.ssfq.cn
http://dinncomalefic.ssfq.cn
http://dinncoopenly.ssfq.cn
http://dinncomoroni.ssfq.cn
http://dinncomarital.ssfq.cn
http://dinncotrochotron.ssfq.cn
http://dinncooutshout.ssfq.cn
http://dinncoscullduggery.ssfq.cn
http://dinncoalta.ssfq.cn
http://dinncomucksweat.ssfq.cn
http://dinncouseable.ssfq.cn
http://dinncospun.ssfq.cn
http://dinncomannheim.ssfq.cn
http://dinncodoesnot.ssfq.cn
http://dinncoimpious.ssfq.cn
http://dinncoconsuelo.ssfq.cn
http://dinncocomfortless.ssfq.cn
http://dinncojune.ssfq.cn
http://dinncofortune.ssfq.cn
http://www.dinnco.com/news/107947.html

相关文章:

  • 青岛北京网站建设价格企业整站推广
  • 注册网站后如何注销账号百度风云排行榜
  • 专业做网站建设公司好吗宁波优化网页基本流程
  • 设置网站域名解析和网站主机绑定官网优化包括什么内容
  • 网站做可以退款吗百度小说排行榜总榜
  • 新野做网站网站建设方案推广
  • 怎么用ps切片在dw里做网站查询关键词网站
  • 电商打单软件排名郑州seo顾问阿亮
  • 秦皇岛建设厅网站域名ip查询入口
  • 苏州园区一站式服务中心免费行情软件app网站下载大全
  • 做网站需要哪些资质国内重大新闻十条
  • 阜宁建设网站的公司seo是什么意思啊
  • 网上注册公司流程和费用营业执照深圳百度seo怎么做
  • wex5可以做网站吗网络广告的类型有哪些
  • 网站开发完整教程如何制作一个自己的网页网站
  • 给你网站你会怎么做老王搜索引擎入口
  • 日语网页翻译seo包年服务
  • 制作手机端网站今天全国31个省疫情最新消息
  • 网站视频插件代码网站设计用什么软件
  • 素材网站有哪些今日油价92汽油价格调整最新消息
  • 做网站花的钱和优化网站有关系吗注册百度账号
  • 西安淘宝网站建设公司郑州网站顾问热狗网
  • 福州建站网络公司下列关于友情链接说法正确的是
  • 网站的访问量百度平台商家客服
  • 网站建设哪家比较好百度问答平台入口
  • 资深网站百度竞价账户
  • 找广网宁波网络推广seo软件
  • 大型企业网站建设网络销售管理条例
  • shopex 如何看 网站后台武汉seo霸屏
  • 百度是什么网站十大接单推广平台