基于Yarn API的Spark程序监控
一.简述
基于对Yarn ResourceManager中运行程序的状态(RUNNING、KILLED、FAILED、FINISHED)以及ApplicationMaster中Application的Job执行时长超过批次时间的监控,来达到对Spark on Yarn程序的失败重启、超时重启等功能
二.Yarn主要的几类API
1.查询整个集群指标
GET http:// http address:port>/ws/v1/cluster/metrics
2.查询集群调度器详情
GET http:// http address:port>/ws/v1/cluster/scheduler
3.监控任务
curl 'http:// http address:port>/ws/v1/cluster/apps//state'
GET http:// http address:port>/ws/v1/cluster/apps//state
4.查看指定任务
GET http:// http address:port>/ws/v1/cluster/apps/
5.查看指定任务的详细信息
curl http:// http address:port>/proxy//ws/v2/mapreduce/info"
6.杀死任务
yarn application -kill application_id
curl -v -X PUT -d '{"state": "KILLED"}''http:// http address:port>/ws/v1/cluster/apps/'
PUT http:// http address:port>/ws/v1/cluster/apps//state
三.YarnMonitor
Ⅰ. Setup
1. install yarn-api-client
you mast install yarn-api-client when you use this yarn monitor
python setup.py build
python setup.py install
2. uninstall yarn-api-client
when you need uninstall this yarn-api-client model,use this
- pip list
- pip uninstall yarn-api-client
3. upate yarn-api-client
when you need update python model,you need unintall and update
- update yarn-api-client
- cp yarn-api-client/base.py base.py.bak
4. offline intall python model
when you need intall other python model,you can do this
- pip freeze > yarn.txt
- mkdir yarnpackage
- pip install --no-index --find-links=yarnpackage/ -r yarn.txt
Ⅱ. Command
you should modify the script permissions
chmod 774 start_prmsbd.sh
Ⅲ. Crontab
configure crontab task
crontab -l
crontab -e
1.start yarn monitor
*/1 * * * * ../yarnmonitor/yarn-monitor/command/start_yarn_monitor.sh >> ../yarnmonitor/yarn-monitor/logs/yarn-corntab.log 2>&1 * * * * * sleep 60; ../yarnmonitor/yarn-monitor/command/start_yarn_monitor.sh
2.clear yarn monitor log
0 4 * * * ../yarn-monitor/command/clear_log_opm.sh >> ../yarn-monitor/logs/yarn-corntab.log 2>&1 0 4 * * * ../yarnmonitor/yarn-monitor/command/clear_log_opm.sh >> ../yarnmonitor/yarn-monitor/logs/yarn-corntab.log 2>&1
Ⅳ. Just for test
1. start yarn command
../python ./yarn-monitor/YarnMonitor.py
2. Application_Master API
curl --compressed -H "Accept: application/json" -X GET "http://***:8088/ws/v1/cluster/apps" curl --compressed -H "Accept: application/json" -X GET "http://***:8088/ws/v1/cluster/apps" curl --compressed -H "Accept: application/json" -X GET "http://***:8088/proxy/application_1549963435527_0001/ws/v1/mapreduce/info" curl --compressed -H "Accept: application/json" -X GET "http://***:8088/proxy/application_1535085750394_0017/ws/v1/mapreduce/info" curl --compressed -H "Accept: application/json" -X GET "http://***:8088/proxy/application_1535085750394_0017/ws/v2/mapreduce/info" curl --compressed -H "Accept: application/json" -X GET "http://***:8088/proxy/application_1535085750394_0017/ws/v1/mapreduce/jobs/4536" curl --compressed -H "Accept: application/json" -X GET "http://***:8088/proxy/application_1548125170651_0090/api/v1/applications"
四.问题
其中,在ApplicationMaster中查询Job的返回数据无法转json的异常时,需修改yarn-api-client中修改对应API返回数据,可参考:
if 'ws/v1/mapreduce/info' in path: if response.status == OK: html_content = response.read() element_html = etree.HTML(html_content) tr_list = element_html.xpath('//tbody/tr') content_list = [] for tr in tr_list: item = {} item['id'] = tr.xpath('./td[1]/text()')[0].replace('\n', '').strip() item['duration'] = tr.xpath('./td[4]/text()')[0] # 打印每条信息 # logging.info(item) content_list.append(item) # print content_list return content_list response.close() return self.response_class(content_list) else: msg = 'Response finished with status: %s' % response.status raise APIError(msg)
低调大师中文资讯倾力打造互联网数据资讯、行业资源、电子商务、移动互联网、网络营销平台。
持续更新报道IT业界、互联网、市场资讯、驱动更新,是最及时权威的产业资讯及硬件资讯报道平台。
转载内容版权归作者及来源网站所有,本站原创内容转载请注明来源。
- 上一篇
MaxCompute技术人背后的故事:从ApacheORC到AliORC | 7月25号云栖夜读
点击订阅云栖夜读日刊,专业的技术干货,不容错过! 阿里专家原创好文 1.MaxCompute技术人背后的故事:从ApacheORC到AliORC 2019大数据技术公开课第一季《技术人生专访》来袭,本季将带领开发者们探讨大数据技术,分享不同国家的工作体验。本文整理自阿里巴巴计算平台事业部高级技术专家吴刚的专访,将为大家介绍Apache ORC开源项目、主流的开源列存格式ORC和Parquet的区别以及MaxCompute选择ORC的原因。此外,吴还将分享他是如何一步步成为Apache开源项目的Committer和PMC的。阅读更多》》 2.一个系统,搞定闲鱼服务端复杂问题告警-定位-快速处理 务端问题排查(服务稳定性/基础设施异常/业务数据不符合预期等)对于开发而言是家常便饭,问题并不可怕,但是每天都要花大量时间去处理问题会很可怕;另一方面故障的快速解决至关重要。那么目前问题排查最大的障碍是什么呢?阅读更多》》 3.Kubenetes 监控一站式解决方案:阿里云 Prometheus 免费公测 Prometheus是目前企业级云原生应用的首选开源监控工具。作为云原生计算基金会(CNCF...
- 下一篇
MaxCompute 助力衣二三构建智能化运营工具
摘要:本文由衣二三CTO程异丁为大家讲解了如何基于MaxCompute构建智能化运营工具。衣二三作为亚洲最大的共享时装平台,MaxCompute是如何帮助它解决数据提取速度慢、数据口径差异等问题呢?程异丁通过衣二三数据体系架构,从用户运营应用、商品运营应用以及算法推荐系统三方面给大家剖析了MaxCompute是如何助力衣二三构建智能化运营工具的。 以下是精彩视频内容整理。 衣二三是谁?衣二三是亚洲最大的共享时装平台。衣二三提供女性服饰包月租赁制服务,会员们在APP上挑选喜爱的衣服,可以在平台上用固定的月费在一整月内不断地换穿衣服,衣二三通过快递将衣服送到客户手中,客户只要会员期有效,就可以一直穿这件衣服,当会员不想穿的时候,衣二三还会通过快递按照约定的时间地点将衣服收回,这样会员就可以继续下新的订单,可以不断地换穿各种衣服。我们的客户
相关文章
文章评论
共有0条评论来说两句吧...