如何将外部配置文件传递给 pyspark(Spark 2.x) 程序? [英] How to pass external configuration file to pyspark(Spark 2.x) program?

查看:73
本文介绍了如何将外部配置文件传递给 pyspark(Spark 2.x) 程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我运行 pyspark 程序时,交互式 shell 能够获取 pyspark 脚本中的配置文件(config.ini),但是,当我尝试使用 Spark 提交命令和主纱线运行相同的脚本时,集群部署模式是集群,它给我错误,因为配置文件不存在,我检查了纱线日志并能够看到相同的内容,下面是运行 pyspark 的命令工作.

When I am running pyspark program interactive shell able to fetch the configuration file(config.ini) inside pyspark script, But when I am trying to run same script using Spark submit command with master yarn and cluster deployment mode is cluster it giving me error as config file not exists, I have checked yarn log and able to see same, below is command for running the pyspark job.

spark2-submit --master yarn --deploy-mode cluster test.py /home/sys_user/ask/conf/config.ini

推荐答案

使用 spark2-sumbmit 命令有参数提供的属性文件,您可以使用它来获取此属性文件在 spark-提交命令.

With spark2-sumbmit command there is parameter provided properties-file, you can use that to get this properties file available in spark-submit command.

例如spark2-submit --master yarn --deploy-mode cluster --properties-file $CONF_FILE_NAME pyspark_script.py

e.g. spark2-submit --master yarn --deploy-mode cluster --properties-file $CONF_FILE_NAME pyspark_script.py

这篇关于如何将外部配置文件传递给 pyspark(Spark 2.x) 程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆