Spark的jar包比较多,如果直接修改spark的jars目录中的jar可能对用户造成jar包冲突,也不利于管理,因为可以利用HDFS存储功能解决jar问题
1、在本地创建zip文件,压缩jar包
# 进入到spark的jars目录,在spark的jars目录下压缩包
zip spark.zip ./*
2、HDFS上创建存放spark jar目录
hdfs dfs -mkdir -p /spark-yarn/jars
3、将$SPARK_HOME/jars下的spark.zip包上传至刚健的HDFS路径
[hadoop@hadoop jars]$ hdfs dfs -put ./spark.zip /spark-yarn/jars/
4、在spark-defaults.conf中添加(也可以在启动时候 -conf 指定)
spark.yarn.archive hdfs://ruozedata001:9000/spark-jars/spark.zip
5、查看Spark log
yarn log -applicationID xxx