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    //配置信息
相关推荐
Touch_Base10 小时前
护照、身份证与罚单:动力电池出海的隐性门槛
大数据·人工智能·创业创新·esg·可持续
Volunteer Technology10 小时前
ES相关度评分算法
大数据·算法·elasticsearch
科研前沿10 小时前
像素即坐标・室外无边界:2026 最新无感定位技术,驱动数字孪生实景可控—— 镜像视界技术白皮书
大数据·人工智能·算法·重构·空间计算
Elastic 中国社区官方博客10 小时前
2026 年金融服务可观测性现状:从实施到业务影响
大数据·运维·人工智能·elasticsearch·搜索引擎·金融·自动化
财经资讯数据_灵砚智能10 小时前
基于全球经济类多源新闻的NLP情感分析与数据可视化(日间)2026年5月1日
大数据·人工智能·python·信息可视化·自然语言处理
无忧智库10 小时前
城市级实景三维底座建设:从倾斜摄影到数字孪生的完整工程解构(WORD)
大数据
长河11 小时前
XXL-JOB 从本地快速上手到核心架构深度解析
分布式
juniperhan11 小时前
Flink 系列第22篇:Flink SQL 参数配置与性能调优指南:从 Checkpoint 到聚合优化
大数据·数据仓库·分布式·sql·flink
盟接之桥11 小时前
盟接之桥说制造:深耕长尾市场,跨越价值“临界点”
大数据·网络·安全·低代码·汽车·制造
黎阳之光11 小时前
黎阳之光:视频孪生赋能国际盛会,定义数字孪生全球新标杆
大数据·人工智能·算法·安全·数字孪生