Spark History Server配置

(1) 修改spark-defaults.conf配置文件

该文件在SPARK_HOME/conf/下,新安装的spark中只有spark-defaults.conf.template这个文件,改名为spark-defaults.conf即可

[root@repo conf]# vim spark-defaults.conf

spark.eventLog.enabled true
spark.eventLog.dir hdfs://repo:9000/spark/historyLog
spark.history.fs.logDirectory hdfs://repo:9000/spark/historyLog
# spark.eventLog.compress true # 可以设置保存历史日志时进行压缩

注意:

  • 保存历史数据的目录需要先创建好
  • 上面配置的两个目录必须是一样的
  • 如果你的hadoop是HA集群,那两个目录的路径要写hdfs://your-clustername/spark/historyLog,your-clustername由hdfs-site.xml中的dfs.nameservices来配置,另外,your-clustername后面不用加端口!我曾经因为写成这样:hdfs://mycluster:9000/user/hadoop/spark/historyLog而报错:
Exception in thread "main" java.io.IOException: Port 9000 specified in URI hdfs://mycluster:9000/user/hadoop/spark/historyLog but host 'mycluster' is a logical (HA) namenode and does not use port information.

浪费了一天时间!血的教训!

(2) 启动history server

[root@repo conf]# start-history-server.sh

(3) 访问web界面

《Spark History Server配置》

(4) 测试

提交一个spark任务

spark-submit \
--class org.apache.spark.examples.SparkPi \
--master spark://repo:7077 \
--executor-memory 2G \
--total-executor-cores 1 \
/opt/spark-2.2.0/examples/jars/spark-examples_2.11-2.2.0.jar \
1000

查看web页面

《Spark History Server配置》

查看hdfs上的日志文件

《Spark History Server配置》

Spark History Server配置成功!

    原文作者:CoderJed
    原文地址: https://www.jianshu.com/p/4a631b772178
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞