美文网首页我爱编程
yarn-cluster 模式下获取driver ip

yarn-cluster 模式下获取driver ip

作者: 吐思圈 | 来源:发表于2018-03-06 22:24 被阅读0次

    spark on yarn共有两种提交方式,
    1 是yarn-client,此时driver节点就是spark作业的提交节点
    2 是yarn-cluster,此时spark作业的提交节点相当于一个提交client,只负责提交作业至yarn集群,applicationMaster(也即driver)是集群中的任一节点,所以需要通过其他方式来获取driver的信息;

    目前可以通过如下几种方式来获取
    1、yarnClient API

    val appReport = yarnClient.getApplication(appid)
    val amHost = appReport.getHost()
    

    2、yarn rest API
    yarn提供了非常多的rest API,其中

    GET [http://rm-http-address:port/ws/v1/cluster/apps/appId]
    
    返回结果(json或者XML)如下:
    ...
    "amHostHttpAddress": "host.domain.com:8042",
    ...
    
    

    3、yarn运行日志
    1)作业运行完以后,在yarn的任一节点执行yarn logs -applicationId appId 可以获取完整的运行日志,其中即包括driver的日志也包括各executor的日志

    2)yarn中资源的最小单位是container,其中container编号为000001的即是AM所在的container,可以在日志中找到如下信息:

    Container: container_e02_1519868127773_1010_01_000001 on hostname_8041
    

    3)此外,也可以根据driverUrl关键字搜索日志获取:

    driverUrl: spark://CoarseGrainedScheduler@172.168.4.8:35377,  executorHostname: hostname
    

    参考:
    1、http://hadoop.apache.org/docs/r2.6.0/api/org/apache/hadoop/yarn/api/records/ApplicationReport.html
    2、http://hadoop.apache.org/docs/current/hadoop-yarn/hadoop-yarn-site/ResourceManagerRest.html#Cluster_Metrics_API
    3、https://hvivani.com.ar/2016/03/30/get-the-driver-ip-in-spark-yarn-cluster-mode/

    相关文章

      网友评论

        本文标题:yarn-cluster 模式下获取driver ip

        本文链接:https://www.haomeiwen.com/subject/wkwnxftx.html