一、参数说明
启动Spark任务时,在没有配置spark.yarn.archive
或者spark.yarn.jars
时, 会看到不停地上传jar,非常耗时;使用spark.yarn.archive
可以大大地减少任务的启动时间,整个处理过程如下。
二、spark.yarn.archive使用
1.在本地创建zip文件
[email protected]:~/env/spark$ cd jars/ [email protected]:~/env/spark$ zip spark2.0.0.zip ./*
注:zip包为全量包
2.上传至HDFS并更改权
[email protected]:~/env/spark$ /usr/ndp/current/hdfs_client/bin/hdfs dfs -mkdir /tmp/spark-archive [email protected]:~/env/spark$ /usr/ndp/current/hdfs_client/bin/hdfs dfs -put ./spark2.0.0.zip /tmp/spark-archive [email protected]:~/env/spark$ /usr/ndp/current/hdfs_client/bin/hdfs dfs -chmod 775 /tmp/spark-archive/spark2.0.0.zip.zip
3.配置spark-defaut.conf
spark.yarn.archive hdfs:///tmp/spark-archive/spark2.0.0.zip
三、spark.yarn.jars使用说明
1. 上传依赖jar包
[email protected]:~/env/spark$ /usr/ndp/current/hdfs_client/bin/hdfs dfs -mkdir hdfs://bd01/user/asiainfo/jars/[email protected]:~/env/spark$ /usr/ndp/current/hdfs_client/bin/hdfs dfs -put ./spark2.0.0.zip hdfs://bd01/user/asiainfo/jars/[email protected]:~/env/spark$ /usr/ndp/current/hdfs_client/bin/hdfs dfs -chmod 775 hdfs://bd01/user/asiainfo/jars/spark2.0.0.zip.zip
2.配置spark-defaut.conf
spark.yarn.jars=local:/opt/cloudera/parcels/CDH-6.1.0-1.cdh6.1.0.p0.770702/lib/spark/jars/*,local:/opt/cloudera/parcels/CDH-6.1.0-1.cdh6.1.0.p0.770702/lib/spark/hive/*,hdfs://bd01/user/asiainfo/jars/*.jar
注:本地配置local,hdfs标记为hdfs目录即可
原文地址:https://www.cnblogs.com/yyy-blog/p/11110388.html
时间: 2024-10-10 22:47:18