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    //配置信息
相关推荐
链上日记2 小时前
从公开信息看WEEX的运营轨迹
大数据·区块链
江畔柳前堤2 小时前
具身智能全景深度指南(2026年9月版):从“会聊天的AI“到“能干活的机器“
大数据·javascript·图像处理·人工智能·分布式·智慧城市·原型模式
GlobalInfo3 小时前
创新不是追逐热点,是在变化中建立长期竞争力
大数据·算法
夕除3 小时前
redis--010
笔记·分布式·学习
Safeploy安策数据3 小时前
国密合规怎么落地?从密钥管理到内网安全完整流程
大数据·安全
2601_960017624 小时前
饲料添加剂研发PLM选型:解读一半科技流程行业适配能力
大数据
baopixiaoz4 小时前
BeeQuant × BeeAgent:AI量化新范式
大数据·人工智能·python·区块链
Raas1004 小时前
AI网关在架构中的位置?MAI Gateway(魔芋企业级AI网关)给出企业级答案
大数据·网络·人工智能·架构·gateway·ai网关·mai gateway
2601_960017624 小时前
油田化学品PLM系统选型:一半科技聚焦配方、工艺、数据管理
大数据·科技
IT毕设实战小研4 小时前
基于大数据的AI应用对就业与收入增长的区域差异分析及可视化
大数据·人工智能·python·随机森林·机器学习·课程设计