谈谈 Spark 应用日志级别的坑

栏目: 编程工具 · 发布时间: 5年前

内容简介:环境说明:HDP 3.0 + Kerberos + Livy根据第三种方案是我们最不希望看到的选择,因而选择了第一、二两种进行尝试。

环境说明:HDP 3.0 + Kerberos + Livy

根据 Spark 官方文档的指引,清楚的知道存在三种方式可以对应用的日志级别进行调整。

  • upload a custom log4j.properties using spark-submit , by adding it to the --files list of files to be uploaded with the application.
  • add -Dlog4j.configuration=<location of configuration file> to spark.driver.extraJavaOptions (for the driver) or spark.executor.extraJavaOptions (for executors). Note that if using a file, the file: protocol should be explicitly provided, and the file needs to exist locally on all the nodes.
  • update the $SPARK_CONF_DIR/log4j.properties file and it will be automatically uploaded along with the other configurations. Note that other 2 options has higher priority than this option if multiple options are specified.

第三种方案是我们最不希望看到的选择,因而选择了第一、二两种进行尝试。

第一种方案

过程:

  1. 将编辑准备好的 log4j-error.properties 文件上传到 HDFS
  2. 授予接下来启动 Spark 应用的用户读取权限
  3. 启动参数中,添加 "files":["/logfile/log4j-error.properties"] 参数,来指定 log4j.properties 文件路径。
  4. 启动参数中,添加 "spark.driver.extraJavaOptions": "-Dlog4j.configuration=log4j-error.properties","spark.executor.extraJavaOptions": "-Dlog4j.configuration=log4j-error.properties" ,相对路径即可
  5. 使用 Livy 进行启动应用

这里的可能遇到的问题:

  • -files 参数是数组,不是简单的 String
  • spark.driver.extraJavaOptions 用于 Driver 的日志级别文件的指定, "spark.executor.extraJavaOptions 用于 Executor 的日志级别文件的指定。可以单独分别指定,支持相对路径。
  • HDFS 下文件的权限一定要注意

第二种方案

过程:

  1. 将编辑准备好的 log4j-error.properties 文件上传到 Spark Server 所在服务器的 $SPARK_CONF_DIR/ 目录下
  2. 授予 log4j-error.properties 文件读取权限,粗暴一点直接设置为 777
  3. 启动参数中,添加 "spark.driver.extraJavaOptions": "-Dlog4j.configuration=log4j-error.properties","spark.executor.extraJavaOptions": "-Dlog4j.configuration=log4j-error.properties" ,如果相对路径不生效,可以使用绝对路径( file:/spark/conf/log4j-error.properties )
  4. 使用 Livy 进行启动应用

这里的可能遇到的问题:

  • 读取的权限,一定要启动应用的用户拥有权限
  • 所有 Spark 节点下都要有日志文件哦

第三种方案

过程:

HDP Ambari 

这里的可能遇到的问题:

  • 优先级该方案是三者中最低的,前两种都可以覆盖该种方案

谈谈 log4j 配置

自定义某路径下的日志级别

比如:希望 com.zerostech.demo 路径下日志级别为 ERROR

log4j.logger.com.zerostech.demo=ERROR

以上所述就是小编给大家介绍的《谈谈 Spark 应用日志级别的坑》,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对 码农网 的支持!

查看所有标签

猜你喜欢:

本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们

Python神经网络编程

Python神经网络编程

[英]塔里克·拉希德(Tariq Rashid) / 林赐 / 人民邮电出版社 / 2018-4 / 69.00元

神经网络是一种模拟人脑的神经网络,以期能够实现类人工智能的机器学习 技术。 本书揭示神经网络背后的概念,并介绍如何通过Python实现神经网络。全书 分为3章和两个附录。第1章介绍了神经网络中所用到的数学思想。第2章介绍使 用Python实现神经网络,识别手写数字,并测试神经网络的性能。第3章带领读 者进一步了解简单的神经网络,观察已受训练的神经网络内部,尝试进一步改......一起来看看 《Python神经网络编程》 这本书的介绍吧!

HTML 编码/解码
HTML 编码/解码

HTML 编码/解码

Base64 编码/解码
Base64 编码/解码

Base64 编码/解码

XML 在线格式化
XML 在线格式化

在线 XML 格式化压缩工具