spark 自定义外部配置参数的三种方式

文章目录

  • [1、通过脚本 --conf 方式来提交](#1、通过脚本 --conf 方式来提交)
  • [2、通过配置文件的方式--properties-file,如果不配置默认读取当前提交节点的 conf/spark-defaults.conf](#2、通过配置文件的方式–properties-file,如果不配置默认读取当前提交节点的 conf/spark-defaults.conf)
  • 3、通过main函数传递

前言
1、2 方式只能修改spark内置参数,外部自定义参数不支持此方式
如果传递,将提示

shell 复制代码
Warning: Ignoring non-spark config property: count.end.time=1564122000000

3方式可以用来传递自定义参数,通过args[]去获取

1、通过脚本 --conf 方式来提交

多个配置参会传递多个 --config

shell 复制代码
./bin/spark-submit  --class  com.xx.TestApp
  --master yarn 
  --deploy-mode cluster
   --driver-memory 1g 
   --num-executors 2 
   --executor-memory 512M 
   --executor-cores 2 
   //配置信息
   --conf spark.mongodb.input.uri=mongodb://192.168.1.2:27017/onemap-statis
    --conf spark.mongodb.output.collection=test_collection
     test-0.0.1-SNAPSHOT.jar

2、通过配置文件的方式--properties-file,如果不配置默认读取当前提交节点的 conf/spark-defaults.conf

shell 复制代码
./bin/spark-submit  
--class  com.xx.TestAppp 
 --master yarn 
 --deploy-mode cluster
  --driver-memory 1g 
  --num-executors 2 
  --executor-memory 512M
   --executor-cores 2 
      //配置信息
   --properties-file  extend.conf 
   test-0.0.1-SNAPSHOT.jar

3、通过main函数传递

arg0 arg1 arg3可以传递自定义参数,主函数里面获取

shell 复制代码
./bin/spark-submit 
 --class  com.xx.TestAppp
   --master yarn 
   --deploy-mode cluster
    --driver-memory 1g 
    --num-executors 2
     --executor-memory 512M
      --executor-cores 2 
       test-0.0.1-SNAPSHOT.jar arg0 arg1 arg3    //配置信息
相关推荐
人类群星闪耀时43 分钟前
物联网与大数据:揭秘万物互联的新纪元
大数据·物联网·struts
快手技术1 小时前
Blaze RangePartitioning 算子Native实现全解析
spark·naive
DC_BLOG4 小时前
Linux-GlusterFS进阶分布式卷
linux·运维·服务器·分布式
点点滴滴的记录5 小时前
分布式之Raft算法
分布式
桃林春风一杯酒7 小时前
HADOOP_HOME and hadoop.home.dir are unset.
大数据·hadoop·分布式
桃木山人7 小时前
BigData File Viewer报错
大数据·java-ee·github·bigdata
B站计算机毕业设计超人7 小时前
计算机毕业设计Python+DeepSeek-R1高考推荐系统 高考分数线预测 大数据毕设(源码+LW文档+PPT+讲解)
大数据·python·机器学习·网络爬虫·课程设计·数据可视化·推荐算法
数造科技8 小时前
紧随“可信数据空间”政策风潮,数造科技正式加入开放数据空间联盟
大数据·人工智能·科技·安全·敏捷开发
逸Y 仙X11 小时前
Git常见命令--助力开发
java·大数据·git·java-ee·github·idea
逻各斯11 小时前
Redisson分布式锁java语法, 可重入性实现原理 ,(还有可重试性,超时不释放,主从一致性)
分布式