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    //配置信息
相关推荐
bubble小拾2 小时前
ElasticSearch高级功能详解与读写性能调优
大数据·elasticsearch·搜索引擎
ZOHO项目管理软件2 小时前
EDM平台大比拼 用户体验与营销效果双重测评
大数据
weixin_453965002 小时前
[单master节点k8s部署]31.ceph分布式存储(二)
分布式·ceph·kubernetes
坎坎坷坷.2 小时前
分布式理论:拜占庭将军问题
分布式
HyperAI超神经3 小时前
Meta 首个多模态大模型一键启动!首个多针刺绣数据集上线,含超 30k 张图片
大数据·人工智能·深度学习·机器学习·语言模型·大模型·数据集
Hello.Reader5 小时前
TopK算法在大数据重复数据分析中的应用与挑战
大数据·算法·数据分析
数据龙傲天5 小时前
1688商品API接口:电商数据自动化的新引擎
java·大数据·sql·mysql
Elastic 中国社区官方博客5 小时前
Elasticsearch:使用 LLM 实现传统搜索自动化
大数据·人工智能·elasticsearch·搜索引擎·ai·自动化·全文检索
Jason不在家7 小时前
Flink 本地 idea 调试开启 WebUI
大数据·flink·intellij-idea
Elastic 中国社区官方博客8 小时前
使用 Vertex AI Gemini 模型和 Elasticsearch Playground 快速创建 RAG 应用程序
大数据·人工智能·elasticsearch·搜索引擎·全文检索