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    //配置信息
相关推荐
LaughingZhu2 小时前
Product Hunt 每日热榜 | 2026-02-08
大数据·人工智能·经验分享·搜索引擎·产品运营
玄同7653 小时前
Git常用命令指南
大数据·git·elasticsearch·gitee·github·团队开发·远程工作
瑞华丽PLM4 小时前
电子行业国产PLM系统功能差异化对比表
大数据·plm·国产plm·瑞华丽plm·瑞华丽
深圳市恒星物联科技有限公司5 小时前
水质流量监测仪:复合指标监测的管网智能感知设备
大数据·网络·人工智能
是做服装的同学6 小时前
如何选择适合的服装企业ERP系统才能提升业务效率?
大数据·经验分享·其他
藦卡机器人7 小时前
国产机械臂做的比较好的品牌有哪些?
大数据·数据库·人工智能
代码改善世界7 小时前
CANN深度解构:中国AI系统软件的原创性突破与架构创新
大数据·人工智能·架构
java-yi8 小时前
Elasticsearch(ES)核心用法与实战技巧分享
大数据·elasticsearch·搜索引擎
程序猿阿伟8 小时前
《分布式追踪Span-业务标识融合:端到端业务可观测手册》
分布式